DIRECTORY BasicLoadStateFormat USING [BcdInfo, ConfigIndex, Extension, LoadStateObject, ModuleInfo, nullConfig, nullModule, nullType, versionID], BcdDefs USING [BcdBase, MTIndex, MTNull], MB USING [BHandle, Error, Handle], MBLoaderOps USING [Binding, BindingRecord, BindLink, EnumerationDirection], MBVM USING [AllocData, DataSeg, HyperSpace, LongCopyWrite, LongPointerFromSeg, Write], PrincOps USING [GFT, GFTIndex, GlobalFrame, GlobalFrameHandle], PrincOpsUtils USING [PagesForWords]; MBLoadState: CEDAR PROGRAM IMPORTS MB, MBVM, PrincOpsUtils EXPORTS MBLoaderOps = BEGIN OPEN MB; data: MB.Handle _ NIL; loadstate: REF BasicLoadStateFormat.LoadStateObject _ NIL; extension: REF BasicLoadStateFormat.Extension _ NIL; lsWords, extensionWords: CARDINAL; nextGFI: CARDINAL _ 1; -- gfi 0 is never used InitLoadState: PUBLIC PROC [h: MB.Handle] = {data _ h}; FinishLoadState: PUBLIC PROC = { loadstate _ NIL; extension _ NIL; data _ NIL; }; InputLoadState: PUBLIC PROC RETURNS [nbcds: BasicLoadStateFormat.ConfigIndex] = TRUSTED { IF loadstate = NIL THEN { IF ~data.germ THEN { lsWords _ SIZE[BasicLoadStateFormat.LoadStateObject[BasicLoadStateFormat.ConfigIndex.LAST]]; extensionWords _ SIZE[BasicLoadStateFormat.Extension]; data.lsseg _ MBVM.AllocData[ base: MBVM.HyperSpace, pages: PrincOpsUtils.PagesForWords[lsWords+extensionWords], dir: up ]; data.lsseg.info.readOnly _ FALSE; data.lsseg.bootLoaded _ TRUE; }; loadstate _ NEW[BasicLoadStateFormat.LoadStateObject[BasicLoadStateFormat.ConfigIndex.LAST]]; loadstate.versionident _ BasicLoadStateFormat.versionID; FOR gfi: PrincOps.GFTIndex IN [0..data.gftLength) DO loadstate.gft[gfi] _ BasicLoadStateFormat.nullModule; ENDLOOP; FOR i: BasicLoadStateFormat.ConfigIndex IN [0..BasicLoadStateFormat.ConfigIndex.LAST) DO loadstate.bcds[i] _ [ptr[NIL]]; ENDLOOP; loadstate.nBcds _ 0; extension _ NEW[BasicLoadStateFormat.Extension]; FOR gfi: PrincOps.GFTIndex IN [0..data.gftLength) DO extension[gfi] _ [mti: BcdDefs.MTNull, type: BasicLoadStateFormat.nullType]; ENDLOOP; nextGFI _ 1; }; RETURN[loadstate.nBcds] }; UpdateLoadState: PUBLIC PROC [ config: BasicLoadStateFormat.ConfigIndex, handle: MB.BHandle] = TRUSTED { bcd: BcdDefs.BcdBase = handle.bcd; IF config = BasicLoadStateFormat.nullConfig THEN ERROR; loadstate.bcds[config].bcd _ IF data.germ THEN NIL ELSE MBVM.LongPointerFromSeg[handle.bcdSeg]; loadstate.bcds[config].typeExported _ bcd.typeExported; loadstate.bcds[config].exports _ (bcd.nExports ~= 0); IF config >= loadstate.nBcds THEN loadstate.nBcds _ loadstate.nBcds + 1; }; WriteLoadState: PUBLIC PROC = TRUSTED { p: LONG POINTER; IF data.germ THEN RETURN; p _ MBVM.LongPointerFromSeg[data.lsseg]; MBVM.LongCopyWrite[ from: LOOPHOLE[loadstate], to: p, nwords: lsWords ]; MBVM.LongCopyWrite[ from: LOOPHOLE[extension], to: p + lsWords, nwords: extensionWords ]; }; EnterModule: PUBLIC PROC [ rgfi: PrincOps.GFTIndex, module: BasicLoadStateFormat.ModuleInfo, mti: BcdDefs.MTIndex _ BcdDefs.MTNull] = { loadstate.gft[rgfi] _ module; IF mti ~= BcdDefs.MTNull THEN extension[rgfi].mti _ mti; }; GetModule: PUBLIC PROC [rgfi: PrincOps.GFTIndex] RETURNS [module: BasicLoadStateFormat.ModuleInfo] = { RETURN[loadstate.gft[rgfi]]}; AcquireBcd: PUBLIC PROC [config: BasicLoadStateFormat.ConfigIndex] RETURNS [handle: MB.BHandle] = { RETURN[data.inputBCDs.bcds[config]]}; InitBinding: PUBLIC PROC [bcd: BcdDefs.BcdBase] RETURNS [binding: MBLoaderOps.Binding] = TRUSTED { binding _ NEW[MBLoaderOps.BindingRecord[bcd.nDummies] _ [ bias: bcd.firstdummy, b: NULL --ALL[MBLoaderOps.BindLink[whichgfi: 0, body: notbound[]]] ]]; FOR i: CARDINAL IN [0..binding.n) DO binding.b[i] _ MBLoaderOps.BindLink[whichgfi: 0, body: notbound[]]; ENDLOOP; }; BcdUnresolved: PUBLIC PROC [ bcd: BasicLoadStateFormat.ConfigIndex] RETURNS [BOOL] = { FOR i: PrincOps.GFTIndex IN [0..data.gftLength) DO IF bcd = loadstate.gft[i].config AND ~loadstate.gft[i].resolved THEN RETURN[TRUE]; ENDLOOP; RETURN[FALSE] }; BcdExports: PUBLIC PROC [bcd: BasicLoadStateFormat.ConfigIndex] RETURNS [BOOL] = { RETURN[loadstate.bcds[bcd].exports]}; BcdExportsTypes: PUBLIC PROC [bcd: BasicLoadStateFormat.ConfigIndex] RETURNS [BOOL] = { RETURN[loadstate.bcds[bcd].typeExported]}; GetNextGFI: PUBLIC PROC [reserve: CARDINAL] RETURNS [next: PrincOps.GFTIndex] = { IF (next _ nextGFI) >= data.gftLength THEN MB.Error["GFT overflow"]; nextGFI _ nextGFI + reserve; }; SetGFTEntry: PUBLIC PROC [ frame: PrincOps.GlobalFrameHandle, gfi: PrincOps.GFTIndex, ngfi: CARDINAL] = TRUSTED { IF gfi+ngfi >= data.gftLength THEN MB.Error["GFT Full"]; FOR i: CARDINAL IN [gfi..gfi+ngfi) DO bias: CARDINAL = (i-gfi); MBVM.Write[@PrincOps.GFT[i].framePtr, (frame + bias)]; ENDLOOP; }; EnumerateModules: PUBLIC PROC [ proc: PROC [rgfi: PrincOps.GFTIndex, module: BasicLoadStateFormat.ModuleInfo] RETURNS [BOOL]] RETURNS [i: PrincOps.GFTIndex] = { FOR i IN [0..nextGFI) DO IF loadstate.gft[i].config ~= BasicLoadStateFormat.nullConfig AND proc[i, loadstate.gft[i]] THEN EXIT; ENDLOOP; }; EnumerateBcds: PUBLIC PROC [ dir: MBLoaderOps.EnumerationDirection, proc: PROC [BasicLoadStateFormat.ConfigIndex] RETURNS [BOOL]] RETURNS [config: BasicLoadStateFormat.ConfigIndex] = { SELECT dir FROM recentfirst => FOR config DECREASING IN [0..loadstate.nBcds) DO IF proc[config] THEN RETURN; ENDLOOP; recentlast => FOR config IN [0..loadstate.nBcds) DO IF proc[config] THEN RETURN; ENDLOOP; ENDCASE; RETURN[BasicLoadStateFormat.nullConfig] }; END. zMBLoadState.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Sandman on March 13, 1981 4:01 PM Lewis on 21-Sep-81 17:08:04 Levin on January 12, 1984 4:20 pm Russ Atkinson (RRA) March 8, 1985 5:23:24 pm PST allocate temporary copy of loadstate (written into MBVM loadstate by WriteLoadState) GFT management bottom two bits of GFT entries bias evi's Κ`˜codešœ™Kšœ Οmœ1™