-- ImageDefs.mesa  Modified by: Sandman, August 12, 1980  11:29 AM
-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  TimeStamp USING [Stamp],
  Mopcodes USING [zKFCB, zLI0, zSTOP],
  BcplOps USING [CleanupReason, BcplOpcode],
  SDDefs USING [sAddFileRequest],
  SegmentDefs USING [AccessOptions, FileHandle, FileSegmentHandle],
  TimeDefs USING [PackedTime];

ImageDefs: DEFINITIONS =
  BEGIN

  FileRequest: TYPE = RECORD [
    link: POINTER TO FileRequest,
    file: SegmentDefs.FileHandle,
    access: SegmentDefs.AccessOptions,
    name: STRING];

  AddFileRequest: PROCEDURE [POINTER TO FileRequest] = MACHINE CODE
    BEGIN Mopcodes.zKFCB, SDDefs.sAddFileRequest END;

  MakeImage: PROCEDURE [name: STRING, merge: BOOLEAN ← TRUE];
  MakeUnMergedImage: PROCEDURE [name: STRING] = INLINE
    BEGIN MakeImage[name, FALSE] END;

  SwapOutDuringMakeImage: SIGNAL;
  SwapTrapDuringMakeImage: SIGNAL;
  SwapErrorDuringMakeImage: SIGNAL;
  NoRoomInImageMap: SIGNAL;
  InvalidImageName: SIGNAL;

  MakeCheckPoint: PROCEDURE [name: STRING] RETURNS [restart: BOOLEAN];
  SwapOutDuringMakeCheck: SIGNAL;
  SwapTrapDuringMakeCheck: SIGNAL;
  SwapErrorDuringMakeCheck: SIGNAL;
  NoRoomInCheckMap: SIGNAL;

  RunImage: PROCEDURE [file: SegmentDefs.FileSegmentHandle];
  InvalidImage: SIGNAL;
  NoRoomForLoader: SIGNAL;

  BcdTime: PROCEDURE RETURNS [TimeDefs.PackedTime];
  BcdVersion: PROCEDURE RETURNS [TimeStamp.Stamp];
  ImageTime: PROCEDURE RETURNS [TimeDefs.PackedTime];
  ImageVersion: PROCEDURE RETURNS [TimeStamp.Stamp];

  CleanupItem: TYPE = RECORD [
    link: POINTER TO CleanupItem, mask: CARDINAL, proc: CleanupProcedure];

  CleanupProcedure: TYPE = PROCEDURE [why: CleanupReason];

  CleanupMask: ARRAY CleanupReason OF CARDINAL =
    [1, 2, 4, 10B, 20B, 40B, 100B, 200B, 400B, 1000B];
  AllReasons: CARDINAL = 177777B;
  CleanupReason: TYPE = BcplOps.CleanupReason;
  BcplOpcode: TYPE = BcplOps.BcplOpcode;

  AddCleanupProcedure, RemoveCleanupProcedure: PROCEDURE [POINTER TO CleanupItem];
  UserCleanupProc: CleanupProcedure;

  StopMesa: PROCEDURE = MACHINE CODE
    BEGIN
    Mopcodes.zLI0 + LOOPHOLE[BcplOpcode[Finish], CARDINAL];
    Mopcodes.zSTOP
    END;

  AbortMesa: PROCEDURE = MACHINE CODE
    BEGIN
    Mopcodes.zLI0 + LOOPHOLE[BcplOpcode[Abort], CARDINAL];
    Mopcodes.zSTOP
    END;

  PuntMesa: PROCEDURE = MACHINE CODE
    BEGIN
    Mopcodes.zLI0 + LOOPHOLE[BcplOpcode[Punt], CARDINAL];
    Mopcodes.zSTOP
    END;


  END..