Address space interfaces
The VM extension provides two types of address spaces,
AddressSpace.T
and Space.T.
AddressSpace.T provides the reservation of
an address range, and mapping and unmapping of a memory object on
the address space.
The
Space.T is a subtype of AddressSpace.T.
Thus, it supports all the services that AddressSpace.T
provides. In addition to them, Space.T provides reading and
writing on it.
AddressSpace.T
Below are the methods provided by
AddressSpace.T object.
- init(name: TEXT): T;
- destroy();
- Initializes and destroys the address space.
-
allocate(VAR pageNum: PageNumber; numPages: PageCount; anyWhere: BOOLEAN)
RAISES {VMError.E};
- deallocate(pageNum: PageNumber; numPages: PageCount)
RAISES {VMError.E};
- These methods reserve or unreserve
the virtual address region without allocating
memory.
They are used to reserve a certain region for later use.
- map(pageNum: PageNumber; numPages: PageCount; mObj: MemoryObject.T;
mOff: PageNumber; lazy := FALSE) RAISES {VMError.E};
-
map maps the region
mOff to mOff+numPages
of the memory object mObj
on the virtual address pageNum to
pageNum + numPages. mOff, pageNum,
and numPages are all specified in machine MMU page
unit. On Alpha, the page size is 8192 bytes.
The region pageNum to pageNum + numPages must
be reserved beforehand using allocate
- foo         bar unmap(pageNum: PageNumber; numPages: PageCount)
RAISES {VMError.E};
- Undos the previous
map.
- clear() RAISES {VMError.E};
- Unmaps all the memory objects mapped on the address space.
Space.T
- PROCEDURE Create(): T;
- PROCEDURE Destroy(space: T);
- Create and destroy an address space.
- PROCEDURE Duplicate(space: T): T RAISES {VMError.E};
- Create a copy of the space
Note: no copy on write now. Everything is copied eagerly.
- PROCEDURE Allocate(space: T; VAR addr: VirtAddr.Address; size: VirtAddr.Size;
anywhere: BOOLEAN := FALSE): VirtAddr.T
RAISES {VMError.E};
- PROCEDURE Deallocate(space:T;v: VirtAddr.T := NIL;
addr: VirtAddr.Address; size: VirtAddr.Size): VirtAddr.T
RAISES {VMError.E};
- These two allocates a memory on the specified region.
Note that unlike
AddressSpace.allocate,
Allocate actually allocates a memory
on the region.
-
PROCEDURE Read(space: T; fromaddr: VirtAddr.Address;
VAR to: ARRAY OF CHAR;
size := -1) RAISES {VMError.E};
-
PROCEDURE Write(space: T; READONLY from: ARRAY OF CHAR;
to : VirtAddr.Address;
size := -1) RAISES {VMError.E};
- These procedures reads or writes the specified region.
Page faults may happen.
If size is ommitted, it is assumed to be
NUMBER(to) or NUMBER(from).
-
PROCEDURE Protect(space: T; v: VirtAddr.T := NIL; addr: VirtAddr.Address;
size: VirtAddr.Size; prot: Protection
) RAISES {VMError.E};
-
This procedure changes the protection mode.