DIRECTORY Basics, PrincOps; PrincOpsUtils: DEFINITIONS IMPORTS Basics = BEGIN OPEN PrincOps; PagesForWords: SAFE PROC [words: INT] RETURNS [pages: PageCount] = TRUSTED INLINE { RETURN[Basics.DoubleShiftRight[[li[li: words+(wordsPerPage-1)]], logWordsPerPage].li] }; WordsForPages: SAFE PROC [pages: PageCount] RETURNS [words: INT] = TRUSTED INLINE { RETURN[Basics.DoubleShiftLeft[[li[li: pages]], logWordsPerPage].li] }; PagesForBytes: SAFE PROC [bytes: INT] RETURNS [pages: PageCount] = TRUSTED INLINE { RETURN[Basics.DoubleShiftRight[[li[li: bytes+(bytesPerPage-1)]], logBytesPerPage].li] }; BytesForPages: SAFE PROC [pages: PageCount] RETURNS [bytes: INT] = TRUSTED INLINE { RETURN[Basics.DoubleShiftLeft[[li[li: pages]], logBytesPerPage].li] }; AddressForPageNumber: SAFE PROC [page: PageNumber] RETURNS [address: LONG POINTER] = TRUSTED INLINE { RETURN[Basics.DoubleShiftLeft[[li[li: page]], logWordsPerPage].lp] }; PageNumberForAddress: SAFE PROC [address: LONG POINTER] RETURNS [page: PageNumber] = TRUSTED INLINE { RETURN[Basics.DoubleShiftRight[ [lp[address]], logWordsPerPage].li] }; LongMove: PROC [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] = INLINE { Ordered: PROC [lp: LONG POINTER] RETURNS [LONG ORDERED POINTER] = MACHINE CODE {}; IF Ordered[to] IN [Ordered[from]..Ordered[from]+nwords) THEN FOR i: CARDINAL DECREASING IN [0..nwords) DO (to+i)^ _ (from+i)^; ENDLOOP ELSE LongCopy[from: from, to: to, nwords: nwords]; }; Copy: PROC [from: POINTER, nwords: CARDINAL, to: POINTER] = MACHINE CODE {zBLT}; ByteBlt: PROC [to, from: ByteBltBlock] RETURNS [nBytes: CARDINAL]; LongCopy: PROC [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] = MACHINE CODE {zBLTL}; BitOp: TYPE = PROC [WORD, WORD] RETURNS [WORD]; BITAND: BitOp = MACHINE CODE {zAND}; BITOR: BitOp = MACHINE CODE {zOR}; BITXOR: BitOp = MACHINE CODE {zXOR}; BITNOT: PROC [WORD] RETURNS [WORD] = MACHINE CODE {zLIN1; zXOR}; BITSHIFT: PROC [value: WORD, count: INTEGER] RETURNS [WORD] = MACHINE CODE {zSHIFT}; LowHalf: PROC [u: LONG POINTER] RETURNS [POINTER] = INLINE {RETURN[LOOPHOLE[LOOPHOLE[u, Basics.LongNumber].lo]]}; HighHalf: PROC [u: LONG POINTER] RETURNS [CARDINAL] = INLINE {RETURN[LOOPHOLE[u, Basics.LongNumber].hi]}; MakeLongPointer: PROC [low: POINTER, high: CARDINAL] RETURNS [LONG POINTER] = INLINE { RETURN[LOOPHOLE[Basics.LongNumber[pair[lo: LOOPHOLE[low], hi: high]]]]}; LongZero: PROC [where: LONG POINTER, nwords: CARDINAL] = MACHINE CODE { zMISC, aZERO; zPOP; zPOP}; PUSH: PROC RETURNS [WORD] = MACHINE CODE {zPUSH}; GetClockPulses: SAFE PROC RETURNS [CARD] = TRUSTED MACHINE CODE {zMISC, aRCLK}; VERSION: SAFE PROC RETURNS [VersionResult] = TRUSTED MACHINE CODE {zMISC, aVERSION}; AlignedBBTable: PROC [ip: POINTER TO BBTableSpace] RETURNS [b: BBptr] = INLINE { align: TYPE = MACHINE DEPENDENT RECORD [ s: [0..WORD.LAST/BBTableAlignment), z: [0..BBTableAlignment)]; b _ LOOPHOLE[ip + BBTableAlignment - 1]; LOOPHOLE[b, align].z _ 0; }; BITBLT: PROC [ptr: BBptr] = MACHINE CODE {zBITBLT}; AlignedTextBltArg: PROC [ip: POINTER TO TextBltArgSpace] RETURNS [p: POINTER TO TextBltArg] = INLINE { align: TYPE = MACHINE DEPENDENT RECORD [ s: [0..WORD.LAST/TextBltArgAlignment), z: [0..TextBltArgAlignment)]; p _ LOOPHOLE[ip + TextBltArgAlignment - 1]; LOOPHOLE[p, align].z _ 0; }; TextBlt: PROC [ index: CARDINAL, bitPos: CARDINAL, micaPos: CARDINAL, count: INTEGER, ptr: POINTER TO TextBltArg] RETURNS [ newIndex: CARDINAL, newBitPos: CARDINAL, newMicaPos: CARDINAL, newCount: INTEGER, result: TextBltResult ] = MACHINE CODE {zMISC, aTEXTBLT}; GetReturnLink: PROC RETURNS [ControlLink] = MACHINE CODE {zLLB, returnOffset}; SetReturnLink: PROC [ControlLink] = MACHINE CODE {zSLB, returnOffset}; IsBound: SAFE PROC [link: ControlLink] RETURNS [BOOL] = TRUSTED INLINE {RETURN[link ~= UnboundLink AND link ~= NullLink]}; GetReturnFrame: PROC RETURNS [FrameHandle] = LOOPHOLE[GetReturnLink]; SetReturnFrame: PROC [FrameHandle] = LOOPHOLE[SetReturnLink]; MyLocalFrame: PROC RETURNS [FrameHandle] = MACHINE CODE {zLADRB, 0}; MakeFsi: SAFE PROC [words: [0..MaxFrameSize]] RETURNS [fsi: FrameSizeIndex] = TRUSTED INLINE { FOR fsi IN [0..LastAVSlot) DO IF FrameVec[fsi] >= words THEN RETURN; ENDLOOP; ERROR }; FrameSize: SAFE PROC [fsi: FrameSizeIndex[0..LargeReturnSlot)] RETURNS [[0..MaxFrameSize]] = TRUSTED INLINE {RETURN[FrameVec[fsi]]}; MyGlobalFrame: PROC RETURNS [GlobalFrameHandle] = MACHINE CODE {zGADRB, 0}; GlobalFrame: SAFE PROC [link: ControlLink] RETURNS [GlobalFrameHandle]; GlobalFrameAndEntryPoint: SAFE PROC [link: ControlLink] RETURNS [gf: GlobalFrameHandle, ep: CARDINAL]; Codebase: PROC [frame: GlobalFrameHandle] RETURNS [PrefixHandle] = INLINE { c: FrameCodeBase _ frame.code; c.out _ FALSE; RETURN[c.cseg] }; Alloc: PROC [FrameSizeIndex] RETURNS [POINTER] = MACHINE CODE {zALLOC}; Free: PROC [POINTER] = MACHINE CODE {zFREE}; ConditionPointer: TYPE = LONG POINTER TO CONDITION; ShortConditionPointer: TYPE = POINTER TO CONDITION; MonitorPointer: TYPE = LONG POINTER TO MONITORLOCK; ShortMonitorPointer: TYPE = POINTER TO MONITORLOCK; PsbHandleToIndex: SAFE PROC [handle: PsbHandle] RETURNS [PsbIndex] = TRUSTED INLINE {RETURN[LOOPHOLE[handle, CARDINAL]/SIZE[ProcessStateBlock]]}; PsbIndexToHandle: SAFE PROC [index: PsbIndex] RETURNS [PsbHandle] = TRUSTED INLINE {RETURN[LOOPHOLE[index*SIZE[ProcessStateBlock]]]}; PsbIndexToProcess: SAFE PROC [index: PsbIndex] RETURNS [PROCESS] = TRUSTED INLINE {RETURN[LOOPHOLE[index]]}; ProcessToPsbIndex: SAFE PROC [process: PROCESS] RETURNS [PsbIndex] = TRUSTED INLINE {RETURN[LOOPHOLE[process]]}; Enter: PROC [ShortMonitorPointer] RETURNS [success: BOOL] = MACHINE CODE {zME}; LongEnter: PROC [MonitorPointer] RETURNS [success: BOOL] = MACHINE CODE {zME}; Exit: PROC [ShortMonitorPointer] = MACHINE CODE {zMXD}; LongExit: PROC [MonitorPointer] = MACHINE CODE {zMXD}; Wait: PROC [ShortMonitorPointer, ShortConditionPointer, --timeout:--CARDINAL] = MACHINE CODE {zMXW}; LongWait: PROC [MonitorPointer, ConditionPointer, --timeout:--CARDINAL] = MACHINE CODE {zMXW}; ReEnter: PROC [ShortMonitorPointer, ShortConditionPointer] RETURNS [success: BOOL] = MACHINE CODE {zMRE}; LongReEnter: PROC [MonitorPointer, ConditionPointer] RETURNS [success: BOOL] = MACHINE CODE {zMRE}; Notify: PROC [ShortConditionPointer] = MACHINE CODE {zNOTIFY}; LongNotify: PROC [ConditionPointer] = MACHINE CODE {zNOTIFY}; Broadcast: PROC [ShortConditionPointer] = MACHINE CODE {zBCAST}; LongBroadcast: PROC [ConditionPointer] = MACHINE CODE {zBCAST}; Requeue: PROC [from: QueueHandle, to: QueueHandle, p: PsbHandle] = MACHINE CODE {zREQUEUE}; EnableAndRequeue: PROC [from: QueueHandle, to: QueueHandle, p: PsbHandle] = MACHINE CODE { zDWDC; zREQUEUE; }; DisableInterrupts: PROC = MACHINE CODE {zIWDC}; EnableInterrupts: PROC = MACHINE CODE {zDWDC}; AllocateNakedCondition: PROC RETURNS [cv: ConditionPointer, mask: WORD]; DeallocateNakedCondition: PROC [cv: ConditionPointer]; WriteMDS: PROC [mdsi: CARDINAL] = MACHINE CODE {zWR, MDSreg}; ReadPSB: PROC RETURNS [currentProcess: PsbHandle] = MACHINE CODE {zRR, PSBreg}; WritePSB: PROC [currentProcess: PsbHandle] = MACHINE CODE {zWR, PSBreg}; ReadPTC: SAFE PROC RETURNS [time: Ticks] = TRUSTED MACHINE CODE {zRR, PTCreg}; WritePTC: SAFE PROC [time: Ticks] = TRUSTED MACHINE CODE {zWR, PTCreg}; ReadWDC: SAFE PROC RETURNS [countDisabled: CARDINAL] = TRUSTED MACHINE CODE {zRR, WDCreg}; WriteWDC: PROC [countDisabled: CARDINAL] = MACHINE CODE {zWR, WDCreg}; ReadATP, ReadOTP: PROC RETURNS [ControlLink] = MACHINE CODE {zLLB, 3B}; ReadXTS: SAFE PROC RETURNS [XferTrapStatus] = TRUSTED MACHINE CODE {zRR, XTSreg}; WriteXTS: PROC [XferTrapStatus] = MACHINE CODE {zWR, XTSreg}; ReadXTP: PROC RETURNS [ControlLink] = MACHINE CODE {zLLB, 3}; END. ΨPrincOpsUtils.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Levin on September 20, 1983 10:57 am Birrell, July 8, 1983 1:16 pm Russ Atkinson (RRA) February 27, 1985 8:05:00 pm PST Doug Wyatt, February 26, 1985 3:17:11 pm PST Note to the casual reader: The definitions in this interface are primarily intended for use by wizards. General clients should probably look in the "Basics" interface for the operations they need before looking here. Utilities for Basic Data Structures Conversion among various memory size measures The following procedures are coded in an obscure way to avoid invoking software-implemented arithmetic. This will all go away when the commented code sequences are introduced (in Trinity). Conversion among various memory address measures The following procedures are coded to avoid invoking software-implemented arithmetic. Block copying utilities Trinity instructions will make this more efficient in the overlapping case. This will be a machine code procedure in Trinity. Logic utilities (same as in Basics) Long Pointer Manipulation Miscellaneous Utilities for BitBlt and TextBlt (wizards only) Utilities for Xfer data structures (wizards only) Control links Local Frames Global Frames Code segments Allocation Vector Utilities for Process data structures (wizards only) Process Data Area access Monitors and Condition Variables Note: this depends on having one instruction after enabling. Interrupts This procedure allocates one of the sixteen naked notify condition variables, initializes it with the default timeout, and returns a long pointer and wakeup mask with an appropriate bit set. This procedure deallocates a naked notify condition variable previously allocated with AllocateNakedCondition. Utilities for Virtual Memory Map (wizards only) Note: these utilities have been moved to VMInternal and BootFile. They need to exist in two versions to allow for running on different machines. Miscellaneous (wizards only) Κ – "Cedar" style˜codešœ™Kšœ Οmœ1™—Kšœžœ˜(Kšžœ˜K˜K˜—š‘œžœ ˜Kšœžœžœ ˜—K˜š œžœžœžœžœžœžœ ˜\Kšœžœ˜ š œžœžœž œžœ˜(Kšœžœžœ4˜D—Kšœžœ˜+Kšžœ˜Kšœ˜K˜—š œžœ žœ žœ žœ žœžœžœ ž œ žœ žœžœ žœ˜θKšœžœžœ˜!—K™—šœ2™2Kšœ ™ K™š  œžœžœ˜)Kšœžœžœ˜$K˜—š  œžœ˜!Kšœžœžœ˜$K˜—š  œžœžœžœžœ˜5Kš œžœžœžœžœ˜DK˜—K™Kšœ ™ K™š œžœžœ˜*Kšœžœ˜K˜—š œžœ˜"Kšœžœ˜K˜—š  œžœžœ˜(Kšœžœžœ ˜K˜—š œžœžœžœ˜KKšœžœžœ˜šžœžœž˜Kšžœžœžœ˜&Kšžœ˜—Kšž˜K˜K˜—š  œžœžœ+žœ˜[Kšœžœžœžœ˜)K˜—K™Kšœ ™ K˜š  œžœžœ˜/Kšœžœžœ ˜K˜—š  œžœžœžœ˜GK˜—š  œžœžœžœžœ˜gK˜—K™K™ K™š œžœžœ˜@Kšœžœ*žœžœ ˜JK˜—K˜Kšœ™K™š œžœžœžœ˜.Kšœžœžœ ˜K˜—š œžœžœ˜Kšœžœžœ ˜K˜——šœ5™5Kš œžœžœžœžœž œ˜3Kš œžœžœžœž œ˜3Kš œžœžœžœžœž œ˜3Kš œžœžœžœž œ˜3K˜Kšœ™K™š œžœžœžœ ˜BKš œžœžœžœžœ žœžœ˜NK˜—š œžœžœžœ ˜AKš œžœžœžœžœžœ˜CK˜—š  œžœžœžœžœ˜@Kš œžœžœžœžœ ˜+K˜—š  œžœžœ žœžœ ˜BKš œžœžœžœžœ ˜-—K˜Kšœ ™ K˜š œžœžœ žœ˜9Kšœžœžœ˜K˜—š  œžœžœ žœ˜8Kšœžœžœ˜K˜—š œžœ˜ Kšœžœžœ˜K˜—š œžœ˜Kšœžœžœ˜K˜—š œžœ.Οc žœ˜MKšœžœžœ˜K˜—š œžœ$’ žœ˜GKšœžœžœ˜K˜—š œžœ-žœ žœ˜RKšœžœžœ˜K˜—š  œžœ#žœ žœ˜LKšœžœžœ˜K˜—š œžœ˜$Kšœžœžœ ˜K˜—š  œžœ˜#Kšœžœžœ ˜K˜—š  œžœ˜'Kšœžœžœ ˜K˜—š  œžœ˜&Kšœžœžœ ˜K˜—š œžœ3˜@Kšœžœžœ ˜K˜—š œžœ3˜IKšœžœžœ˜Kšœ<™