-- Cedar Remote Debugging: Internal WorldVM Interface

-- WVMPrivate.mesa

-- Andrew Birrell July 26, 1983 3:55 pm

DIRECTORY
Booting   USING [Bootee, Switches],
Device   USING[ Type ],
Environment USING [wordsPerPage],
PilotDisk  USING [Label],
Rope    USING[ ROPE ],
WorldVM  USING [Address, World];

WVMPrivate: DEFINITIONS =

BEGIN

pageSize: CARDINAL = Environment.wordsPerPage;

PageNumber: TYPE = INT -- [0..LAST[WorldVM.Address]/pageSize) --;

PageAddress: PROC[mempage: PageNumber] RETURNS[ WorldVM.Address ] = INLINE
{ RETURN[ mempage * LONG[pageSize] ] };

DiskAddress: TYPE = RECORD[
deviceType: Device.Type,
deviceOrdinal: CARDINAL,
diskPage: LONG CARDINAL, -- device-relative page number of start of run
offset: CARDINAL, -- page number from start of run, for label checksum calculation
labelCheck: CARDINAL -- label checksum of start of run (Pilot relic: should use entire label)
];


-- Map log machinery (Includes run-table machinery in Cedar debuggees) --

MapLog: TYPE = REF MapLogObject;

MapLogObject: TYPE;

CreateMapLog: PROC[world: WorldVM.World] RETURNS[ MapLog ];
-- May read only swapped-in (or resident) client pages.

ReadMapLog: PROC[world: WorldVM.World, log: MapLog]
RETURNS[patchTable, loadState: WorldVM.Address];

GetMapLogEntry: PROC[log: MapLog, mempage: PageNumber]
RETURNS[ DiskAddress ];

LocalPatchTable: PROC RETURNS[patchTable: WorldVM.Address];
-- Implemented in WVMMapLog, because it comes from the maplog descriptor.

PatchTable: PROC[world: WorldVM.World] RETURNS[ WorldVM.Address ];
-- returns address of world's patch table.


-- Page cache --

PageHandle: TYPE = REF PageInfo;

PageInfo: TYPE;

PageData: TYPE = ARRAY [0..pageSize) OF CARDINAL;

GetPage: PROC[world: WorldVM.World, mempage: PageNumber, coreOnly: BOOLEAN]
RETURNS[ data: REF PageData, handle: PageHandle ];
-- If "coreOnly" and page is not swapped in, returns [NIL,NIL].

ReleasePage: PROC[handle: PageHandle];

WriteAndReleasePage: PROC[handle: PageHandle];



-- Remote page transfers --

MapEntry: TYPE = MACHINE DEPENDENT RECORD [
flags: RECORD[logSE, W, D, R: BOOLEAN],
page: [0..7777B]];

Machine: TYPE[3];

LocateRemote: PROC[Rope.ROPE] RETURNS[ Machine ];

GoRemote: PROC[host: Machine];

ReadRemoteCore: PROC[host: Machine,
data: REF PageData,
mempage: PageNumber]
RETURNS[map: MapEntry, ok: BOOLEAN];

WriteRemoteCore: PROC[host: Machine,
data: REF PageData,
mempage: PageNumber,
map: MapEntry];

ReadRemoteDisk: PROC[host: Machine,
data: REF PageData,
addr: DiskAddress,
label: LONG POINTER TO PilotDisk.Label];

WriteRemoteDisk: PROC[host: Machine,
data: REF PageData,
addr: DiskAddress,
label: LONG POINTER TO PilotDisk.Label];



-- World-swap page transfers --

LocateOther: PROC; -- outload, boot physical volume, return after inload --

GoOther: PROC; -- outload, return after inload --

ReallySwapAndBoot: SAFE PROC[boot: Booting.Bootee, switches: Booting.Switches];

ReadOtherCore: PROC[data: REF PageData, mempage: PageNumber]
RETURNS[map: MapEntry, ok: BOOLEAN];

WriteOtherCore: PROC[data: REF PageData, mempage: PageNumber, map: MapEntry];

ChannelDirection: TYPE = { read, write };

MoveLocalDiskPage: PROC[
data: REF PageData,
direction: ChannelDirection,
addr: DiskAddress];

END.