LupineRuntime.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
BZM on 11-May-82 16:17:07.
Birrell, September 12, 1983 2:02 pm
Swinehart, February 8, 1985 8:13:38 am PST
Bob Hagmann February 11, 1985 9:40:39 am PST
Russ Atkinson (RRA) February 20, 1985 7:16:49 pm PST
This interface is used at runtime for marshaling and other common functions.
DIRECTORY
Basics USING [charsPerWord],
PrincOpsUtils USING [LongCopy],
RPC USING [Zones],
Rope USING [ ROPE ],
RPCLupine USING [DataLength, maxDataLength, --PktLength,-- RPCPkt, StubPkt];
LupineRuntime: DEFINITIONS IMPORTS PrincOpsUtils = { OPEN RpcPrivate: RPCLupine;
Lupine's no-nonsense errors.
TranslationError: ERROR;
BindingError: ERROR;
RuntimeError: ERROR;
These procedures map into ERRORs (for now).
MarshalingError: PROC;
MarshalingExprError: PROC RETURNS [never: UNSPECIFIED];
These procedures map into RpcRuntime ERRORs.
UnmarshalingError: PROC;
UnmarshalingExprError: PROC RETURNS [never: UNSPECIFIED];
DispatchingError: PROC RETURNS [never: UNSPECIFIED];
Default parameter storage zones.
defaultZones: RPC.Zones;
Parameter protocol headers.
NilHeader: TYPE = BOOLNULL;
RopeHeader: TYPE = CARDINALNULL;
ListHeader, SequenceHeader: TYPE = LONG CARDINALNULL;
StringHeader: TYPE = MACHINE DEPENDENT RECORD [
header (0): SELECT OVERLAID * FROM
Lengths => [maxLength (0), length (1): CARDINALNULL],
All => [all (0): LONG CARDINAL],
ENDCASE] ← [Lengths[]];
Parameter marshaling routines.
DoubleWord: TYPE = LONG CARDINAL; -- LONG UNSPECIFIED doesn't work well
StubPktDoubleWord: PROC [pkt: RpcPrivate.StubPkt, index: RpcPrivate.DataLength] RETURNS [--ptrToDoubleWord:-- POINTER TO DoubleWord] = INLINE {
RETURN[LOOPHOLE[@pkt.data[index]]]};
RpcPktDoubleWord: PROC [pkt: RpcPrivate.RPCPkt, index: RpcPrivate.DataLength] RETURNS [--ptrToDoubleWord:-- LONG POINTER TO DoubleWord] = INLINE {
RETURN[LOOPHOLE[@pkt.data[index]]]};
SHORT: PROC [long: LONG CARDINAL] RETURNS [CARDINAL] = INLINE {
IF long <= LAST[CARDINAL] THEN RETURN[long] ELSE RETURN[UnmarshalingExprError[]];
};
Words: TYPE = --LONG-- CARDINALNULL;
WordsForChars: PROC [chars: CARDINAL] RETURNS [--words:-- Words] = INLINE {
RETURN[(chars+Basics.charsPerWord-1)/Basics.charsPerWord];
};
CheckPktLength: PROC [ pkt: RpcPrivate.RPCPkt, lastPkt: BOOLTRUE, pktLength: RpcPrivate.DataLength ] = INLINE {
IF RpcPrivate.PktLength[pkt: pkt] # [lastPkt: lastPkt, pktLength: pktLength]
THEN UnmarshalingError;
};
FinishThisPkt, StartNextPkt: PROC [ pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength ] RETURNS [zeroPktLength: RpcPrivate.DataLength];
CopyToPkt: PROC [ pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, dataAdr: LONG POINTER, dataLength: Words, alwaysOnePkt: BOOLFALSE ] RETURNS [--newPktLength:-- RpcPrivate.DataLength] = INLINE {
IF alwaysOnePkt OR pktLength+dataLength <= RpcPrivate.maxDataLength
THEN {
PrincOpsUtils.LongCopy[to: @pkt.data[pktLength], from: dataAdr, nwords: dataLength];
RETURN[pktLength+dataLength];
}
ELSE RETURN[ CopyToMultiplePkts[pkt, pktLength, dataAdr, dataLength] ];
};
CopyFromPkt: PROC [ pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, dataAdr: LONG POINTER, dataLength: Words, alwaysOnePkt: BOOLFALSE ] RETURNS [--newPktLength:-- RpcPrivate.DataLength] = INLINE {
IF alwaysOnePkt OR pktLength+dataLength <= RpcPrivate.maxDataLength
THEN {
PrincOpsUtils.LongCopy[to: dataAdr, from: @pkt.data[pktLength], nwords: dataLength];
RETURN[pktLength+dataLength];
}
ELSE RETURN[ CopyFromMultiplePkts[pkt, pktLength, dataAdr, dataLength] ];
};
CopyToMultiplePkts, CopyFromMultiplePkts: PRIVATE PROC [ pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, dataAdr: LONG POINTER, dataLength: Words ] RETURNS [--newPktLength:-- RpcPrivate.DataLength];
MarshalRope: PROC [ rope: Rope.ROPE, pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, assertShortRope: BOOL] RETURNS [newLength: RpcPrivate.DataLength];
UnmarshalRope: PROC [pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength, assertShortRope: BOOL] RETURNS [rope: Rope.ROPE, newLength: RpcPrivate.DataLength];
MarshalAtom: PROC [ atom: ATOM, pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength] RETURNS [newLength: RpcPrivate.DataLength];
UnmarshalAtom: PROC [pkt: RpcPrivate.RPCPkt, pktLength: RpcPrivate.DataLength] RETURNS [atom: ATOM, newLength: RpcPrivate.DataLength];
}. -- LupineRuntime.
Bob Hagmann February 11, 1985 9:33:46 am PST
changes to: DIRECTORY, LupineRuntime, PacketBufferLock, MaxPacketBufferListSize, PacketBufferCacheList