-- Stub file was translated on July 19, 1984 2:05:41 am PDT by Lupine of December 20, 1983 1:22:57 pm PST -- Source interface Multibus came from file Multibus.bcd, which was created on July 19, 1984 1:56:38 am PDT with version stamp 14#17#25044235147 from source of July 17, 1984 3:41:14 pm PDT. -- The RPC stub modules for Multibus are: -- MultibusRpcControl.mesa; -- MultibusRpcClientImpl.mesa; -- MultibusRpcBinderImpl.mesa; -- MultibusRpcServerImpl.mesa. -- The parameters for this translation are: -- Target language = Cedar -- Default parameter passing = VALUE -- Deallocate server heap arguments = TRUE -- Inline RpcServerImpl dispatcher stubs = TRUE -- Declare signals = TRUE -- Warn about short POINTER ("MDS") allocations = TRUE -- Maximum number of dynamic heap NEWs = 50, MDS NEWs = 50 -- Acceptable parameter protocols = VersionRange[1..1]. DIRECTORY Multibus, MultibusRpcControl USING [InterMdsCallsOnly, LupineProtocolVersion, ProcedureIndex, SignalIndex], RPC USING [EncryptionKey, InterfaceName, Principal, standardZones, Zones], RPCLupine --USING SOME OF [Call, DataLength, Dispatcher, ExportHandle, -- ExportInterface, GetStubPkt, maxDataLength, maxPrincipalLength, -- maxShortStringLength, pktOverhead, ReceiveExtraPkt, SendPrelimPkt, -- StartCall, StartSignal, StubPkt, UnexportInterface]--, LupineRuntime --USING SOME OF [BindingError, CheckPktLength, CopyFromPkt, -- CopyFromMultiplePkts, CopyToPkt, CopyToMultiplePkts, defaultZones, -- DispatchingError, FinishThisPkt, ListHeader, MarshalingError, -- MarshalingExprError, NilHeader, ProtocolError, RopeHeader, RpcPktDoubleWord, -- RuntimeError, SequenceHeader, SHORT, StartNextPkt, StringHeader, -- StubPktDoubleWord, TranslationError, UnmarshalingError, UnmarshalingExprError, -- WordsForChars]--, Atom --USING SOME OF [GetPName, MakeAtom]--, Rope --USING SOME OF [InlineFlatten, Length, NewText, Text]--; MultibusRpcServerImpl: MONITOR IMPORTS Multibus, RpcPrivate: RPCLupine, Lupine: LupineRuntime, Atom, Rope EXPORTS MultibusRpcControl SHARES Multibus, MultibusRpcControl, Rope = BEGIN OPEN Multibus, RpcControl: MultibusRpcControl, RpcPublic: RPC; -- Standard remote binding routines. bound: BOOLEAN ← FALSE; myInterface: RpcPrivate.ExportHandle; paramZones: RpcPublic.Zones ← RpcPublic.standardZones; ExportInterface: PUBLIC ENTRY SAFE PROCEDURE [ interfaceName: RpcPublic.InterfaceName, user: RpcPublic.Principal, password: RpcPublic.EncryptionKey, parameterStorage: RpcPublic.Zones ] = TRUSTED BEGIN ENABLE UNWIND => NULL; IsNull: PROCEDURE [string: Rope.ROPE] RETURNS [BOOLEAN] = INLINE {RETURN[string.Length[] = 0]}; IF bound THEN Lupine.BindingError; myInterface ← RpcPrivate.ExportInterface [ interface: [ type: IF ~IsNull[interfaceName.type] THEN interfaceName.type ELSE "Multibus~14#17#25044235147", instance: interfaceName.instance, version: interfaceName.version ], user: user, password: password, dispatcher: ServerDispatcher, localOnly: RpcControl.InterMdsCallsOnly, stubProtocol: RpcControl.LupineProtocolVersion ]; paramZones ← [ gc: IF parameterStorage.gc # NIL THEN parameterStorage.gc ELSE Lupine.defaultZones.gc, heap: IF parameterStorage.heap # NIL THEN parameterStorage.heap ELSE Lupine.defaultZones.heap, mds: IF parameterStorage.mds # NIL THEN parameterStorage.mds ELSE Lupine.defaultZones.mds ]; bound ← TRUE; END; UnexportInterface: PUBLIC ENTRY SAFE PROCEDURE = TRUSTED BEGIN ENABLE UNWIND => NULL; IF ~bound THEN Lupine.BindingError; myInterface ← RpcPrivate.UnexportInterface[myInterface]; paramZones ← RpcPublic.standardZones; bound ← FALSE; END; -- Public procedure dispatcher and public signal and error catcher. ServerDispatcher: --PROCEDURE [pkt: RPCPkt, callLength: DataLength, -- lastPkt: BOOLEAN, localConversation: Conversation] RETURNS [returnLength: -- DataLength]-- RpcPrivate.Dispatcher = BEGIN -- Catch public signals. ENABLE BEGIN Error --ERROR [reason: LONG STRING]-- => BEGIN ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.SignalIndex ← Error]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength ← 1; lastPkt: BOOLEAN; RpcPrivate.StartSignal[signalPkt: pkt]; argPkt.transferIndex ← Error; BEGIN -- Marshal reason: LONG STRING to pkt.data[pktLength]. IF pktLength+3 > RpcPrivate.maxDataLength THEN pktLength ← Lupine.StartNextPkt[pkt: pkt, pktLength: pktLength]; pkt.data[pktLength] ← reason=NIL; pktLength ← pktLength+1; IF reason # NIL THEN BEGIN stringHeader: Lupine.StringHeader = [ Lengths[length: reason.length, maxLength: reason.maxlength]]; Lupine.RpcPktDoubleWord[pkt, pktLength]↑ ← stringHeader.all; pktLength ← pktLength + 2; pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength, dataAdr: BASE[reason.text], dataLength: Lupine.WordsForChars[stringHeader.length], alwaysOnePkt: FALSE]; END; -- IF reason # NIL. END; -- Marshal reason. [returnLength: , lastPkt: lastPkt] ← RpcPrivate.Call[ pkt: pkt, callLength: pktLength, maxReturnLength: 0]; Lupine.RuntimeError; -- Impossible to RESUME an ERROR. END; -- Error. END; -- Catch public signals. -- Call public procedures (still in dispatcher). SELECT LOOPHOLE[pkt.data[0], RpcControl.ProcedureIndex] FROM Input => RETURN[ InputStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; Output => RETURN[ OutputStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; RawRead => RETURN[ RawReadStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; RawWrite => RETURN[ RawWriteStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; RawReadPage => RETURN[ RawReadPageStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; RawWritePage => RETURN[ RawWritePageStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; RawReadBlock => RETURN[ RawReadBlockStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; RawWriteBlock => RETURN[ RawWriteBlockStub[pkt: pkt, callLength: callLength, lastPkt: lastPkt, localConversation: localConversation]]; ENDCASE => RETURN[Lupine.DispatchingError[]]; END; -- ServerDispatcher -- Public procedure dispatcher stubs. InputStub: --PROCEDURE [address: HANDLEIOAddress] RETURNS [word: -- UNSPECIFIED]-- RpcPrivate.Dispatcher = INLINE BEGIN ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, address (1): HANDLEIOAddress]; ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [ word (0): UNSPECIFIED]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength; Lupine.CheckPktLength[pkt: pkt, pktLength: 3]; [resPkt.word] ← Input[argPkt.address]; pktLength ← 1; RETURN[returnLength: pktLength]; END; -- InputStub. OutputStub: --PROCEDURE [word: UNSPECIFIED, address: HANDLEIOAddress]-- RpcPrivate.Dispatcher = INLINE BEGIN ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, word (1): UNSPECIFIED, address (2): HANDLEIOAddress]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength; Lupine.CheckPktLength[pkt: pkt, pktLength: 4]; Output[argPkt.word, argPkt.address]; pktLength ← 0; RETURN[returnLength: pktLength]; END; -- OutputStub. RawReadStub: --PROCEDURE [address: HANDLERawAddress] RETURNS [word: -- UNSPECIFIED]-- RpcPrivate.Dispatcher = INLINE BEGIN ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, address (1): HANDLERawAddress]; ResultOverlay: TYPE = MACHINE DEPENDENT RECORD [ word (0): UNSPECIFIED]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; resPkt: LONG POINTER TO ResultOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength; Lupine.CheckPktLength[pkt: pkt, pktLength: 3]; [resPkt.word] ← RawRead[argPkt.address]; pktLength ← 1; RETURN[returnLength: pktLength]; END; -- RawReadStub. RawWriteStub: --PROCEDURE [word: UNSPECIFIED, address: HANDLERawAddress]-- RpcPrivate.Dispatcher = INLINE BEGIN ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, word (1): UNSPECIFIED, address (2): HANDLERawAddress]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength; Lupine.CheckPktLength[pkt: pkt, pktLength: 4]; RawWrite[argPkt.word, argPkt.address]; pktLength ← 0; RETURN[returnLength: pktLength]; END; -- RawWriteStub. RawReadPageStub: --PROCEDURE [address: HANDLERawAddress] RETURNS -- [page: Page]-- RpcPrivate.Dispatcher = INLINE BEGIN page: Page; ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, address (1): HANDLERawAddress]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength; Lupine.CheckPktLength[pkt: pkt, pktLength: 3]; [page] ← RawReadPage[argPkt.address]; pktLength ← 0; BEGIN -- Marshal page: Page to pkt.data[pktLength]. pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength, dataAdr: @page, dataLength: SIZE[Page], alwaysOnePkt: FALSE]; END; -- Marshal page. RETURN[returnLength: pktLength]; END; -- RawReadPageStub. RawWritePageStub: --PROCEDURE [page: Page, address: HANDLERawAddress]-- RpcPrivate.Dispatcher = INLINE BEGIN page: Page; address: HANDLERawAddress; ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, address (1): HANDLERawAddress]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength ← 3; [address: address] ← argPkt↑; BEGIN -- Unmarshal page: Page from pkt.data[pktLength]. pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength, dataAdr: @page, dataLength: SIZE[Page], alwaysOnePkt: FALSE]; END; -- Unmarshal page. Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength]; RawWritePage[page, address]; pktLength ← 0; RETURN[returnLength: pktLength]; END; -- RawWritePageStub. RawReadBlockStub: --PROCEDURE [address: HANDLERawAddress] RETURNS -- [block: Block]-- RpcPrivate.Dispatcher = INLINE BEGIN block: Block; ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, address (1): HANDLERawAddress]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength; Lupine.CheckPktLength[pkt: pkt, pktLength: 3]; [block] ← RawReadBlock[argPkt.address]; pktLength ← 0; BEGIN -- Marshal block: Block to pkt.data[pktLength]. pktLength ← Lupine.CopyToPkt[pkt: pkt, pktLength: pktLength, dataAdr: @block, dataLength: SIZE[Block], alwaysOnePkt: FALSE]; END; -- Marshal block. RETURN[returnLength: pktLength]; END; -- RawReadBlockStub. RawWriteBlockStub: --PROCEDURE [block: Block, address: HANDLERawAddress]-- RpcPrivate.Dispatcher = INLINE BEGIN block: Block; address: HANDLERawAddress; ArgumentOverlay: TYPE = MACHINE DEPENDENT RECORD [ transferIndex (0): RpcControl.ProcedureIndex, address (1): HANDLERawAddress]; argPkt: LONG POINTER TO ArgumentOverlay = @pkt.data[0]; pktLength: RpcPrivate.DataLength ← 3; [address: address] ← argPkt↑; BEGIN -- Unmarshal block: Block from pkt.data[pktLength]. pktLength ← Lupine.CopyFromPkt[pkt: pkt, pktLength: pktLength, dataAdr: @block, dataLength: SIZE[Block], alwaysOnePkt: FALSE]; END; -- Unmarshal block. Lupine.CheckPktLength[pkt: pkt, pktLength: pktLength]; RawWriteBlock[block, address]; pktLength ← 0; RETURN[returnLength: pktLength]; END; -- RawWriteBlockStub. -- No module initialization. END. -- MultibusRpcServerImpl.