English
Language : 

MC68030 Datasheet, PDF (355/602 Pages) Motorola, Inc – ENHANCED 32-BIT MICROPROCESSOR
Memory Management Unit
These routines provide many of the functions required for the memory management
services of an operating system, but a complete memory management system requires a
complementary function for each routine. The complementary function usually performs the
same steps in the reverse order. The complement of GetVirtual could be ReturnVirtual; for
SwapInPage, the complement might be SwapOutPage. These counterparts can be derived
to perform similar steps in the reverse order.
9.10.2 Allocation Routines
This section describes the central routine Vallocate, which user programs call to obtain
memory. In this section (and the next), a loose high-level language syntax is used for the
code. The code takes many liberties to enhance readability. For example, the code assigns
descriptive strings for return status values. These strings typically represent binary values.
Also, the code uses empty brackets to represent obvious subscripts in loops that scan
tables. In such a loop, the subscript on the second line is obvious:
for Upper-Table-Index=1 to 31 do
if Upper-Table [Upper-Table-Index].Status=invalid then ...
In the code shown here, the second line is:
if Upper-Table [].Status=invalid then ...
The code uses flag operations that are assumed to be defined elsewhere in the system.
They may imply more complex operations than bit manipulations. For example, page table
status of invalid virgin can be implemented with an invalid descriptor instead of the page
descriptor, and a software flag bit in the descriptor that indicates the page is allocated but
has never been used (the paging device has no page image).
Vallocate has a single input parameter, the required memory size in bytes. It returns status
information and the virtual address of the start of the area (if the memory is allocated). To
simplify the routine, it always returns a multiple of the system page size and never allocates
a block that crosses a 16-Mbyte boundary. It could allocate a portion of a page by
implementing a control structure to subdivide a page, but, if the control structure were within
the allocated page, the user could corrupt it. The block could cross a 16-Mbyte boundary if
the routine included code to keep track of consecutive free blocks when scanning the lower
level tables, each of which represents 16 Mbytes of address space. Once the total area is
located, Vallocate allocates the consecutive blocks and returns the address of the lowest
block.
The 32 upper level table entries are long pointer types; each represents 16 Mbytes of virtual
address space. Each entry is either invalid (has no lower page tables) or allocated (has
lower page tables and a limit field that defines the table size). By convention, the first entry
maps the supervisor address space and has supervisor protection. The routine never
modifies this first entry. The 31 entries after the first are available to be allocated as user
address space.
MOTOROLA
MC68030 USER’S MANUAL
9-67