DIRECTORY BasicLoadState USING [ModuleIndex, NullModule], BasicLoadStateFormat USING [ BcdInfo, ConfigIndex, LoadState, LoadStateObject, ModuleInfo, nullConfig], BasicLoadStateFormatExtension USING [Extension], BcdDefs USING [BcdBase, MTHandle], BootStartList USING [ h, IndexToSpaceEntryPointer, IndexToSwapUnitEntryPointer, SpaceEntryPointer, SwapUnitEntryPointer], PrincOps USING [GFT, GFTIndex, GFTItem, GlobalFrameHandle], VM USING [AddressForPageNumber, Allocate, Free, Interval, PagesForWords]; BasicLoadStateImpl: PROGRAM IMPORTS BootStartList, VM EXPORTS BasicLoadState = BEGIN OPEN BasicLoadStateFormat; ConfigID: PUBLIC TYPE = ConfigIndex; ModuleIndex: TYPE = BasicLoadState.ModuleIndex; TypeCode: PUBLIC TYPE = CARDINAL; GFMap: TYPE = LONG POINTER TO ConfigTable; ConfigTable: TYPE = RECORD[SEQUENCE COMPUTED ConfigID OF ModuleMap]; ModuleMap: TYPE = LONG POINTER TO ModuleMapTable; ModuleMapTable: TYPE = RECORD [ SEQUENCE length: CARDINAL OF PrincOps.GlobalFrameHandle]; NullConfig: PUBLIC ConfigID _ BasicLoadStateFormat.nullConfig; loadState: LoadState _ NIL; extension: LONG POINTER TO BasicLoadStateFormatExtension.Extension _ NIL; gfMap: GFMap _ NIL; loadStateInterval, gfMapInterval: VM.Interval; BasicLoadStateGone: ERROR = CODE; BogusConfigID: ERROR = CODE; BogusModuleIndex: ERROR = CODE; Destroy: PUBLIC PROC = { IF loadState = NIL THEN RETURN; VM.Free[gfMapInterval]; VM.Free[loadStateInterval]; loadState _ NIL; }; ModuleToGlobalFrame: PUBLIC PROC [config: ConfigID, module: ModuleIndex] RETURNS [gfh: PrincOps.GlobalFrameHandle] = { moduleMap: ModuleMap; IF loadState = NIL THEN ERROR BasicLoadStateGone; IF ~(config IN [ConfigID.FIRST..loadState.nBcds)) THEN ERROR BogusConfigID; moduleMap _ gfMap[config]; IF module >= moduleMap.length THEN ERROR BogusModuleIndex; RETURN [moduleMap[module]] }; GlobalFrameToModule: PUBLIC PROC [gfh: PrincOps.GlobalFrameHandle] RETURNS [config: ConfigID, module: ModuleIndex] = { info: ModuleInfo; IF loadState = NIL THEN ERROR BasicLoadStateGone; info _ loadState.gft[gfh.gfi]; RETURN[config: info.config, module: info.module] }; GlobalFrameToType: PUBLIC PROC [gfh: PrincOps.GlobalFrameHandle] RETURNS [type: TypeCode] = { IF loadState = NIL THEN ERROR BasicLoadStateGone; RETURN[extension[gfh.gfi].type] }; SetType: PUBLIC PROC [gfh: PrincOps.GlobalFrameHandle, type: TypeCode] = { IF loadState = NIL THEN ERROR BasicLoadStateGone; extension[gfh.gfi].type _ type; }; ConfigInfo: PUBLIC PROC [config: ConfigID] RETURNS [ bcd: BcdDefs.BcdBase, exports, exportsTypes: BOOL] = { bi: BcdInfo; IF loadState = NIL THEN ERROR BasicLoadStateGone; IF ~(config IN [ConfigID.FIRST..loadState.nBcds)) THEN ERROR BogusConfigID; bi _ loadState.bcds[config]; exports _ bi.exports; exportsTypes _ bi.typeExported; bi.exports _ bi.typeExported _ FALSE; bcd _ bi.bcd; }; EnumerateConfigs: PUBLIC PROC [proc: PROC [ConfigID] RETURNS [BOOL]] RETURNS [config: ConfigID] = { IF loadState = NIL THEN ERROR BasicLoadStateGone; FOR config IN [0..loadState.nBcds) DO IF proc[config] THEN RETURN; ENDLOOP; RETURN[nullConfig] }; EnumerateModulesInConfig: PUBLIC PROC [ config: ConfigID, proc: PROC [ModuleIndex] RETURNS [BOOL]] RETURNS [module: ModuleIndex] = { moduleMap: ModuleMap; prev: PrincOps.GlobalFrameHandle _ NIL; IF loadState = NIL THEN ERROR BasicLoadStateGone; moduleMap _ gfMap[config]; FOR module IN [1..moduleMap.length) DO IF moduleMap[module] = prev THEN LOOP; IF proc[module] THEN RETURN; prev _ moduleMap[module]; ENDLOOP; RETURN[BasicLoadState.NullModule] }; EnumerateAllModules: PUBLIC PROC [ proc: PROC [ConfigID, ModuleIndex] RETURNS [BOOL]] RETURNS [config: ConfigID, module: ModuleIndex] = { IF loadState = NIL THEN ERROR BasicLoadStateGone; FOR config IN [0..loadState.nBcds) DO prev: PrincOps.GlobalFrameHandle _ NIL; moduleMap: ModuleMap = gfMap[config]; FOR module IN [1..moduleMap.length) DO IF moduleMap[module] = prev THEN LOOP; IF proc[config, module] THEN RETURN; prev _ moduleMap[module]; ENDLOOP; ENDLOOP; RETURN[NullConfig, BasicLoadState.NullModule] }; ConfigToBcd: PROC [config: ConfigID] RETURNS [BcdDefs.BcdBase] = { bi: BcdInfo _ loadState.bcds[config]; bi.exports _ bi.typeExported _ FALSE; RETURN [bi.bcd] }; FindMakeBootLoadState: PROC = { OPEN BootStartList; su: SwapUnitEntryPointer = IndexToSwapUnitEntryPointer[h.initLoadState]; parent: SpaceEntryPointer = IndexToSpaceEntryPointer[su.parent]; loadStateInterval _ [page: parent.vmPage + su.base, count: su.pages]; loadState _ VM.AddressForPageNumber[loadStateInterval.page]; extension _ LOOPHOLE[loadState+SIZE[LoadStateObject[loadState.length]]]; }; BuildGFTable: PROC = { GetFrame: PROC [g: PrincOps.GFTItem] RETURNS [PrincOps.GlobalFrameHandle] = { g.epbias _ 0; RETURN[g.framePtr] }; MapSizeForBcd: PROC [bcd: BcdDefs.BcdBase] RETURNS [CARDINAL] = { IF bcd.nModules > 1 THEN RETURN[bcd.firstdummy]; RETURN[1+LOOPHOLE[bcd+bcd.mtOffset, BcdDefs.MTHandle].ngfi] }; gfMapSize, configTableSize: NAT; moduleMap: ModuleMap; gfMapSize _ configTableSize _ SIZE[ConfigTable[loadState.nBcds]]; FOR config: ConfigID IN [0..loadState.nBcds) DO bcd: BcdDefs.BcdBase = ConfigToBcd[config]; gfMapSize _ gfMapSize + SIZE[ModuleMapTable[MapSizeForBcd[bcd]]]; ENDLOOP; gfMapInterval _ VM.Allocate[VM.PagesForWords[gfMapSize]]; gfMap _ VM.AddressForPageNumber[gfMapInterval.page]; moduleMap _ LOOPHOLE[gfMap + configTableSize]; FOR config: ConfigID IN [0..loadState.nBcds) DO bcd: BcdDefs.BcdBase = ConfigToBcd[config]; mapSize: CARDINAL = MapSizeForBcd[bcd]; gfMap[config] _ moduleMap; LOOPHOLE[moduleMap, LONG POINTER TO CARDINAL]^ _ mapSize; moduleMap[0] _ NIL; FOR gfi: PrincOps.GFTIndex IN PrincOps.GFTIndex DO IF loadState.gft[gfi].config = config THEN { IF loadState.gft[gfi].module >= mapSize THEN ERROR; moduleMap[loadState.gft[gfi].module] _ GetFrame[PrincOps.GFT[gfi]]; }; ENDLOOP; moduleMap _ moduleMap + SIZE[ModuleMapTable[mapSize]]; ENDLOOP; }; FindMakeBootLoadState[]; BuildGFTable[]; END. úBasicLoadStateImpl.mesa last edited by Levin on October 3, 1983 1:10 pm Types Global Variables Errors Exported Procedures Internal Procedures Compiler always sets bcd.firstdummy to PrincOps.MaxNGfi+1. The truth is in the module table entry. ÊɘJšœ™Jšœ/™/J˜šÏk ˜ Jšœœ˜/šœœ˜JšœJ˜J—Jšœœ ˜0Jšœœ˜"šœœ˜Jšœc˜c—Jšœ œœ(˜;JšœœA˜I—J˜šœ˜Jšœ˜Jšœ˜—J˜Jš˜J˜Jšœ˜J˜Jšœ™˜Jšœ œ˜$Jšœ œ˜/Jšœ œœ˜!J˜Jš œœœœœ ˜*Jš œ œœœœ œ ˜DJš œ œœœœ˜2šœœœ˜Jšœ œœ˜9—J˜—Jšœ™˜Jšœ œ,˜>J˜Jšœœ˜Jš œ œœœ+œ˜IJšœœ˜J˜Jšœ"œ ˜.J˜—J™™Jšœœœ˜!Jšœœœ˜Jšœœœ˜J˜—Jšœ™˜šÏnœ œ˜Jšœ œœœ˜Jšœ˜Jšœ˜Jšœ œ˜J˜—J˜šžœ œ(˜HJšœ&˜-J˜Jšœ œœœ˜1Jš œ œ œœœ˜KJšœ˜Jšœœœ˜:Jšœ˜J˜—J˜šžœ œ"˜BJšœ,˜3J˜Jšœ œœœ˜1J˜Jšœ*˜0J˜—J˜šžœ œ"˜@Jšœ˜Jšœ œœœ˜1Jšœ˜J˜—J˜šžœ œ6˜JJšœ œœœ˜1Jšœ˜J˜J˜—šž œ œœ˜4Jšœ-œ˜6J˜ Jšœ œœœ˜1Jš œ œ œœœ˜KJ˜Jšœ5˜5Jšœœ˜%J˜ J˜—J˜š žœ œœ œœ˜DJšœ˜Jšœ œœœ˜1šœœ˜%Jšœœœ˜Jšœ˜—Jšœ ˜J˜—J˜šžœœœ˜'Jšœœœœ˜:Jšœ˜!J˜Jšœ#œ˜'Jšœ œœœ˜1Jšœ˜šœœ˜&Jšœœœ˜&Jšœœœ˜Jšœ˜Jšœ˜—Jšœ˜!J˜J˜—šžœ œ˜"Jšœœœœ˜2Jšœ,˜3Jšœ œœœ˜1šœœ˜%Jšœ#œ˜'Jšœ%˜%šœœ˜&Jšœœœ˜&Jšœœœ˜$Jšœ˜Jšœ˜—Jšœ˜—Jšœ'˜-J˜——J˜Jšœ™˜šž œœœ˜BJ˜%Jšœœ˜%Jšœ ˜J˜—J˜šžœœ˜Jšœ˜JšœH˜HJšœ@˜@JšœE˜EJšœ œ.˜