SoftcardRemoteCallImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
written by Ch. Le Cocq, August 4, 1988
Christian Le Cocq November 9, 1988 6:08:14 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: BOOLEANFALSE;
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.STREAMIO.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: CARD32NARROW[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.STREAMIO.ROS[];
IO.UnsafePutBlock[ros, ub];
r ← IO.RopeFromROS[ros];
};
Reset: PROC[inputFile: IO.STREAM] ~ {
procTable ← RefTab.Create[];
};
procTable: RefTab.Ref;
pendingRequest: CARD32;
result: CARD32;
SoftcardDataExch.Register[RCALL, ActionCall];
SoftcardDataExch.Register[RREGISTER, ActionRegister];
SparcSoftcardLoaderOps.RegisterStartProc[$SparcRemoteCall, Reset];
END.