-- LoaderOps.mesa
-- Last Modified by Sandman,  June 30, 1980  4:57 PM 
-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  BcdDefs USING [EXPIndex, MTIndex],
  BcdOps USING [BcdBase, MTHandle],
  ControlDefs USING [
    ControlLink, ControlModule, GFTIndex, GlobalFrameHandle, MaxNGfi],
  LoadStateOps USING [Map];

LoaderOps: DEFINITIONS =
  BEGIN OPEN ControlDefs;

  FinalizeUtilities: PROCEDURE;
  InitializeUtilities: PROCEDURE [bcd: BcdOps.BcdBase];

  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: PROCEDURE [bcd: BcdOps.BcdBase] RETURNS [binding: Binding];
  ReleaseBinding: PROCEDURE [bcd: BcdOps.BcdBase, binding: Binding]
    RETURNS [null: Binding];

  FindFiles: PROCEDURE [bcd: BcdOps.BcdBase];
  FileNotFound: SIGNAL [name: STRING];
  FindCode: PROCEDURE [bcd: BcdOps.BcdBase, map: LoadStateOps.Map];
  BadCode: SIGNAL [name: STRING];
  FindFrameIndex: PROCEDURE [mth: BcdOps.MTHandle, framelinks: BOOLEAN]
    RETURNS [fsi: CARDINAL];
  GetGfi: PROCEDURE [frame: GlobalFrameHandle, ngfi: [1..MaxNGfi]]
    RETURNS [gfi: GFTIndex];
  AllocateFrames: PROCEDURE [bcd: BcdOps.BcdBase, alloc, framelinks: BOOLEAN]
    RETURNS [POINTER];
  ReleaseFrames: PROCEDURE [
    bcd: BcdOps.BcdBase, frames: POINTER, map: LoadStateOps.Map];

  InitializeMap: PROCEDURE [bcd: BcdOps.BcdBase] RETURNS [map: LoadStateOps.Map];
  DestroyMap: PROCEDURE [map: LoadStateOps.Map];

  OpenLinkSpace: PROCEDURE [frame: GlobalFrameHandle, mth: BcdOps.MTHandle];
  WriteLink: PROCEDURE [offset: CARDINAL, link: ControlLink];
  ReadLink: PROCEDURE [offset: CARDINAL] RETURNS [link: ControlLink];
  CloseLinkSpace: PROCEDURE [frame: GlobalFrameHandle];

  InvalidFile: ERROR [name: STRING];
  VersionMismatch: SIGNAL [name: STRING];

  Load: PROCEDURE [name: STRING] RETURNS [bcd: BcdOps.BcdBase];
  New: PROCEDURE [bcd: BcdOps.BcdBase, framelinks, alloc: BOOLEAN]
    RETURNS [frame: ControlDefs.ControlModule];

  END....