<> <> DIRECTORY MiscAlpha USING [aASSOC, aGETF, aSETF], Mopcodes USING [zMISC]; PageMap: DEFINITIONS = BEGIN PageNumber: TYPE = INT; RealPageNumber: TYPE = CARDINAL; State: TYPE = MACHINE DEPENDENT RECORD [ processorDependent(0:0..12): ProcessorDependent _ NULL, flags(0:13..15): Flags]; InterimState: TYPE = MACHINE DEPENDENT RECORD [ logSingleError(0:0..0): BOOL, flags(0:1..3): Flags, realPage(0:4..15): [0..7777B]]; Flags: TYPE = MACHINE DEPENDENT RECORD [ readonly(0:0..0): BOOL, -- (0 for FALSE, 1 for TRUE.) dirty(0:1..1): BOOL, referenced(0:2..2): BOOL]; ProcessorDependent: TYPE = MACHINE DEPENDENT RECORD [ <> <> bits(0:0..12): CARDINAL [0..17777B]]; <> flagsClean, flagsNone: Flags = [ readonly: FALSE, dirty: FALSE, referenced: FALSE]; flagsDirty: Flags = [readonly: FALSE, dirty: TRUE, referenced: FALSE]; flagsDirtyReferenced: Flags = [readonly: FALSE, dirty: TRUE, referenced: TRUE]; flagsReadOnly, flagsReadonly: Flags = [ readonly: TRUE, dirty: FALSE, referenced: FALSE]; flagsReadOnlyReferenced, flagsReadonlyReferenced: Flags = [ readonly: TRUE, dirty: FALSE, referenced: TRUE]; flagsVacant: Flags = [readonly: TRUE, dirty: TRUE, referenced: FALSE]; flagsReadOnlyDirtyReferenced: Flags = [ readonly: TRUE, dirty: TRUE, referenced: TRUE]; <> maskNone: Flags = [ readonly: LOOPHOLE[0], dirty: LOOPHOLE[0], referenced: LOOPHOLE[0]]; maskReferenced, maskNotReadonlyNotDirty: Flags = [ readonly: LOOPHOLE[0], dirty: LOOPHOLE[0], referenced: LOOPHOLE[1]]; maskDirty, maskNotReadOnlyNotReferenced, maskNotReadonlyNotReferenced: Flags = [ readonly: LOOPHOLE[0], dirty: LOOPHOLE[1], referenced: LOOPHOLE[0]]; maskDirtyReferenced, maskNotReadOnly, maskNotReadonly: Flags = [ readonly: LOOPHOLE[0], dirty: LOOPHOLE[1], referenced: LOOPHOLE[1]]; maskReadOnly, maskNotDirtyNotReferenced: Flags = [ readonly: LOOPHOLE[1], dirty: LOOPHOLE[0], referenced: LOOPHOLE[0]]; maskReadOnlyReferenced, maskReadonlyReferenced, maskNotDirty: Flags = [ readonly: LOOPHOLE[1], dirty: LOOPHOLE[0], referenced: LOOPHOLE[1]]; maskReadOnlyDirty, maskReadonlyDirty, maskNotReferenced: Flags = [ readonly: LOOPHOLE[1], dirty: LOOPHOLE[1], referenced: LOOPHOLE[0]]; maskAll: Flags = [ readonly: LOOPHOLE[1], dirty: LOOPHOLE[1], referenced: LOOPHOLE[1]]; <> ExchangeState: PROC [virtual: PageNumber, newState: State] RETURNS [oldState: State, real: RealPageNumber] = INLINE { <> <> DoExchangeState: PROC [virtual: PageNumber, state: InterimState] RETURNS [oldState: InterimState] = MACHINE CODE {Mopcodes.zMISC, MiscAlpha.aSETF}; [logSingleError: , flags: oldState.flags, realPage: real] _ DoExchangeState[virtual, InterimState[FALSE, newState.flags, 0]].oldState; }; ExchangeFlags: PROC [virtual: PageNumber, newFlags: Flags] RETURNS [oldState: State, real: RealPageNumber] = <> <> INLINE {RETURN ExchangeState[virtual, StateFromFlags[newFlags]]}; GetState: PROC [virtual: PageNumber] RETURNS [state: State, real: RealPageNumber] = INLINE { <> DoGetMapState: PROC [virtual: PageNumber] RETURNS [state: InterimState] = MACHINE CODE {Mopcodes.zMISC, MiscAlpha.aGETF}; [logSingleError: , flags: state.flags, realPage: real] _ DoGetMapState[virtual].state; }; SetMapState: PROC [virtual: PageNumber, real: RealPageNumber, state: State] = INLINE { <> DoSetMapState: PROC [virtual: PageNumber, state: InterimState] = MACHINE CODE {Mopcodes.zMISC, MiscAlpha.aASSOC}; DoSetMapState[virtual, InterimState[FALSE, state.flags, real]]; }; SetMapFlags: PROC [virtual: PageNumber, real: RealPageNumber, flags: Flags] = <> INLINE {SetMapState[virtual, real, StateFromFlags[flags]]}; IsMapped: PROC [virtual: PageNumber] RETURNS [BOOL] = INLINE {RETURN[GetState[virtual].state.flags ~= flagsVacant]}; IsVacant: PROC [virtual: PageNumber] RETURNS [BOOL] = INLINE {RETURN[GetState[virtual].state.flags = flagsVacant]}; StateFromFlags: PROC [flags: Flags] RETURNS [State] = INLINE {RETURN[LOOPHOLE[flags]]}; END.