-- File: BootmesaOps.Mesa
-- Last edited by Sandman; July 10, 1980  7:38 AM
-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  AltoDefs USING [PageNumber],
  BcdDefs USING [BCD, VersionStamp],
  BcdOps USING [MTHandle],
  ControlDefs USING [GFTIndex, GlobalFrameHandle],
  ImageFormat USING [ImageHeader],
  SegmentDefs USING [FileHandle, FileSegmentHandle],
  SegOps USING [Seg, CodeClass],
  StreamDefs USING [StreamHandle],
  WartDefs USING [Header, TableBase];

BootmesaOps: DEFINITIONS =
  BEGIN OPEN AltoDefs, SegOps, ControlDefs;
  
  FirstFrameWord: TYPE = MACHINE DEPENDENT RECORD [
    gfi: GFTIndex,
    unused: [0..1],
    copied, alloced, shared, started: BOOLEAN,
    trapxfers, codelinks: BOOLEAN];
  
  -- From Script
  
  segTable, linkTable: WartDefs.TableBase;
  InitializeBootScript: PROCEDURE;
  FinishBootScript: PROCEDURE [startframe: GlobalFrameHandle] RETURNS [POINTER];
  DeclareSegs: PROCEDURE;
  DeclareCodeLinks: PROCEDURE;
  DeclareUnlocked: PROCEDURE [s: Seg];
  WriteScriptSegments: PROCEDURE;
  DisableHyperspace: PROCEDURE;
  
  -- From Image
  
  
  WriteSwappedIn: PROCEDURE [s: Seg] RETURNS [BOOLEAN];
  WriteSwappedOut: PROCEDURE [s: Seg] RETURNS [BOOLEAN];
  SegmentToMap: PROCEDURE [Seg];
  EnterMapSegment: PROCEDURE [Seg];
  DeclareSegments: PROCEDURE;
  WriteData, WriteNonData: PROCEDURE;
  GetImageHeader: PROCEDURE RETURNS [SegmentDefs.FileSegmentHandle];
  InitializeImage: PROCEDURE;
  WriteImage: PROCEDURE;
  
  -- From Bootmesa
  
  
  InitializeHeap: PROCEDURE;
  AllocGlobalFrame: PROCEDURE [framesize, nlinks: CARDINAL, framelinks: BOOLEAN]
    RETURNS [POINTER];
  InitializeLoadState: PROCEDURE;
  MapLoadStates: PROCEDURE;
  MapResidentCode: PROCEDURE;
  MapSwappedInCode: PROCEDURE;
  AdjustBcd: PROCEDURE [Seg];
  InitializeBootmesa: PROCEDURE [STRING] RETURNS [BcdDefs.VersionStamp];
  XFER: PROCEDURE [dest: GlobalFrameHandle];
  SetDefaultMemoryLimits: PROCEDURE [fp, lp: PageNumber];
  GetMemoryLimits: PROCEDURE RETURNS [fp, lp: PageNumber];
  SetDefaultNProcesses: PROCEDURE [n: CARDINAL];
  SetDefaultGFTLength: PROCEDURE [l: CARDINAL];
  GetIOPage: PROCEDURE RETURNS [CARDINAL];
  SetIOPage: PROCEDURE [CARDINAL];
  TurnOffStartTrap: PROCEDURE;
  SetResidentFramePages: PROCEDURE [CARDINAL];
  SetNonResidentFramePages: PROCEDURE [CARDINAL];
  
  BootmesaError: PROCEDURE [msg: STRING];
  BootmesaModuleError: PROCEDURE [msg, config, module: STRING];
  
  -- From BootLoader
  
  
  InitializeLoading: PROCEDURE [STRING];
  FinishLoading: PROCEDURE;
  lsseg, initlsseg, fakebcdseg: Seg;
  LoadModules: PROCEDURE [which: LoadClass];
  AssignCodeSegments: PROCEDURE;
  OpenLoadmap: PROCEDURE [root: STRING];
  CloseLoadmap: PROCEDURE;
  InitializeGFT: PROCEDURE [POINTER, CARDINAL];
  
  -- From Utilities
  
  MultipleNames: SIGNAL;
  ModuleName: PROCEDURE [frame: GlobalFrameHandle, name: STRING];
  ModuleGFI: PROCEDURE [STRING] RETURNS [ControlDefs.GFTIndex];
  FrameForGFI: PROCEDURE [ControlDefs.GFTIndex] RETURNS [GlobalFrameHandle];
  Frame: PROCEDURE [STRING] RETURNS [GlobalFrameHandle];
  SetConfig: PROCEDURE [name: STRING];
  ResetConfig: PROCEDURE;
  CodeSegment: PROCEDURE [f: GlobalFrameHandle] RETURNS [Seg];
  VirtualGlobalFrame: PROCEDURE [GlobalFrameHandle] RETURNS [GlobalFrameHandle];
  MakeResident: PROCEDURE [SegmentDefs.FileSegmentHandle];
  
  -- From Other Modules
  
  
  SetSource: PROCEDURE [STRING];
  
  -- From Parse
  
  
  InitParse: PROCEDURE [PROCEDURE RETURNS [CHARACTER], SIGNAL];
  ParseInput: PROCEDURE;
  FinishParse: PROCEDURE;
  LookUpModules: PROCEDURE;
  NubFrame, WartFrame, UserControl: PROCEDURE RETURNS [GlobalFrameHandle];
  EnumerateResidentModules: PROCEDURE [
    proc: PROCEDURE [GFTIndex] RETURNS [BOOLEAN]] RETURNS [GFTIndex];
  EnumerateSwappedInModules: PROCEDURE [
    proc: PROCEDURE [GFTIndex] RETURNS [BOOLEAN]] RETURNS [GFTIndex];
  EnumerateNoTrapModules: PROCEDURE [proc: PROCEDURE [GFTIndex] RETURNS [BOOLEAN]]
    RETURNS [GFTIndex];
  FinalizeParse: PROCEDURE;
  
  BootAbort: SIGNAL;
  
  LoadClass: TYPE = {resident, nonResident, initialization, notLoaded};
  
  ModuleInfo: TYPE = RECORD [
    mth: BcdOps.MTHandle,
    frame: GlobalFrameHandle,
    code: Seg,
    class: CodeClass,
    bound: BOOLEAN,
    whenLoaded: LoadClass];
  
  BootData: TYPE = RECORD [
    moduleTable: DESCRIPTOR FOR ARRAY OF ModuleInfo,
    bcd: POINTER TO BcdDefs.BCD,
    image: POINTER TO ImageFormat.ImageHeader,
    header: POINTER TO WartDefs.Header,
    imageFileRoot: STRING,
    imageFile: SegmentDefs.FileHandle,
    imageStream: StreamDefs.StreamHandle,
    vmFile: SegmentDefs.FileHandle,
    headerSeg: SegmentDefs.FileSegmentHandle,
    vmTableSeg, daSeg: Seg,
    buildingImage: BOOLEAN];
  
  dataObject: BootData;
  
  END..