SoftcardRemoteCallImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
written by Ch. Le Cocq, August 4, 1988
Christian Le Cocq December 5, 1988 4:22:47 pm PST
Christophe Cuenod September 12, 1988 5:59:56 pm PDT
Description of what this module does.
DIRECTORY
Atom,
Basics,
IO,
RefTab,
Rope,
SoftcardDataExch,
SoftcardRemoteCall,
SparcSoftcardLoaderOps;
SoftcardRemoteCallImpl: CEDAR MONITOR
IMPORTS Atom, IO, RefTab, SoftcardDataExch, SparcSoftcardLoaderOps
EXPORTS SoftcardRemoteCall
~
BEGIN
QUIT: CARD32 ← SoftcardDataExch.QUIT; -- 0 is the type which stops the watch procedure of the SPARC
RCALL: CARD32 = SoftcardRemoteCall.RCALL;
RREGISTER: CARD32 = SoftcardRemoteCall.RREGISTER;
ProcId: TYPE ~ SoftcardRemoteCall.ProcId;
ProcDesc:
TYPE ~
REF ProcDescRec;
ProcDescRec: TYPE ~ RECORD[ad, private: CARD32];
Utilities
waitForAnswer: BOOLEAN ← FALSE;
answerReceived: CONDITION;
ReleaseLock:
ENTRY PROC ~ {
ENABLE UNWIND => NULL;
waitForAnswer ← FALSE;
BROADCAST answerReceived;
};
TakeLock:
PROC ~ {
WaitForLock[];
waitForAnswer ← TRUE;
};
WaitForLock:
ENTRY PROC ~ {
ENABLE UNWIND => NULL;
WHILE waitForAnswer
DO
WAIT answerReceived
ENDLOOP;
};
ActionProcs
ActionRegister: SoftcardDataExch.ActionProc ~ {
keyName: Rope.ROPE;
key: ProcId;
IF ub.count=0
THEN keyName ← "SoftcardProc"
ELSE {
ros: IO.STREAM ← IO.ROS[];
IO.UnsafePutBlock[ros, ub];
keyName ← IO.RopeFromROS[ros];
};
key ← Atom.MakeAtom[pName: keyName];
[] ← RefTab.Store[procTable, key, NEW[ProcDescRec ← [ad: data1, private: data2]]]
};
ActionCall: SoftcardDataExch.ActionProc ~ {
PROC[ub: Basics.UnsafeBlock, type, data1, data2: CARD32];
IF data1#pendingRequest THEN Error;
result ← data2;
ReleaseLock[];
};
Public Procs
UnknownProc: PUBLIC ERROR ~ CODE;
Error: ERROR ~ CODE; --probably an unconsistency between the SPARC and 6085 sides
CallRProc:
PUBLIC
PROC[procId: ProcId, argsByteSize:
CARD32, putArgs:
PROC [ub: Basics.UnsafeBlock] ←
NIL]
RETURNS [r:
CARD32] ~ {
DoPutArgs: SoftcardDataExch.PutProc ~ {
putArgs[ub];
RETURN[ub.count];
};
addr: CARD32 ← NARROW[RefTab.Fetch[procTable, procId].val, ProcDesc].ad;
TakeLock[];
pendingRequest ← pendingRequest+1;
SoftcardDataExch.PutPacket[RCALL, addr, pendingRequest, argsByteSize, DoPutArgs];
WaitForLock[];
RETURN[result];
};
RopeFromUnsafeBlock:
PUBLIC
PROC[ub: Basics.UnsafeBlock]
RETURNS [r: Rope.
ROPE] ~ {
ros: IO.STREAM ← IO.ROS[];
IO.UnsafePutBlock[ros, ub];
r ← IO.RopeFromROS[ros];
};
Reset:
PROC[inputFile:
IO.
STREAM] ~ {
procTable ← RefTab.Create[];
ReleaseLock[];
};
procTable: RefTab.Ref;
pendingRequest: CARD32;
result: CARD32;
SoftcardDataExch.Register[RCALL, ActionCall];
SoftcardDataExch.Register[RREGISTER, ActionRegister];
SparcSoftcardLoaderOps.RegisterStartProc[$SparcRemoteCall, Reset];
END.