BreakWorldArchitecture.mesa
Copyright Ó 1989, 1990 by Xerox Corporation. All rights reserved.
Peter B. Kessler, April 18, 1990 12:20 pm PDT
DIRECTORY
Rope USING [ROPE],
TargetArchitecture USING [Address, Displacement, nullDisplacement, Contents, Instruction];
BreakWorldArchitecture: CEDAR DEFINITIONS ~ {
Types.
BreakWorld: TYPE ~ REF BreakWorldRep ← nullBreakWorld;
nullBreakWorld: BreakWorld ~ NIL;
BreakWorldRep: TYPE;
WorldAccess: TYPE ~ REF WorldAccessRep ← nullWorldAccess;
nullWorldAccess: WorldAccess ~ NIL;
WorldAccessRep: TYPE ~ RECORD [
procs: WorldAccessProcs,
data: WorldAccessData
];
WorldAccessProcs: TYPE ~ REF WorldAccessProcsRep ← nullWorldAccessProcs;
nullWorldAccessProcs: WorldAccessProcs ~ NIL;
WorldAccessProcsRep: TYPE ~ RECORD [
peekContents: PeekContentsProc,
pokeContents: PokeContentsProc,
getProcAddress: GetProcAddressProc,
getPatchArea: GetPatchAreaProc,
monitoredCall: MonitoredCallProc
];
PeekContentsProc: TYPE ~
PROCEDURE [address: Address] RETURNS [TargetArchitecture.Contents];
returns contents of given address.
PokeContentsProc: TYPE ~
PROCEDURE [address: Address, contents: TargetArchitecture.Contents] RETURNS [];
sets given address to have given contents.
GetProcAddressProc: TYPE ~
PROCEDURE [breakWorld: BreakWorld, procName: Rope.ROPE] RETURNS [Address];
returns address of procedure with gien name.
GetPatchAreaProc: TYPE ~
PROCEDURE [address: Address] RETURNS [PatchAreaRep];
returns PatchAreaRep for a given address.
PatchAreaRep: TYPE ~ RECORD [
address: Address,
byteSize: ByteSize
] ← nullPatchAreaRep;
nullPatchAreaRep: PatchAreaRep ~ [
address: nullAddress,
byteSize: 0];
PatchArea: TYPE ~ REF PatchAreaRep ← nullPatchArea;
nullPatchArea: PatchArea ~ NIL;
MonitoredCallProc: TYPE ~
PROCEDURE [address: Address, proc: PROCEDURE [] RETURNS []] RETURNS [];
Acquires monitor lock at given address for the duration of call to the given proc.
Can raise WouldBlock if world is frozen and monitor lock is already held.
Only remote worlds are frozen.
WorldAccessData: TYPE ~ REF ANY ← nullWorldAccessData;
nullWorldAccessData: WorldAccessData ~ NIL;
BreakAccess: TYPE ~ REF BreakAccessRep ← nullBreakAccess;
nullBreakAccess: BreakAccess ~ NIL;
BreakAccessRep: TYPE;
Address: TYPE ~ REF AddressRep ← nullAddress;
nullAddress: Address ~ NIL;
AddressRep: TYPE ~ RECORD [
breakWorld: BreakWorld,
address: TargetArchitecture.Address
];
ByteSize: TYPE ~ CARD32;
Procedures.
Major items:
CreateBreakWorld: PROCEDURE [
peekContents: PeekContentsProc,
pokeContents: PokeContentsProc,
getProcAddress: GetProcAddressProc,
getPatchArea: GetPatchAreaProc,
monitoredCall: MonitoredCallProc,
worldAccessData: WorldAccessData]
RETURNS [BreakWorld];
calls BreakWorldFromWorldAccess[CreateWorldAccess[...]].
CreateWorldAccess: PROCEDURE [
peekContents: PeekContentsProc,
pokeContents: PokeContentsProc,
getProcAddress: GetProcAddressProc,
getPatchArea: GetPatchAreaProc,
monitoredCall: MonitoredCallProc,
worldAccessData: WorldAccessData]
RETURNS [WorldAccess];
BreakWorldFromWorldAccess: PROCEDURE [worldAccess: WorldAccess]
RETURNS
[BreakWorld];
BreakWorld accessors.
IsNullBreakWorld: PROCEDURE [breakWorld: BreakWorld] RETURNS [BOOLEAN];
WorldAccessFromBreakWorld: PROCEDURE [breakWorld: BreakWorld]
RETURNS
[WorldAccess];
BreakAccessFromBreakWorld: PROCEDURE [breakWorld: BreakWorld]
RETURNS
[BreakAccess];
Object style accessors:
PeekContents: PROCEDURE [
address: Address,
displacement: TargetArchitecture.Displacement ← TargetArchitecture.nullDisplacement]
RETURNS [TargetArchitecture.Contents];
PokeContents: PROCEDURE [
address: Address,
displacement: TargetArchitecture.Displacement ← TargetArchitecture.nullDisplacement,
contents: TargetArchitecture.Contents]
RETURNS [];
This had better be atomic!
GetProcAddress: PROCEDURE [breakWorld: BreakWorld, procName: Rope.ROPE]
RETURNS
[Address];
GetPatchArea: PROCEDURE [address: Address] RETURNS [PatchArea];
MonitoredCall: PROCEDURE [address: Address, proc: PROCEDURE [] RETURNS []]
RETURNS [];
Useful procedures for object-style on Addresses, Instructions, etc.:
NewAddress: PROCEDURE [breakWorld: BreakWorld, address: TargetArchitecture.Address]
RETURNS [Address];
TargetAddressFromBreakWorldAddress: PROCEDURE [address: Address]
RETURNS [TargetArchitecture.Address];
BreakWorldFromBreakWorldAddress: PROCEDURE [address: Address]
RETURNS
[BreakWorld];
IsNullAddress: PROCEDURE [address: Address] RETURNS [BOOLEAN];
AddressEqual: PROCEDURE [this: Address, that: Address]
RETURNS
[BOOLEAN];
AddressFromDisplacement: PROCEDURE [
address: Address,
displacement: TargetArchitecture.Displacement]
RETURNS [Address];
NextInstruction: PROCEDURE [pc: Address] RETURNS [Address];
PrevInstruction: PROCEDURE [pc: Address] RETURNS [Address];
PeekInstruction: PROCEDURE [
pc: Address,
displacement: TargetArchitecture.Displacement ← TargetArchitecture.nullDisplacement]
RETURNS
[TargetArchitecture.Instruction];
PokeInstruction: PROCEDURE [
pc: Address,
displacement: TargetArchitecture.Displacement ← TargetArchitecture.nullDisplacement,
instruction: TargetArchitecture.Instruction]
RETURNS
[];
This had better be atomic!
IsNullPatchArea: PROCEDURE [patchArea: PatchArea] RETURNS [BOOLEAN];
Errors.
ErrorCode: TYPE ~ ATOM ← nullErrorCode;
nullErrorCode: ErrorCode ~ NIL;
ErrorMessage: TYPE ~ Rope.ROPE ← nullErrorMessage;
nullErrorMessage: ErrorMessage ~ NIL;
Cant: ERROR [code: ErrorCode, message: ErrorMessage];
WouldBlock: ERROR [message: ErrorMessage];
Raised by MonitoredCall.
}.