DIRECTORY IO USING [int, PutFR1], Mach, Rope USING [Cat, Fetch, Length, ROPE]; MachImpl: CEDAR PROGRAM IMPORTS IO, Mach, Rope EXPORTS Mach ~ BEGIN OPEN Mach; MachCall: PUBLIC SIGNAL [errorCode: msgReturnT, explanation: Rope.ROPE] = CODE; MachAnomaly: PUBLIC SIGNAL [explanation: Rope.ROPE] = CODE; taskSelf: PUBLIC PROC RETURNS [targetTask: taskT] ~ { innerTaskSelf: PROC RETURNS [XtargetTask: taskT] ~ TRUSTED MACHINE CODE { "@task_self_" }; targetTask _ innerTaskSelf[]; IF targetTask # 1 THEN ERROR; }; taskNotify: PUBLIC PROC RETURNS [notifyPort: portT] ~ { innerTaskNotify: PROC RETURNS [XnotifyPort: portT] ~ TRUSTED MACHINE CODE { "@task_notify_" }; notifyPort _ innerTaskNotify[]; IF notifyPort # 2 THEN ERROR; }; taskData: PUBLIC PROC RETURNS [dataPort: portT] ~ { innerTaskData: PROC RETURNS [XdataPort: portT] ~ TRUSTED MACHINE CODE { "@task_data_" }; dataPort _ innerTaskData[]; }; vmAllocate: PUBLIC PROC [targetTask: vmTaskT, address: vmAddressT, size: vmSizeT, anywhere: BOOL,raiseSignal: BOOL] RETURNS [mappedAddress: vmAddressT _ 0, kernCode: kernReturnT _ -1] ~ TRUSTED { innerVmAllocate: PROC [itargetTask: vmTaskT, iaddress: POINTER TO vmAddressT, isize: vmSizeT, ianywhere: BOOL] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "vm_allocate" }; localAddress: vmAddressT _ address; allocCode: kernReturnT _ -1; allocCode _ innerVmAllocate[targetTask, @localAddress, size, anywhere]; IF raiseSignal AND allocCode # KernSuccess THEN SIGNAL Mach.MachCall[allocCode, Rope.Cat["vm_allocate failed; code = ", IO.PutFR1["%g", IO.int[allocCode]]]]; RETURN[localAddress, allocCode]; }; vmAllocateWithPager: PUBLIC PROC [targetTask: vmTaskT, address: vmAddressT, size: vmSizeT, anywhere: BOOL, pagingObject: pagingObjectT, offset: vmOffsetT, raiseSignal: BOOL] RETURNS [mappedAddress: vmAddressT _ 0, kernCode: kernReturnT _ -1] ~ TRUSTED { innerVmAllocateWithPager: PROC [itargetTask: vmTaskT, iaddress: POINTER TO vmAddressT, isize: vmSizeT, ianywhere: BOOL, ipagingObject: pagingObjectT, ioffset: vmOffsetT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "vm_allocate_with_pager" }; localAddress: vmAddressT _ address; allocCode: kernReturnT _ -1; allocCode _ innerVmAllocateWithPager[targetTask, @localAddress, size, anywhere, pagingObject, offset]; IF raiseSignal AND allocCode # KernSuccess THEN SIGNAL Mach.MachCall[allocCode, Rope.Cat["vm_allocate_with_pager failed; code = ", IO.PutFR1["%g", IO.int[allocCode]]]]; RETURN[localAddress, allocCode]; }; vmDeallocate: PUBLIC PROC [targetTask: vmTaskT, address: vmAddressT, size: vmSizeT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT _ -1] ~ { innerVmDellocate: PROC [itargetTask: vmTaskT, iaddress: vmAddressT, isize: vmSizeT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "vm_deallocate" }; deallocCode: kernReturnT _ -1; deallocCode _ innerVmDellocate[targetTask, address, size]; IF raiseSignal AND deallocCode # KernSuccess THEN SIGNAL Mach.MachCall[deallocCode, Rope.Cat["vm_deallocate failed; code = ", IO.PutFR1["%g", IO.int[deallocCode]]]]; RETURN[deallocCode]; }; msgSend: PUBLIC PROC [header: REF msgHeaderT, option: msgOptionT, timeout: INT, raiseSignal: BOOL] RETURNS [msgCode: msgReturnT _ -1] ~ { innerMsgSend: PROC [iheader: POINTER TO msgHeaderT, ioption: msgOptionT, itimeout: INT] RETURNS [msgReturnT] ~ TRUSTED MACHINE CODE { "msg_send" }; sendCode: msgReturnT _ SendErrorsStart; sendCode _ innerMsgSend[LOOPHOLE[header], option, timeout]; IF raiseSignal AND sendCode # KernSuccess THEN SIGNAL Mach.MachCall[sendCode, Rope.Cat["msg_send failed; code = ", IO.PutFR1["%g", IO.int[sendCode]]]]; RETURN[sendCode]; }; msgReceive: PUBLIC PROC [header: REF msgHeaderT, option: msgOptionT, timeout: INT, raiseSignal: BOOL] RETURNS [msgCode: msgReturnT _ -1] ~ { innerMsgReceive: PROC [iheader: POINTER TO msgHeaderT, ioption: msgOptionT, itimeout: INT] RETURNS [msgReturnT] ~ TRUSTED MACHINE CODE { "msg_receive" }; rCode: msgReturnT _ SendErrorsStart; rCode _ innerMsgReceive[LOOPHOLE[header], option, timeout]; IF raiseSignal AND rCode # KernSuccess THEN ERROR MachCall[rCode, Rope.Cat["msg_receive failed; code = ", IO.PutFR1["%g", IO.int[rCode]]]]; RETURN[rCode]; }; msgRPC: PUBLIC PROC [header: REF msgHeaderT, option: msgOptionT, rcvSize: INT, sendTimeout: INT, rcvTimeout: INT, raiseSignal: BOOL] RETURNS [msgCode: msgReturnT _ -1] ~ { innerMsgRPC: PROC [iheader: POINTER TO msgHeaderT, ioption: msgOptionT, ircvSize: INT, isendTimeout: INT, ircvTimeout: INT] RETURNS [msgReturnT]~ TRUSTED MACHINE CODE { "msg_RPC" }; rpcCode: msgReturnT _ RcvErrorsStart ; rpcCode _ innerMsgRPC[LOOPHOLE[header], option, rcvSize, sendTimeout, rcvTimeout]; IF raiseSignal AND rpcCode # KernSuccess THEN ERROR MachCall[rpcCode, Rope.Cat["msg_RPC failed; code = ", IO.PutFR1["%g", IO.int[rpcCode]]]]; RETURN[rpcCode]; }; nameServerPort: PUBLIC PROC RETURNS [p: portT] ~ { innerPort: PROC RETURNS [XportT: portT] ~ TRUSTED MACHINE CODE { "@name_server_port" }; p _ innerPort[]; }; environmentPort: PUBLIC PROC RETURNS [p: portT] ~ { innerPort: PROC RETURNS [XportT: portT] ~ TRUSTED MACHINE CODE { "@environment_port" }; p _ innerPort[]; }; servicePort: PUBLIC PROC RETURNS [p: portT] ~ { innerPort: PROC RETURNS [XportT: portT] ~ TRUSTED MACHINE CODE { "@service_port" }; p _ innerPort[]; }; MachPortsLookup: PUBLIC PROC [targetTask: taskT, raiseSignal: BOOL] RETURNS [intPortSet: portArrayT, intPortArrayCount: INT, kernCode: kernReturnT] ~ { xintPortArrayCount: POINTER TO INT; innerMachPortsLookup: PROC [itargetTask: taskT, iintPortSet: portArrayT, iintPortArrayCount: POINTER TO INT] RETURNS [kernReturnT]~ TRUSTED MACHINE CODE { "mach_ports_lookup" }; TRUSTED {xintPortArrayCount _ @intPortArrayCount;}; kernCode _ innerMachPortsLookup[targetTask, intPortSet, xintPortArrayCount]; IF raiseSignal AND kernCode # KernSuccess THEN ERROR MachCall[kernCode, IO.PutFR1["mach_ports_lookup failed; code = %g", IO.int[kernCode]]]; }; portAllocate: PUBLIC PROC [targetTask: taskT, raiseSignal: BOOL] RETURNS [newPort: portT, kernCode: kernReturnT _ -1] ~ TRUSTED { innerPortAllocate: PROC [itargetTask: taskT, inewPort: POINTER TO portT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "port_allocate" }; allocCode: kernReturnT _ -1 ; allocCode _ innerPortAllocate[targetTask, @newPort]; IF raiseSignal AND allocCode # KernSuccess THEN ERROR MachCall[allocCode, Rope.Cat["port_allocate failed; code = ", IO.PutFR1["%g", IO.int[allocCode]]]]; kernCode _ allocCode; }; portDeallocate: PUBLIC PROC [targetTask: taskT, localPort: portT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT _ -1] ~ { innerPortDeallocate: PROC [itargetTask: taskT, ilocalPort: portT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "port_deallocate" }; deallocCode: kernReturnT _ -1 ; deallocCode _ innerPortDeallocate[targetTask, localPort]; IF raiseSignal AND deallocCode # KernSuccess THEN ERROR MachCall[deallocCode, Rope.Cat["port_deallocate failed; code = ", IO.PutFR1["%g", IO.int[deallocCode]]]]; RETURN[deallocCode]; }; portRestrict: PUBLIC PROC [targetTask: taskT, port: portT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT _ -1] ~ { innerPortRestrict: PROC [itargetTask: taskT, iport: portT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "port_restrict" }; kernCode _ innerPortRestrict[targetTask, port]; IF raiseSignal AND kernCode # KernSuccess THEN SIGNAL Mach.MachCall[kernCode, IO.PutFR1["port_restrict failed; code = %g", IO.int[kernCode]]]; }; portUnrestrict: PUBLIC PROC [targetTask: taskT, port: portT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT _ -1] ~ { innerPortUnrestrict: PROC [itargetTask: taskT, iport: portT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "port_restrict" }; kernCode _ innerPortUnrestrict[targetTask, port]; IF raiseSignal AND kernCode # KernSuccess THEN SIGNAL Mach.MachCall[kernCode, IO.PutFR1["port_unrestrict failed; code = %g", IO.int[kernCode]]]; }; netnameCheckIn: PUBLIC PROC [ServPort: portT, portName: Rope.ROPE, signature: portT, portId: portT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT] ~ { innerNetnameCheckIn: PROC [wServPort: portT, wportName: POINTER TO Mach.netnameNameT, wsignature: portT, wportId: portT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "netname_check_in" }; portNameString: REF Mach.netnameNameT; portNameString _ netnameNameTFromRope[portName]; kernCode _ innerNetnameCheckIn[ServPort, LOOPHOLE[portNameString], signature, portId]; IF raiseSignal AND kernCode # KernSuccess THEN SIGNAL Mach.MachCall[kernCode, IO.PutFR1["netname_check_in failed; code = %g", IO.int[kernCode]]]; }; netnameLookUp: PUBLIC PROC [ServPort: portT, hostName: Rope.ROPE, portName: Rope.ROPE, raiseSignal: BOOL] RETURNS [portId: portT, kernCode: kernReturnT] ~ TRUSTED { innerNetnameLookUp: PROC [wServPort: portT, whostName: POINTER TO Mach.netnameNameT, wportName: POINTER TO Mach.netnameNameT, wportId: POINTER TO portT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "netname_look_up" }; portNameString: REF Mach.netnameNameT; hostNameString: REF Mach.netnameNameT; portNameString _ netnameNameTFromRope[portName]; hostNameString _ netnameNameTFromRope[hostName]; kernCode _ innerNetnameLookUp[ServPort, LOOPHOLE[hostNameString], LOOPHOLE[portNameString], @portId]; IF raiseSignal AND kernCode # KernSuccess THEN SIGNAL Mach.MachCall[kernCode, IO.PutFR1["netname_look_up failed; code = %g", IO.int[kernCode]]]; }; netnameCheckOut: PUBLIC PROC [ServPort: portT, portName: Rope.ROPE, signature: portT, raiseSignal: BOOL] RETURNS [kernCode: kernReturnT] ~ { innerNetnameCheckOut: PROC [wServPort: portT, wportName: POINTER TO Mach.netnameNameT, wsignature: portT] RETURNS [kernReturnT] ~ TRUSTED MACHINE CODE { "netname_check_out" }; portNameString: REF Mach.netnameNameT; portNameString _ netnameNameTFromRope[portName]; kernCode _ innerNetnameCheckOut[ServPort, LOOPHOLE[portNameString], signature]; IF raiseSignal AND kernCode # KernSuccess THEN SIGNAL Mach.MachCall[kernCode, IO.PutFR1["netname_check_in failed; code = %g", IO.int[kernCode]]]; }; netnameNameTFromRope: PROC [name: Rope.ROPE] RETURNS [portNameString: REF Mach.netnameNameT] ~ { pNSize: INT _ 0; portNameString _ NEW[Mach.netnameNameT]; pNSize _ Rope.Length[name]; IF pNSize >= 80 THEN ERROR; FOR index: INT IN [0..pNSize) DO portNameString[index] _ Rope.Fetch[name, index]; ENDLOOP; portNameString[pNSize] _ 0C; }; END. :MachImpl.mesa Copyright Ó 1988 by Xerox Corporation. All rights reserved. Bob Hagmann October 7, 1988 2:18:45 pm PDT Handle calls to Camelot from Cedar. See CamelotImpl for a discussion of the mapping of parameters advertized in .defs files and the actual calling sequence as generated by MIG. Exported task procedures get my task get my notify port (task_notify) get my data port (task_data) IF dataPort # 3 THEN ERROR; Exported virtual memory procedures Grab some VM. Map some externally backed memory into VM. Unmap some externally backed memory into VM, whether externally backed or not. Exported message procedures send a message Receive a message. Modifies the header! Receive a message. Modifies the header! Exported port procedures get my port to the name server (name_server_port) get my port to the environment (environment_port) get my port to the service port (service_port) get my port to the service port (service_port) send a message Receive a message. Modifies the header! 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" "check in a name into the local name space" "check in a name into the local name space" Initialization Ê Ò˜code•Mark outsideHeaderšœ ™ Kšœ<™œœœœ˜‚Kšœ˜K˜—Kšœ˜Kšœ:˜:Kš œ œœœFœœ˜¥Kšœ˜K˜——šœ™š œœœ œ*œœœ˜‰Kšœ™šœœ œœ,œœœœœ˜…Kšœ˜K˜—Kšœ'˜'Kšœœ˜;Kš œ œœœ>œœ˜—Kšœ ˜K˜K™K™—š  œœœ œ*œœœ˜ŒKšœ™Kšœ™šœœ œœ,œœœœœ˜ˆKšœ˜K˜—Kšœ$˜$Kšœœ˜;Kš œ%œœ9œœ˜‹Kšœ˜K˜K™—š œœœ œ*œœœœœ˜«Kšœ™Kšœ™šœ œ œœ,œœœœœœœ˜¨Kšœ˜K˜—Kšœ&˜&Kšœœ4˜RKš œ'œœ7œœ˜Kšœ ˜K˜K™——šœ™š œ œœ˜2Kšœ2™2š œ œœœœœ˜AKšœ˜K˜—Kšœ˜K˜K™—š œ œœ˜3Kšœ2™2š œ œœœœœ˜AKšœ˜K˜—Kšœ˜K˜K™—š  œ œœ˜/Kšœ/™/š œ œœœœœ˜AKšœ˜K˜—Kšœ˜K˜K™—š Ÿœœœ"œœ-œ˜—Kšœ/™/Kšœœœœ˜#šœœCœœœœœœœ˜›Kšœ˜K˜—Kšœ,˜3KšœL˜LKš œ(œœœ/œ˜ŒK˜K˜K™—š   œœœ"œœ0œ˜Kšœ™šœœ œœœœœœ˜wKšœ˜K˜—Kšœ˜Kšœ4˜4Kš œ)œœ?œœ˜™Kšœœ ˜K˜K™K™—š  œœœœœœ!˜}Kšœ™Kšœ™š œœ)œœœœ˜pKšœ˜K˜—Kšœ˜Kšœ9˜9Kš œ+œœCœœ˜¡Kšœ˜K˜K˜—š  œ œ/œœ!˜vK™Oš œœ$œœœœ˜iKšœ˜K˜—Kšœ/˜/Kš œ œœœœ+œ˜ŽK˜K™—š œ œ/œœ!˜xK™Mš œœ$œœœœ˜kKšœ˜K˜—Kšœ1˜1Kš œ œœœœ-œ˜K˜K™K˜——™š  œœœ"œ0œœ˜šK™+šœœœœ7œœœœ˜§Kšœ%˜%K˜—Kšœœ˜&Kšœ0˜0Kšœ)œ%˜VKš œ œœœœ.œ˜‘K˜K™—š  œ œ"œœœœ*œ˜¤K™+šœœœœœœœœœœœœ˜ÇKšœ$˜$K˜—Kšœœ˜&Kšœœ˜&Kšœ0˜0Kšœ0˜0Kšœ(œœ˜eKš œ œœœœ-œ˜K˜K™—š  œ œ"œ!œœ˜ŒK™+šœœœœ'œœœœ˜˜Kšœ&˜&K˜—Kšœœ˜&Kšœ0˜0Kšœ*œ˜OKš œ œœœœ.œ˜‘K˜K˜—š  œœ œœœ˜`Kšœœ˜Kšœœ˜(Kšœ˜Kšœœœ˜šœœœ ˜ Kšœ0˜0Kšœ˜—Kšœ˜K˜K™——™K˜—K˜Kšœ˜—…—(Ü9è