Important: The information in this document is obsolete and should not be used for new development.
Summary of the Virtual Memory Manager
Pascal Summary
Constants
CONST {Gestalt constants} gestaltVMAttr = 'vm '; {virtual memory attributes} gestaltVMPresent = 0; {bit set if virtual memory present} {default number of physical blocks in a translation table} defaultPhysicalEntryCount = 8; {page states} kPageInMemory = 0; {page is in RAM} kPageOnDisk = 1; {page is on disk} kNotPaged = 2; {address is not paged}Data Types
TYPE PageState = Integer; LogicalToPhysicalTable = {translation table} RECORD logical: MemoryBlock; {logical block} physical: ARRAY[0..defaultPhysicalEntryCount-1] OF MemoryBlock; {equivalent physical blocks} END; MemoryBlock = {memory-block record} RECORD address: Ptr; {start of block} count: LongInt; {size of block} END;Routines
Virtual Memory Management
FUNCTION HoldMemory (address: UNIV Ptr; count: LongInt): OSErr; FUNCTION UnholdMemory (address: UNIV Ptr; count: LongInt): OSErr; FUNCTION LockMemory (address: UNIV Ptr; count: LongInt): OSErr; FUNCTION LockMemoryContiguous (address: UNIV Ptr; count: LongInt): OSErr; FUNCTION UnlockMemory (address: UNIV Ptr; count: LongInt): OSErr; FUNCTION GetPhysical (VAR addresses: LogicalToPhysicalTable; VAR physicalEntryCount: LongInt): OSErr; FUNCTION DeferUserFn (userFunction: ProcPtr; argument: UNIV Ptr): OSErr;Virtual Memory Debugger Support Routines
FUNCTION DebuggerGetMax : LongInt; PROCEDURE DebuggerEnter; PROCEDURE DebuggerExit; FUNCTION PageFaultFatal : Boolean; FUNCTION DebuggerLockMemory (address: UNIV Ptr; count: LongInt): OSErr; FUNCTION DebuggerUnlockMemory (address: UNIV Ptr; count: LongInt): OSErr; PROCEDURE DebuggerPoll; FUNCTION GetPageState (address: UNIV Ptr): PageState;C Summary
Constants
/*Gestalt constants*/ #define gestaltVMAttr 'vm '; /*virtual memory attributes*/ #define gestaltVMPresent 0; /*bit set if virtual memory present*/ /*default number of physical blocks in table*/ enum { defaultPhysicalEntryCount = 8 }; /*page states*/ enum { kPageInMemory = 0, /*page is in RAM*/ kPageOnDisk = 1, /*page is on disk*/ kNotPaged = 2 /*address is not paged*/ };Data Types
typedef short PageState; struct LogicalToPhysicalTable { /*translation table*/ MemoryBlock logical; /*logical block*/ MemoryBlock physical[defaultPhysicalEntryCount]; /*equivalent physical blocks*/ }; typedef struct LogicalToPhysicalTable LogicalToPhysicalTable; struct MemoryBlock { /*memory-block record*/ void *address; /*start of block*/ unsigned long count; /*size of block*/ }; typedef struct MemoryBlock MemoryBlock;Routines
Virtual Memory Management
pascal OSErr HoldMemory (void *address, unsigned long count); pascal OSErr UnholdMemory (void *address, unsigned long count); pascal OSErr LockMemory (void *address, unsigned long count); pascal OSErr LockMemoryContiguous (void *address, unsigned long count); pascal OSErr UnlockMemory (void *address, unsigned long count); pascal OSErr GetPhysical (LogicalToPhysicalTable *addresses, unsigned long *physicalEntryCount); pascal OSErr DeferUserFn (ProcPtr userFunction, void *argument);Virtual Memory Debugger Support Routines
pascal long DebuggerGetMax (void); pascal void DebuggerEnter (void); pascal void DebuggerExit (void); pascal Boolean PageFaultFatal (void); pascal OSErr DebuggerLockMemory (void *address, unsigned long count); pascal OSErr DebuggerUnlockMemory (void *address, unsigned long count); pascal void DebuggerPoll (void); pascal PageState GetPageState (const void *address);Assembly-Language Summary
Data Types
Memory-Block Data Structure
0 address long start of block 4 count 4 bytes size of block Translation Table Data Structure
0 logical 8 bytes logical block 8 physical 64 bytes equivalent physical blocks Trap Macros
Trap Macros Requiring Routine Selectors
_MemoryDispatch_MemoryDispatchA0Result
Selector Routine $0000 HoldMemory $0001 UnholdMemory $0002 LockMemory $0003 UnlockMemory $0004 LockMemoryContiguous _DebugUtil
Selector Routine $0005 GetPhysical
Selector Routine $0000 DebuggerGetMax $0001 DebuggerEnter $0002 DebuggerExit $0003 DebuggerPoll $0004 GetPageState $0005 PageFaultFatal $0006 DebuggerLockMemory $0007 DebuggerUnlockMemory $0008 EnterSupervisorMode Result Codes
noErr 0 No error paramErr -50 Error in parameter list notEnoughMemoryErr -620 Insufficient physical memory notHeldErr -621 Specified range of memory is not held cannotMakeContiguousErr -622 Cannot make specified range contiguous notLockedErr -623 Specified range of memory is not locked interruptsMaskedErr -624 Called with interrupts masked cannotDeferErr -625 Unable to defer additional user functions