-- File: BootServerDefs.Mesa,  Last Edit: HGM  February 4, 1981  10:52 PM

DIRECTORY
  InlineDefs USING [BcplLongNumber],
  System USING [GreenwichMeanTime, gmtEpoch],
  Window USING [Handle],
  File USING [Capability],
  Space USING [Handle],
  StatsDefs USING [StatCounterIndex],
  BufferDefs USING [PupBuffer],
  PupTypes USING [PupType, PupAddress],
  MiscServerDefs USING [
    lockBooterRequest, lockBooterReply, unlockBooterRequest, unlockBooterReply,
    bootStatsRequest, bootStatsReply, microcodeRequest, microcodeReply];

BootServerDefs: DEFINITIONS =
  BEGIN

  PupBootServerOn: PROCEDURE;
  PupBootServerOff: PROCEDURE;
  StartProbingForBootFiles: PROCEDURE;
  StartLongRangeProbingForBootFiles: PROCEDURE;
  EnumerateBootTable: PROCEDURE [PROCEDURE [BootFile]];


  BootFile: TYPE = POINTER TO BootFileObject;
  BootFileObject: TYPE = RECORD [
    next: BootFile,
    code: WORD,
    create: System.GreenwichMeanTime,
    file: File.Capability,
    fileName: STRING,
    ms: LONG CARDINAL, -- total time spend booting
    count: LONG CARDINAL,
    pages: CARDINAL,
    bytes: LONG CARDINAL,
    space: Space.Handle, -- nullHandle if inactive
    tries: [0..20),
    unknown, inTransit: BOOLEAN];

  pagesPerSwapUnit: CARDINAL = 15;

  BootFileHeader: TYPE = RECORD [
    -- disk boot loader is first page
    other: ARRAY [0..3) OF WORD,
    timeStamp: InlineDefs.BcplLongNumber];

  timeNotKnown: System.GreenwichMeanTime = System.gmtEpoch;

  kissOfDeath: PupTypes.PupType = LOOPHOLE[247B];

  lockBooterRequest: PupTypes.PupType = MiscServerDefs.lockBooterRequest;
  lockBooterReply: PupTypes.PupType = MiscServerDefs.lockBooterReply;
  unlockBooterRequest: PupTypes.PupType = MiscServerDefs.unlockBooterRequest;
  unlockBooterReply: PupTypes.PupType = MiscServerDefs.unlockBooterReply;

  bootStatsRequest: PupTypes.PupType = MiscServerDefs.bootStatsRequest;
  bootStatsReply: PupTypes.PupType = MiscServerDefs.bootStatsReply;

  microcodeRequest: PupTypes.PupType = MiscServerDefs.microcodeRequest;
  microcodeReply: PupTypes.PupType = MiscServerDefs.microcodeReply;

  microcodeVersionNumber: CARDINAL = 1;

  BootStatsEntry: TYPE = RECORD [
    version: WORD,
    directories: InlineDefs.BcplLongNumber,
    fastSends: InlineDefs.BcplLongNumber,
    slowSends: InlineDefs.BcplLongNumber,
    filesRecv: InlineDefs.BcplLongNumber];
  bootVersion: WORD = 2;


  statLife: StatsDefs.StatCounterIndex;
  statBootNew: StatsDefs.StatCounterIndex;
  statBootDir, statFile, statFileSent, statFileSentSlow:
    StatsDefs.StatCounterIndex;
  statFileTroubles, statFileNeverStarted, statBusyDisk:
    StatsDefs.StatCounterIndex;
  statBusyBooting, statMicrocodeBooted, statUnknown: StatsDefs.StatCounterIndex;

  -- Internal things
  lock: MONITORLOCK;
  running, pleaseStop, booting, slowBooting, probing, sloshing, visible: BOOLEAN;
  SendBootDir: PROCEDURE [BufferDefs.PupBuffer]; -- NIL to Broadcast
  GetPointerToBootTable: PROCEDURE RETURNS [POINTER TO BootFile];
  PupBootServer: PROCEDURE [BufferDefs.PupBuffer];
  BreatherOn: PROCEDURE;
  BreatherOff: PROCEDURE;
  LookAtBootDir: PROCEDURE [BufferDefs.PupBuffer];
  BootServerStats: PROCEDURE [BufferDefs.PupBuffer];

  -- Pilot things
  pagesInVM, maxPagesInVM: CARDINAL;
  KillSpace, SetupSpace: PROCEDURE [BootFile];

  WhatHappened: TYPE = {fast, slow, micro, diskBusy, neverStarted, troubles};
  SlowBooter, FastBooter, MicrocodeBooter: PROCEDURE [
    BootFile, PupTypes.PupAddress] RETURNS [WhatHappened];

  UpdatePicture: PROCEDURE;
  msg, form: Window.Handle;
  slowBooteeHost, slosheeHost: STRING;
  slowBootFileName, slosheeFileName: STRING;

  END.