-- SMLoad.Mesa
-- last edit by Schmidt, May 13, 1983 3:17 pm
-- last edit by Satterthwaite, August 15, 1983 11:36 am
-- the new modeller loader interface
DIRECTORY
BcdDefs: TYPE USING [Link, NameRecord],
BcdOps: TYPE USING [BcdBase, EXPHandle, MTHandle],
File: TYPE USING [Capability],
IO: TYPE USING [Handle],
MiscAlpha: TYPE USING [alpha],
Mopcodes: TYPE USING [zMISC],
PilotLoaderOps: TYPE USING [FrameList],
PilotLoadStateOps: TYPE USING [ConfigIndex, Map],
PrincOps: TYPE USING [
ControlLink, ControlModule, GFTIndex, GlobalFrameHandle, MaxNGfi,
NullControl, NullLink],
Rope: TYPE USING [Text],
TimeStamp: TYPE USING [Null, Stamp];
SMLoad: DEFINITIONS ~ {
-- this is an Interface Record in the usual parlance
-- for procedures, this ControlLink is [procedure[gfi: gfi, ep: ep, tag: TRUE]
-- for exported variables this is the absolute address of the variable
-- for PROGRAM modules this is a GlobalFramePointer
IR: TYPE~REF InterfaceRecordRep;
InterfaceRecordRep: TYPE~RECORD[
name: ATOM←NIL, -- the interface (module) name (note that Tree.Name = ATOM)
stamp: TimeStamp.Stamp←TimeStamp.Null, -- func time stamp
resolved: BOOL←FALSE, -- all links have been filled in
body: SEQUENCE size: NAT OF RECORD[
link: PrincOps.ControlLink←PrincOps.NullLink] -- the actual link
];
LoadInfo: TYPE~REF LoadInfoRecord;
LoadInfoRecord: TYPE~RECORD[
bcdBase: BcdOps.BcdBase←NIL, -- the in core bcd
linksResolved: BOOL←FALSE, -- => all links for these frames are resolved
rtStarted: BOOL←FALSE, -- => AcquireTypesAndLiterals has been called on this bcd
cm: PrincOps.ControlModule←PrincOps.NullControl, -- the control module to start
gfiMap: GfiMap←NIL, -- [0 to bcdbase.firstdummy+bcdbase.nDummies)
imports: IRSeq←NIL, -- [0 to bcdbase.nImports)
exports: IRSeq←NIL, -- export[0] is the global frame
configGfi: PrincOps.GFTIndex←0, -- dummy gfi in resulting loaded config
map: PilotLoadStateOps.Map←NIL, -- map for this bcd, not fake config
frameList: PilotLoaderOps.FrameList←NIL, -- ptrs to frames
body: SEQUENCE size: NAT OF LoadRecord]; -- (> 1 only for configs)
LoadRecord: TYPE~RECORD[
frame: PrincOps.GlobalFrameHandle←NIL, -- the gfh for module
frameSize: CARDINAL←0, -- shadows the mth.framesize
nGfi: NAT←0]; -- shadows the mth.ngfi
-- For gfiMap[0 .. bcdbase.firstdummy) this is the real gfi for the module.
-- for gfiMap[bcdbase.firstdummy .. bcdbase.ndummies + bcdbase.firstdummy),
-- this is the index into the ImportTable for the dummy gfi's
GfiMap: TYPE~REF GfiMapSeq;
GfiMapSeq: TYPE~RECORD[
size: NAT←0,
body: SEQUENCE maxsize: NAT OF RECORD[
index: PrincOps.GFTIndex,
whichOne: [0..PrincOps.MaxNGfi)] -- this ranges between 0 and 3
];
-- The ith element of this is the interface record associated with the ith import (zero origin).
-- Import #3 has been matched up with InterfaceRecord import[3], etc.
IRSeq: TYPE~REF IRSeqRecord;
IRSeqRecord: TYPE~RECORD[
body: SEQUENCE size: NAT OF IR];
ReplaceResult: TYPE ~ {
ok, configNotReplaceable, frameTooBig, ngfiTooBig, cantCopyOldBcd,
checkForMRFailed, compilerSaysNo};
InvalidFile: ERROR[File.Capability]; -- raised by LoadGlobalFrames and LoadIncremental
LoadGlobalFrames: PROC[
cap: File.Capability, config: PilotLoadStateOps.ConfigIndex,
oldConfigGfi: PrincOps.GFTIndex, out: IO.Handle]
RETURNS[loadInfo: LoadInfo, newConfigGfi: PrincOps.GFTIndex];
-- will read in bcd header and map code segments
LoadIncremental: PROC[bcdcap: File.Capability, loadInfo: LoadInfo, out: IO.Handle]
RETURNS[replaceResult: ReplaceResult];
BuildInterface: PROC[loadInfo: LoadInfo, eth: BcdOps.EXPHandle] RETURNS[ir: IR];
BuildFramePtrInterface: PROC[bcdBase: BcdOps.BcdBase, frame: PrincOps.GlobalFrameHandle]
RETURNS[ir: IR];
NSToRope: PROC[bcdBase: BcdOps.BcdBase, name: BcdDefs.NameRecord] RETURNS[Rope.Text];
ConvertLink: PROC [bl: BcdDefs.Link] RETURNS [cl: PrincOps.ControlLink];
aLongBlkZ: MiscAlpha.alpha = 102b;
Zero: PROC[lp: LONG POINTER, nwords: CARDINAL] RETURNS[LONG POINTER] ~
MACHINE CODE {Mopcodes.zMISC, aLongBlkZ};
-- frame link space operations
OpenLinkSpace: PROC [
frame: PrincOps.GlobalFrameHandle, mth: BcdOps.MTHandle, bcd: BcdOps.BcdBase←NIL]
RETURNS[LONG POINTER];
ReadLink: PROC[offset: CARDINAL] RETURNS[link: PrincOps.ControlLink];
WriteLink: PROC[offset: CARDINAL, link: PrincOps.ControlLink];
CloseLinkSpace: PROC[frame: PrincOps.GlobalFrameHandle];
-- allocation/deallocation
AllocateLoadInfo: PROC[bcdbase: BcdOps.BcdBase] RETURNS[LoadInfo];
FreeLoadInfo: PROC[loadInfo: LoadInfo] RETURNS[LoadInfo]; -- always gives NIL
AllocateIR: PROC[name: ATOM, size: NAT] RETURNS[IR];
FreeIR: PROC[ir: IR] RETURNS[IR]; -- always gives NIL
}.