-- Copyright (C) 1983  by Xerox Corporation. All rights reserved. 
-- BootServerFriends.Mesa, HGM, 23-Sep-83  3:15:05

DIRECTORY
  File USING [File],
  MFile USING [Handle],
  Space USING [Interval],
  Stream USING [Handle],
  System USING [GreenwichMeanTime, gmtEpoch],
  BootServerBasics USING [BootFileNumber],
  BootServer USING [BootFileType, MachineType];

BootServerFriends: DEFINITIONS =
  BEGIN

  FileHandle: TYPE = MFile.Handle;

  BootFileNumber: TYPE = BootServerBasics.BootFileNumber;

  FindBootFile: PROCEDURE [BootFileNumber] RETURNS [BootFile];  -- NIL if not found, move to front of chain
  FindBootFileByName: PROCEDURE [LONG STRING] RETURNS [BootFile];  -- NIL if not found, move to front of chain
  EnumerateBootTable: PROCEDURE [PROCEDURE [BootFile]];  -- With LOCK Locked
  GetPointerToBootTable: PROCEDURE RETURNS [LONG POINTER TO BootFile];  -- For Debugging

  ActivateFiles: PROCEDURE;
  AddBootFile: PROCEDURE [
    BootFileNumber, LONG STRING, BootFileType, MachineType, BOOLEAN];
  DeactivateFiles: PROCEDURE;
  DeleteBootFileTable: PROCEDURE;

  ActivateFileSystem: PROCEDURE;
  ActivateFile: PROCEDURE [BootFile];
  LockFileRead: PROCEDURE [BootFile] RETURNS [BOOLEAN];
  SetupSpace: PROCEDURE [BootFile];
  ReadStreamFromBootFile: PROCEDURE [BootFile] RETURNS [Stream.Handle];
  UnlockFile: PROCEDURE [BootFile];
  KillSpace: PROCEDURE [BootFile];
  ReleaseFile: PROCEDURE [BootFile];
  DeactivateFile: PROCEDURE [BootFile];
  DeactivateFileSystem: PROCEDURE[];

  CreateTempFile: PROCEDURE RETURNS [FileHandle, Stream.Handle];
  MakeTempFileIntoBootFile: PROCEDURE [BootFile, FileHandle] RETURNS [BOOLEAN];
  DeleteTempFile: PROCEDURE [FileHandle];

  MachineType: TYPE = BootServer.MachineType;
  BootFileType: TYPE = BootServer.BootFileType;

  BootFile: TYPE = LONG POINTER TO BootFileObject;
  BootFileObject: TYPE = RECORD [
    next: BootFile,
    code: BootFileNumber,
    create: System.GreenwichMeanTime,
    handle: FileHandle,
    file: File.File,
    fileName: LONG STRING,
    ms: LONG CARDINAL,  -- total time spend booting
    count: LONG CARDINAL,
    pages: CARDINAL,
    bytes: LONG CARDINAL,
    space: Space.Interval,  -- nullInterval if inactive
    tries: [0..20),
    useCount: [0..100),
    pup: BOOLEAN,
    fileType: BootFileType,
    machineType: MachineType,
    unknown, inTransit: BOOLEAN];


  timeNotKnown: System.GreenwichMeanTime = System.gmtEpoch;

  pagesPerSwapUnit: CARDINAL = 15;

  END.