Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Memory /
Chapter 3 - Virtual Memory Manager / Virtual Memory Manager Reference
Routines / Virtual Memory Management


GetPhysical

To translate logical addresses into their corresponding physical addresses, use the GetPhysical function.

FUNCTION GetPhysical (VAR addresses: LogicalToPhysicalTable;
                        VAR physicalEntryCount: LongInt): OSErr;
addresses
A translation table. On entry, set the logical field of this record to the block of memory to translate. On exit, the physical field of this record holds the corresponding physical address blocks.
physicalEntryCount
The number of physical entries to translate. On entry, set this field to 0 if you want GetPhysical to return the number of table entries needed to translate the entire logical address range.
DESCRIPTION
The GetPhysical function translates a logical address range into its corresponding physical address ranges. The logical field of the addresses translation table specifies the logical address range to be translated. GetPhysical translates up to the size of the physical table or until it completes the translation, whichever occurs first.

If you call GetPhysical with the physicalEntryCount parameter set to 0, it returns in physicalEntryCount the number of table entries needed to translate the entire address range. In this case, the translation table specified by the addresses parameter is unchanged.

If you call GetPhysical with the physicalEntryCount parameter set to a number greater than 0, it returns in the physical field of the addresses translation table an array specifying the physical blocks that correspond to the logical address specified in the logical field. In the physicalEntryCount parameter, GetPhysical returns the number of entries in that array (which may be fewer than were asked for). If the physical field of the translation table was not large enough to contain all the physical blocks corresponding to the logical block, GetPhysical updates the fields of the logical memory block to reflect the remaining number of bytes in the logical range
left to translate (count field) and the next address in the logical address range to translate (start field).

Note
The logical address range must be locked to ensure validity of the translation data.
SPECIAL CONSIDERATIONS
The GetPhysical function as currently implemented under virtual memory supports only logical RAM. You cannot use GetPhysical to translate addresses in the address spaces of the ROM, I/O devices, or NuBus slots. Some Macintosh computers map a portion of the physical RAM into NuBus space, to simulate the presence of a video expansion card. GetPhysical returns the result code paramErr if you attempt to read that memory.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for the GetPhysical function are
Trap macro Selector
_MemoryDispatchA0Result$0005

The registers on entry and exit for this routine are
Registers on entry
D0Selector code
A0Pointer to a translation table
A1physicalEntryCount in table
Registers on exit
A0physicalEntryCount translated
D0Result code

RESULT CODES
noErr0No error
paramErr-50Error in parameter list
notLockedErr-623Specified range of memory is not locked
interruptsMaskedErr-624Called with interrupts masked
SEE ALSO
See "Mapping Logical to Physical Addresses," beginning on page 3-16, for a method of calling GetPhysical to translate addresses to be sent to a NuBus master card.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996