-- PageMap.mesa  (last edited by Knutsen on January 21, 1980  8:57 AM)
-- Inline access to the Principles of Operation page map.
-- Use a higher level interface unless you cannot call a procedure AND you will not interfere with Pilot's use of this interface!

DIRECTORY
  Environment USING [PageNumber],
  MiscAlpha USING [aASSOC, aGETF, aSETF],
  Mopcodes USING [zMISC];

PageMap: DEFINITIONS =
  BEGIN

  Flags: TYPE = MACHINE DEPENDENT RECORD [
    writeProtected, dirty, referenced: BOOLEAN];

  maxRealPages: CARDINAL = 4096;  -- really determined by size of realPage field of Value

  RealPageNumber: TYPE = [0..maxRealPages);

  Value: TYPE = MACHINE DEPENDENT RECORD [
    logSingleError: BOOLEAN, flags: Flags, realPage: RealPageNumber];

  flagsClean: Flags = [writeProtected: FALSE, dirty: FALSE, referenced: FALSE];
  flagsDirty: Flags = [writeProtected: FALSE, dirty: TRUE, referenced: FALSE];
  flagsVacant: Flags = [writeProtected: TRUE, dirty: TRUE, referenced: FALSE];
  flagsWriteProtected: Flags = [
    writeProtected: TRUE, dirty: FALSE, referenced: FALSE];

  -- Bit masks for isolation of fields of a Flags:
  flagsAll: Flags = [
    writeProtected: LOOPHOLE[1], dirty: LOOPHOLE[1], referenced: LOOPHOLE[1]];
  flagsNone: Flags = [
    writeProtected: LOOPHOLE[0], dirty: LOOPHOLE[0], referenced: LOOPHOLE[0]];
  flagsNotReferenced: Flags = [
    writeProtected: LOOPHOLE[1], dirty: LOOPHOLE[1], referenced: LOOPHOLE[0]];
  flagsReferenced: Flags = [
    writeProtected: LOOPHOLE[0], dirty: LOOPHOLE[0], referenced: LOOPHOLE[1]];

  valueAny: Value = valueVacant;
  valueClean: Value = [logSingleError: FALSE, flags: flagsClean, realPage: 0];
  valueVacant: Value = [logSingleError: FALSE, flags: flagsVacant, realPage: 0];
  valueWriteProtected: Value = [
    logSingleError: FALSE, flags: flagsWriteProtected, realPage: 0];

  -- Bit masks for isolation of fields of a Value:
  maskWriteProtectedDirty: Value =
    [logSingleError: LOOPHOLE[0], flags: [
      writeProtected: LOOPHOLE[1], dirty: LOOPHOLE[1], referenced: LOOPHOLE[0]],
      realPage: 0];

  maskNotDirtyNotReferenced: Value =
    [logSingleError: LOOPHOLE[1], flags: [
      writeProtected: LOOPHOLE[1], dirty: LOOPHOLE[0], referenced: LOOPHOLE[0]],
      realPage: LOOPHOLE[7777B]];

  maskDirtyReferenced: Value =
    [logSingleError: LOOPHOLE[0], flags: [
      writeProtected: LOOPHOLE[0], dirty: LOOPHOLE[1], referenced: LOOPHOLE[1]],
      realPage: 0];

  -- Machine instructions from the Principles of Operations:
  Assoc: PRIVATE PROCEDURE [page: Environment.PageNumber, value: Value] = MACHINE
    CODE BEGIN Mopcodes.zMISC, MiscAlpha.aASSOC END;

  GetF: PRIVATE PROCEDURE [page: Environment.PageNumber]
    RETURNS [valueOld: Value] = MACHINE CODE
    BEGIN Mopcodes.zMISC, MiscAlpha.aGETF END;

  SetF: PRIVATE PROCEDURE [page: Environment.PageNumber, flagsNew: Value]
    RETURNS [valueOld: Value] = MACHINE CODE
    BEGIN Mopcodes.zMISC, MiscAlpha.aSETF END;

  END.
LOG
Time: December 11, 1978  2:14 PM	By: McJones	Action: Created file
Time: January 21, 1980  8:57 AM	By: Knutsen	Action: Added mask values.
Time: July 21, 1980  2:46 PM	By: Knutsen	Action: Added GetFlags.