-- Cedar Remote Debugging: Internal WorldVM Interface

-- WVMPrivate.mesa

-- Andrew Birrell February 14, 1983 4:41 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 = LONG CARDINAL -- [0..LAST[WorldVM.Address]/pageSize) --;

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

DiskAddress: TYPE = RECORD[
driveTag: CARDINAL,
diskPage: LONG CARDINAL,
offset: CARDINAL,
labelCheck: CARDINAL];


-- Map log machinery --

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,
device: Device.Type,
addr: DiskAddress,
label: LONG POINTER TO PilotDisk.Label];

WriteRemoteDisk: PROC[host: Machine,
data: REF PageData,
device: Device.Type,
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.