DIRECTORY Camelot, CamelotRecoverable, CountedVM, File, FileStream, FS, FSBackdoor, IO, Mach, PBasics, Process, Rope, YggDID, YggDIDPrivate, YggDIDMap, YggDIDMapPrivate, YggdrasilInit, YggLock, YggFixedNames, YggEnvironment, YggFile, YggFileStream, YggIndexMaint, YggInternal, YggMonitoringLog, YggRep, YggTransaction, VM; TestSupportImpl: CEDAR MONITOR IMPORTS CamelotRecoverable, CountedVM, FS, PBasics, Process, YggdrasilInit, YggTransaction, VM EXPORTS Camelot, Mach, YggdrasilInit, YggMonitoringLog = BEGIN OPEN Camelot, Mach; ROPE: TYPE = Rope.ROPE; notice: PUBLIC YggMonitoringLog.ProcsRecord _ []; DID: PUBLIC TYPE ~ REF DIDRep; DIDRep: PUBLIC TYPE ~ YggDIDPrivate.DIDRep; Document: TYPE = REF DocumentRep; DocumentRep: PUBLIC TYPE = YggDIDMapPrivate.DocumentRep; NextTransCount: CARD _ 10001; MachCall: PUBLIC SIGNAL [errorCode: msgReturnT, explanation: Rope.ROPE] = CODE; MachAnomaly: PUBLIC SIGNAL [explanation: Rope.ROPE] = CODE; taskSelf: PUBLIC PROC RETURNS [targetTask: taskT] ~ { targetTask _ [1]; }; taskNotify: PUBLIC PROC RETURNS [notifyPort: portT] ~ { notifyPort _ [2]; }; vmAllocate: PUBLIC PROC [targetTask: vmTaskT, address: vmAddressT, size: vmSizeT, anywhere: BOOL,raiseSignal: BOOL] RETURNS [mappedAddress: vmAddressT _ 0, kernCode: kernReturnT _ -1] ~ TRUSTED { interval: VM.Interval; interval _ VM.Allocate[count: VM.PagesForBytes[size]]; mappedAddress _ LOOPHOLE[VM.AddressForPageNumber[interval.page]]; kernCode _ KernSuccess; }; VMAllocList: LIST OF AllocItem _ NIL; AllocItem: TYPE = RECORD [ offset: vmOffsetT, size: vmSizeT, mappedAddress: vmAddressT, cvmHandle: CountedVM.Handle, allocated: BOOL _ TRUE ]; vmAllocateWithPager: PUBLIC ENTRY PROC [targetTask: vmTaskT, address: vmAddressT, size: vmSizeT, anywhere: BOOL, pagingObject: pagingObjectT, offset: vmOffsetT, raiseSignal: BOOL] RETURNS [mappedAddress: vmAddressT _ 0, kernCode: kernReturnT _ -1] ~ TRUSTED { loai: LIST OF AllocItem; cvmHandle: CountedVM.Handle; pages: INT _ -1; firstPage: INT _ -1; FOR loai _ VMAllocList, loai.rest UNTIL loai = NIL DO IF loai.first.offset > offset+size THEN LOOP; IF offset > loai.first.offset+loai.first.size THEN LOOP; IF loai.first.offset = offset AND loai.first.size = size THEN { IF loai.first.allocated THEN ERROR; EXIT; }; ENDLOOP; cvmHandle _ CountedVM.Allocate[words:size/BYTES[WORD]]; mappedAddress _ LOOPHOLE[cvmHandle.pointer]; pages _ FS.PagesForBytes[size]; IF INT[size] # FS.BytesForPages[pages] THEN ERROR; firstPage _ FS.PagesForBytes[offset]; IF INT[offset] # FS.BytesForPages[firstPage] THEN ERROR; IF loai = NIL THEN { where: LONG POINTER _ LOOPHOLE[mappedAddress]; nWordsLeft: CARD32 _ size/PBasics.bytesPerWord; WHILE nWordsLeft > 0 DO fillThisTime: CARD32 _ MIN[nWordsLeft, 10000]; PBasics.Fill[where: where, nWords: fillThisTime, value: 0]; where _ where + fillThisTime * UNITS[PBasics.Word]; nWordsLeft _ nWordsLeft - fillThisTime; ENDLOOP; VMAllocList _ CONS[[offset: offset, size: size, mappedAddress: mappedAddress, cvmHandle: cvmHandle], VMAllocList]; } ELSE { FS.Read[file: CamelotRecoverable.CamelotRecoverableFile, from: firstPage, nPages: pages, to: LOOPHOLE[mappedAddress]]; loai.first.allocated _ TRUE; loai.first.mappedAddress _ mappedAddress; loai.first.cvmHandle _ cvmHandle; }; kernCode _ KernSuccess; }; vmDeallocate: PUBLIC ENTRY PROC [targetTask: vmTaskT, address: vmAddressT, size: vmSizeT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT _ -1] ~ { FOR loai: LIST OF AllocItem _ VMAllocList, loai.rest UNTIL loai = NIL DO IF loai.first.mappedAddress = address THEN { pages: INT _ -1; firstPage: INT _ -1; IF size # loai.first.size THEN ERROR; pages _ FS.PagesForBytes[loai.first.size]; firstPage _ FS.PagesForBytes[loai.first.offset]; FS.Write[file: CamelotRecoverable.CamelotRecoverableFile, to: firstPage, nPages: pages, from: LOOPHOLE[address]]; loai.first.allocated _ FALSE; loai.first.mappedAddress _ 0; loai.first.cvmHandle _ NIL; EXIT; }; ENDLOOP; }; msgSend: PUBLIC PROC [header: REF msgHeaderT, option: msgOptionT, timeout: INT, raiseSignal: BOOL] RETURNS [msgCode: msgReturnT _ -1] ~ { ERROR; }; msgReceive: PUBLIC PROC [header: REF msgHeaderT, option: msgOptionT, timeout: INT, raiseSignal: BOOL] RETURNS [msgCode: msgReturnT _ -1] ~ { DO Process.Pause[33]; ENDLOOP; }; nameServerPort: PUBLIC PROC RETURNS [p: portT] ~ { p _ [3]; }; MachPortsLookup: PUBLIC PROC [targetTask: taskT, raiseSignal: BOOL] RETURNS [intPortSet: portArrayT, intPortArrayCount: INT, kernCode: kernReturnT] ~ { xPortArray: REF ARRAY[0..3] OF portT _ NEW[ARRAY[0..3] OF portT _ [[0], [1], [2], [3]]]; intPortArrayCount _ 4; kernCode _ KernSuccess; intPortSet _ LOOPHOLE[xPortArray]; }; nextPort: portT _ [10]; portAllocate: PUBLIC PROC [targetTask: taskT, raiseSignal: BOOL] RETURNS [newPort: portT, kernCode: kernReturnT _ -1] ~ TRUSTED { nextPort _ [nextPort + 1]; newPort _ nextPort; kernCode _ KernSuccess; }; portRestrict: PUBLIC PROC [targetTask: taskT, port: portT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT _ -1] ~ { kernCode _ KernSuccess; }; portUnrestrict: PUBLIC PROC [targetTask: taskT, port: portT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT _ -1] ~ { kernCode _ KernSuccess; }; netnameCheckIn: PUBLIC PROC [ServPort: portT, portName: Rope.ROPE, signature: portT, portId: portT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT] ~ { kernCode _ KernSuccess; }; DSInitialize: PUBLIC PROC [dsPort: portT, raiseSignal: BOOL] RETURNS [serverID: serverIdT, tsPort, mPort, sPort: portT, sharedMemAddr: vmAddressT, seqDescList: ListOfSegmentDesc _ NIL, seqPortList: ListOfPorts, kernCode: Mach.kernReturnT _ -1] ~ TRUSTED { serverID _ [1989]; tsPort _ [4]; mPort _ [5]; sPort _ [6]; sharedMemAddr _ 0; seqDescList _ LIST[[serverId: [1234], segmentId: [1066], logicalDisk: 'Z, unused: 'z, highSize: 0, lowSize: 40960000]]; seqPortList _ LIST[[7]]; kernCode _ KernSuccess; }; DSPinObject: PUBLIC PROC [dsPort: portT, tid: tidT, optr: optrT, size: uInt, raiseSignal: BOOL] RETURNS [kernCode: Mach.kernReturnT _ -1] ~ { kernCode _ KernSuccess; }; DSLogNewValue: PUBLIC PROC [dsPort: portT, tid: tidT, optr: optrT, newValue: pointerT, newValueCnt: INT, raiseSignal: BOOL] RETURNS [kernCode: Mach.kernReturnT _ -1] ~ { kernCode _ KernSuccess; }; DSLogOldValueNewValue: PUBLIC PROC [dsPort: portT, tid: tidT, optr: optrT, oldValue: pointerT, oldValueCnt: INT, newValue: pointerT, newValueCnt: INT, raiseSignal: BOOL] RETURNS [kernCode: Mach.kernReturnT _ -1] ~ { kernCode _ KernSuccess; }; DSQInit: PUBLIC PROC [sharedMemAddr: Mach.vmAddressT] ~ { }; TAAddApplication: PUBLIC PROC [tPort: portT, atPort: portT, authName: Rope.ROPE, raiseSignal: BOOL] RETURNS [applicationID: applicationIdT, taPort: portT, kernCode: Mach.kernReturnT _ -1] ~ TRUSTED { kernCode _ KernSuccess; }; TABegin: PUBLIC ENTRY PROC [taPort: portT, parentTid: tidT, transType: transactionTypeT, raiseSignal: BOOL] RETURNS [newTid: tidT, kernCode: Mach.kernReturnT _ -1] ~ TRUSTED { newTid _ GetNextTrans[]; kernCode _ KernSuccess; }; TAEnd: PUBLIC PROC [taPort: portT, tid: tidT, protocolType: protocolTypeT, raiseSignal: BOOL] RETURNS [timestamp: timestampT, status: INT, kernCode: Mach.kernReturnT _ -1] ~ TRUSTED { transID: YggTransaction.TransID _ LOOPHOLE[tid]; status _ ErSuccess; kernCode _ KernSuccess; }; TAKill: PUBLIC PROC [taPort: portT, tid: tidT, status: INT, raiseSignal: BOOL] RETURNS [kernCode: Mach.kernReturnT _ -1] ~ TRUSTED { transID: YggTransaction.TransID _ LOOPHOLE[tid]; YggTransaction.Suspend[transID, ErWaitingTransAborted]; kernCode _ KernSuccess; }; CALookup: PUBLIC PROC [nameServerPort: Mach.portT, name: Rope.ROPE, site: Rope.ROPE, numberWanted: INT, maxSeconds: INT, raiseSignal: BOOL] RETURNS [portList: Mach.ListOfPorts, kernCode: Mach.kernReturnT] ~ { portList _ LIST[[9]]; kernCode _ KernSuccess; }; GetNextTrans: PROC RETURNS [transID: YggTransaction.TransID] ~ { NextTransCount _ NextTransCount + 1; transID _ [top: [lowTicker: NextTransCount], bottom: [lowTicker: NextTransCount]]; }; DoCommit: PROC [transID: YggTransaction.TransID, doCommit: BOOL] ~ { [] _ YggTransaction.Finish[transID, IF doCommit THEN commit ELSE abort]; }; STServer: PUBLIC PROC [inMsg: REF Camelot.camlibSysReqMsgT, outMsg: REF Camelot.camlibSysRepMsgT] RETURNS [messageUnderstood: BOOL _ FALSE] ~ { }; SRServer: PUBLIC PROC [inMsg: REF Camelot.camlibSysReqMsgT, outMsg: REF Camelot.camlibSysRepMsgT] RETURNS [messageUnderstood: BOOL _ FALSE] ~ { }; ATServer: PUBLIC PROC [inMsg: REF Camelot.camlibSysReqMsgT, outMsg: REF Camelot.camlibSysRepMsgT] RETURNS [messageUnderstood: BOOL _ FALSE] ~ { }; Init: PROC = { YggdrasilInit.RecoveryComplete[]; }; Init[]; END. .TestSupportImpl.mesa Copyright Ó 1988, 1989 by Xerox Corporation. All rights reserved. Bob Hagmann March 24, 1989 7:47:41 am PST Exported junk Global data Exported task procedures get my task get my notify port (task_notify) Exported virtual memory procedures Grab some VM. Map some externally backed memory into VM. interval: VM.Interval; interval _ VM.Allocate[count: VM.PagesForBytes[size]]; Unmap some externally backed memory into VM, whether externally backed or not. TRUSTED{VM.Free[interval: loai.first.interval];}; REPEAT FINISHED => ERROR; Exported message procedures send a message Receive a message. Modifies the header! Exported port procedures get my port to the name server (name_server_port) get my port to the service port (service_port) send a message restricts port so that msgReceive must be used the port number, not PortDefault unrestricts port so that PortDefault to msgReceive can receive from this port Netname "check in a name into the local name space" Exported recoverable storage management procedures Initialize the data server. Pin an object in preparation for modification. Send a new value of an object to the log. Send a new value of an object to the log. Send a new value of an object to the log. Exported transaction management procedures Initialize an application to the transaction manager. Start a new transaction. Try to commit a transaction. DoCommit[transID, TRUE]; Try to abort a transaction. DoCommit[transID, FALSE]; Name server Lookup for applications. Local procs YggdrasilInit Initialization Ê Ü˜šœ™IcodešœB™BKšœ)™)K˜šÏk ˜ Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ˜——headšœœ˜KšœW˜^Kšœ/˜6K˜Kšœ˜Kšœ˜Kšœœœ˜K˜—™ K˜Kšœœ#˜1K˜Kšœ œœ˜Kšœœœ˜+K˜Kšœ œœ ˜!Kšœ œœ ˜8K˜K˜—™ K˜Kšœ˜—šœ™Kš Ïnœœœ+œœ˜OKš ž œœœœœÏb˜