-- PilotLoaderOps.mesa   Last Modified by 
-- Sandman,  August 4, 1980  8:13 AM 
-- Karlton,  Feb 27, 1980 11:36 AM 
-- Forrest,  May 17, 1980  6:48 PM 
-- Paul Rovner, May 6, 1982 10:56 am 

DIRECTORY
  BcdDefs USING [EXPIndex, MTIndex, NameRecord, Link],
  BcdOps USING [BcdBase, MTHandle, NameString],
  PrincOps USING [ControlLink, ControlModule, GFTIndex, GlobalFrameHandle,
                      MaxNGfi],
  PilotLoadStateOps USING [Map];

PilotLoaderOps: DEFINITIONS
= BEGIN OPEN BcdDefs, BcdOps, PrincOps;

  BindLink: TYPE = RECORD [
    whichgfi: [0..MaxNGfi),
    body: SELECT type: * FROM
      interface => [eti: BcdDefs.EXPIndex],
      module => [mti: BcdDefs.MTIndex],
      notbound => NULL,
      ENDCASE];

  Binding: TYPE = DESCRIPTOR FOR ARRAY OF BindLink;
    -- BASE[Binding] is biased by bcd.firstdummy


  InitBinding: PROC[bcd: BcdOps.BcdBase] RETURNS [binding: Binding];
  ReleaseBinding: PROC[bcd: BcdOps.BcdBase, binding: Binding]
    RETURNS [null: Binding];
  
  PilotLoaderSupport: PROGRAM;

  FindCode: PROC[bcd: BcdOps.BcdBase, map: PilotLoadStateOps.Map];

  FrameList: TYPE = POINTER TO FrameItem;
  FrameItem: TYPE = RECORD [frame: POINTER, next: FrameList];
  AllocateFrames: PROC[size: CARDINAL, single, resident: BOOLEAN]
    RETURNS [FrameList];
  ReleaseFrames: PROC[
    bcd: BcdOps.BcdBase, frames: FrameList, map: PilotLoadStateOps.Map];

  InitializeMap: PROC[bcd: BcdOps.BcdBase]
    RETURNS [map: PilotLoadStateOps.Map];
  DestroyMap: PROC[map: PilotLoadStateOps.Map];

  OpenLinkSpace: PROC[frame: GlobalFrameHandle, mth: MTHandle, bcd: BcdBase ← NIL];
  WriteLink: PROC[offset: CARDINAL, link: ControlLink];
  ReadLink: PROC[offset: CARDINAL] RETURNS [link: ControlLink];
  CloseLinkSpace: PROC[frame: GlobalFrameHandle];

  GetSpace: PROC[nwords: CARDINAL] RETURNS [p: POINTER];
  FreeSpace: PROC[p: POINTER];
  AppendName: PROC[s: STRING, ssb: NameString, name: NameRecord];
  
  New: PROC[bcd: BcdOps.BcdBase, framelinks: BOOLEAN]
    RETURNS [cm: PrincOps.ControlModule, unboundImports: BOOLEAN];
  
  LinkSegmentLength: PROC[mth: MTHandle, bcd: BcdBase] RETURNS[CARDINAL];
  IthLink: PROC[mth: BcdOps.MTHandle, i: CARDINAL, bcd: BcdBase]
        RETURNS[Link];

END.