RemoteFrameImpl.mesa
Stolen from FrameImpl.mesa by Levin on July 1, 1983 4:58 pm
last modified by Paul Rovner on July 7, 1983 9:04 am
DIRECTORY
PrincOps USING [
ControlLink, EPRange, GFT, GFTItem, GlobalFrameHandle, SD, sGFTLength, UnboundLink],
RemotePrincOpsUtils USING [],
RuntimeError USING [UnboundProcedure],
WorldVM USING [ShortAddress, World, Read, Long];
RemoteFrameImpl: PROGRAM
IMPORTS RuntimeError, WorldVM
EXPORTS RemotePrincOpsUtils =
BEGIN OPEN PrincOps, WorldVM;
Exported to RemotePrincOpsUtils (Global Frame stuff)
RemoteGlobalFrame:
PUBLIC SAFE PROC [world: World, link: --ControlLink--UNSPECIFIED]
RETURNS [gf: GlobalFrameHandle] = TRUSTED {
DO
OPEN l: LOOPHOLE[link, ControlLink];
SELECT TRUE FROM
l = UnboundLink => link ← SIGNAL RuntimeError.UnboundProcedure[link];
l.proc =>
IF l.gfi IN
[1..LOOPHOLE[Read[world, Long[world, LOOPHOLE[SD + sGFTLength, ShortAddress]]],
    NAT])
THEN {
gftItem: GFTItem
LOOPHOLE[Read[world, Long[world, LOOPHOLE[GFT + l.gfi, ShortAddress]]],
    GFTItem];
NOTE assume GFTItem is one word
gftItem.epbias ← 0;
RETURN[gftItem.framePtr]
}
ELSE RETURN[NIL];
l.indirect => link ← Read[world, Long[world, LOOPHOLE[l.link, ShortAddress]]];
link = 0 => RETURN[NIL];
ENDCASE => RETURN[LOOPHOLE[Read[world, Long[world, LOOPHOLE[l.frame, ShortAddress]]]]];
NOTE assume accesslink is addressed by fh
ENDLOOP;
};
RemoteGlobalFrameAndEntryPoint:
PUBLIC SAFE PROC [world: World, link: --ControlLink--UNSPECIFIED]
RETURNS [gf: GlobalFrameHandle, ep: CARDINAL] = TRUSTED {
DO
OPEN l: LOOPHOLE[link, ControlLink];
SELECT TRUE FROM
l = UnboundLink => link ← SIGNAL RuntimeError.UnboundProcedure[link];
l.proc =>
IF l.gfi IN
[1..LOOPHOLE[Read[world, Long[world, LOOPHOLE[SD + sGFTLength, ShortAddress]]],
    NAT])
THEN {
gftItem: GFTItem
LOOPHOLE[Read[world, Long[world, LOOPHOLE[GFT + l.gfi, ShortAddress]]],
    GFTItem];
NOTE assume GFTItem is one word
ep ← gftItem.epbias*EPRange+l.ep;
gftItem.epbias ← 0;
RETURN[gf: gftItem.framePtr, ep: ep]
}
ELSE ERROR;
l.indirect => link ← Read[world, Long[world, LOOPHOLE[l.link, ShortAddress]]];
ENDCASE => ERROR; -- not meaningful for type-0 control links
ENDLOOP;
};
END.