PageMap.mesa
last edited by Levin on March 11, 1983 5:57 pm
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 [
Processor dependent page status. This data is read-only
to the processor via the procedures in this interface.
bits(0:0..12): CARDINAL [0..17777B]];
Flags or bit masks for setting the fields of a Flags (in binary order):
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];
Bit masks for isolation of the fields of a Flags (in binary order):
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]];
Machine instructions from the Principles of Operations:
ExchangeState: PROC [virtual: PageNumber, newState: State]
RETURNS [oldState: State, real: RealPageNumber] = INLINE {
Gets the state and real page of a virtual page;
If the page is mapped, also sets the flags to newState.
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] =
Gets the state and real page of a virtual page;
If the page is mapped, also sets the flags to newFlags.
INLINE {RETURN ExchangeState[virtual, StateFromFlags[newFlags]]};
GetState: PROC [virtual: PageNumber] RETURNS [state: State, real: RealPageNumber] = INLINE {
Gets the state and real page of a virtual page.
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 {
Sets the real page and state of a virtual page.
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] =
Sets the real page and flags of a virtual page.
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.