DragOpsUtils.mesa
Copyright © 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
Utilities for Basic Data Structures
Conversion among various memory size measures
PagesForWords:
SAFE
PROC [words:
INT]
RETURNS [pages: PageCount]
= TRUSTED INLINE {
RETURN[Basics.ShiftRight[[li[li: words+(wordsPerPage-1)]], logWordsPerPage].li]
};
WordsForPages:
SAFE
PROC [pages: PageCount]
RETURNS [words:
INT]
= TRUSTED INLINE {
RETURN[Basics.ShiftLeft[[li[li: pages]], logWordsPerPage].li]
};
PagesForBytes:
SAFE
PROC [bytes:
INT]
RETURNS [pages: PageCount]
= TRUSTED INLINE {
RETURN[Basics.ShiftRight[[li[li: bytes+(bytesPerPage-1)]], logBytesPerPage].li]
};
BytesForPages:
SAFE
PROC [pages: PageCount]
RETURNS [bytes:
INT]
= TRUSTED INLINE {
RETURN[Basics.ShiftLeft[[li[li: pages]], logBytesPerPage].li]
};
Conversion among various memory address measures
AddressForPageNumber:
SAFE
PROC [page: PageNumber]
RETURNS [address:
LONG
POINTER]
= TRUSTED INLINE {
RETURN[Basics.ShiftLeft[[li[li: page]], logWordsPerPage].lp]
};
PageNumberForAddress:
SAFE
PROC [address:
LONG
POINTER]
RETURNS [page: PageNumber]
= TRUSTED INLINE {
RETURN[Basics.ShiftRight[ [lp[address]], logWordsPerPage].li]
};
Block copying utilities - Moved to Basics
Long Pointer Manipulation - No longer needed
Miscellaneous
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};
Utilities for Stack data structures (wizards only)
To be replaced with things appropriate to Dragon
Control links
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]};
Local Frames
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]]};
Global Frames
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];
Code segments
Codebase: PROC [frame: GlobalFrameHandle] RETURNS [PrefixHandle]
= INLINE { c: FrameCodeBase ← frame.code; c.out ← FALSE; RETURN[c.cseg] };
Allocation Vector
Alloc: PROC [FrameSizeIndex] RETURNS [POINTER]
= MACHINE CODE {zALLOC};
Free: PROC [POINTER]
= MACHINE CODE {zFREE};