RapunzelTestServer.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Demers, September 18, 1986 6:09:28 pm PDT
Willie-Sue, October 9, 1986 5:28:28 pm PDT
RapunzelTestServer:
CEDAR
PROGRAM
EXPORTS RapunzelP2200V1
~ {
OPEN Rapunzel: RapunzelP2200V1;
memSize: CARD ~ 1024;
Mem: TYPE ~ ARRAY [0..memSize) OF CARDINAL;
mem: REF Mem ← NIL;
Init: PROC ~ { IF mem = NIL THEN mem ← NEW[Mem ← ALL[0]] };
Fault: PUBLIC ERROR [code: Rapunzel.FaultCode, address: Rapunzel.Address] ~ CODE;
DoCmds:
PUBLIC PROC [h: CrRPC.Handle, cmdSeq: Rapunzel.SeqCmd]
RETURNS [resultSeq: Rapunzel.SeqResult] ~ {
Init[];
resultSeq ← NEW[Rapunzel.SeqResultObject[cmdSeq.length]];
FOR i:
CARDINAL
IN [0..cmdSeq.length)
DO
this: Rapunzel.Cmd = cmdSeq[i];
WITH this: this
SELECT
FROM
peekShort => {
address: Rapunzel.Address = this.peekShort.address;
IF address >= memSize THEN ERROR Fault[nonexistent, address];
TRUSTED {
res: Rapunzel.PeekShortResult ← [mem[address]];
resultSeq[i] ← [peekShort[res]];
};
};
pokeShort => {
address: Rapunzel.Address = this.pokeShort.address;
res: pokeShort Rapunzel.Result = NULL;
IF address >= memSize THEN ERROR Fault[nonexistent, address];
mem[address] ← this.pokeShort.value;
TRUSTED { resultSeq[i] ← res };
};
ENDCASE => ERROR Fault[nonexistent, 0];
ENDLOOP;
};
PeekShort:
PUBLIC PROC [h: CrRPC.Handle, address: Rapunzel.Address]
RETURNS [result: Rapunzel.Short] ~ {
Init[];
IF address >= memSize THEN ERROR Fault[nonexistent, address];
RETURN [mem[address]];
};
PokeShort:
PUBLIC PROC[
h: CrRPC.Handle, address: Rapunzel.Address, value: Rapunzel.Short] ~ {
Init[];
IF address >= memSize THEN ERROR Fault[nonexistent, address];
mem[address] ← value;
};
PeekSeqShort:
PUBLIC PROC [h: CrRPC.Handle, address: Rapunzel.Address, count:
CARDINAL]
RETURNS [resultSeq: Rapunzel.SeqShort] ~ {
Init[];
ERROR Fault[nonexistent, 0];
};
PokeSeqShort:
PUBLIC PROC [
h: CrRPC.Handle, address: Rapunzel.Address, valueSeq: Rapunzel.SeqShort] ~ {
Init[];
ERROR Fault[nonexistent, 0];
};
PeekLong:
PUBLIC PROC [h: CrRPC.Handle, address: Rapunzel.Address]
RETURNS [result: Rapunzel.Long] ~ {
x: Basics.LongNumber;
Init[];
IF address >= (memSize - 1) THEN ERROR Fault[nonexistent, address];
TRUSTED { x.lo ← mem[address]; x.hi ← mem[address+1]; result ← x.lc };
};
PokeLong:
PUBLIC PROC[
h: CrRPC.Handle, address: Rapunzel.Address, value: Rapunzel.Long] ~ {
x: Basics.LongNumber;
Init[];
IF address >= (memSize - 1) THEN ERROR Fault[nonexistent, address];
x.lc ← value; mem[address] ← x.lo; mem[address+1] ← x.hi;
};
}.