RemoteFrameImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Stolen from FrameImpl.mesa by Levin on July 1, 1983 4:58 pm
Rovner on July 7, 1983 9:04 am
Russ Atkinson (RRA) February 11, 1985 7:09:32 pm PST
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: WORD] RETURNS [gf: GlobalFrameHandle] = TRUSTED {
l: ControlLink ← LOOPHOLE[link];
DO
SELECT TRUE FROM
l = UnboundLink => l ← SIGNAL RuntimeError.UnboundProcedure[l];
l.proc =>
IF l.gfi IN [1..LOOPHOLE[Read[world, Long[world, LOOPHOLE[SD + sGFTLength, ShortAddress]]], NAT])
THEN {
NOTE assume GFTItem is one word
gftItem: GFTItem ← LOOPHOLE[Read[world, Long[world, LOOPHOLE[GFT + l.gfi, ShortAddress]]], GFTItem];
gftItem.epbias ← 0;
RETURN[gftItem.framePtr];
}
ELSE RETURN[NIL];
l.indirect => l ← LOOPHOLE[Read[world, Long[world, LOOPHOLE[l.link, ShortAddress]]]];
link = 0 => RETURN[NIL];
ENDCASE =>
NOTE assume accesslink is addressed by fh
RETURN[LOOPHOLE[Read[world, Long[world, LOOPHOLE[l.frame, ShortAddress]]]]];
ENDLOOP;
};
RemoteGlobalFrameAndEntryPoint: PUBLIC SAFE PROC [world: World, link: WORD] RETURNS [gf: GlobalFrameHandle, ep: CARDINAL] = TRUSTED {
l: ControlLink ← LOOPHOLE[link, ControlLink];
DO
SELECT TRUE FROM
l = UnboundLink => l ← SIGNAL RuntimeError.UnboundProcedure[l];
l.proc =>
IF l.gfi IN [1..LOOPHOLE[Read[world, Long[world, LOOPHOLE[SD + sGFTLength, ShortAddress]]], NAT]) THEN {
NOTE assume GFTItem is one word
gftItem: GFTItem ← LOOPHOLE[Read[world, Long[world, LOOPHOLE[GFT + l.gfi, ShortAddress]]], GFTItem];
ep ← gftItem.epbias*EPRange+l.ep;
gftItem.epbias ← 0;
RETURN[gf: gftItem.framePtr, ep: ep]
}
ELSE ERROR;
l.indirect => l ← LOOPHOLE[Read[world, Long[world, LOOPHOLE[l.link, ShortAddress]]]];
ENDCASE => ERROR;
not meaningful for type-0 control links
ENDLOOP;
};
END.