Function - Map the specified memory object to a region of virtual memory.
[in task send right]
The port for the task in whose address space the
memory object is to be mapped.
[pointer to in/out scalar]
The starting address for the mapped object.
The mapped object will start at the beginning of the page containing
address. If there is not enough room following the address, the kernel
does not map the object. The kernel returns the starting address
actually used for the mapped object.
The number of bytes to allocate for the object. The kernel
rounds this number up to an integral number of virtual pages.
Alignment restrictions for starting address. Bits turned on in
the mask will not be turned on in the starting address.
Placement indicator. The valid values are:
The kernel allocates the region in the next unused space that
is sufficient within the address space. The kernel returns the
starting address actually used in address.
The kernel allocates the region starting at address unless that
space is already allocated.
[in memory-object send right]
The port naming the
memory object. If MEMORY_OBJECT_NULL is
specified, the kernel allocates zero-filled memory, as with vm_allocate.
An offset within the memory object, in bytes. The kernel
maps address to the specified offset.
Copy indicator. If true, the kernel copies the region of the
memory object to the specified task's address space. If false, the region
is directly mapped.
The initial current protection for the region. Valid values are
obtained by or'ing together the following values:
Allows read access.
Allows write access.
Allows execute access.
The maximum protection for the region. Values are the same
as for cur_protection.
The initial inheritance attribute for the region. Valid values
Allows child tasks to share the region.
Gives child tasks a copy of the region.
Provides no access to the region for child tasks.
The vm_map function maps a portion of the specified
memory object into the
virtual address space belonging to target_task. The target task
can be the calling
task or another task, identified by its task kernel port.
The portion of the memory object mapped is determined by offset
and size. The
kernel maps address to the offset, so that an access to the memory
starts at the offset in the object.
The mask parameter specifies additional alignment restrictions on
the kernel's selection of the starting address. Uses for this mask include:
Forcing the memory address alignment for a mapping to be the same as the
alignment within the memory object.
Quickly finding the beginning of an allocated region by performing bit
arithmetic on an address known to be in the region.
Emulating a larger virtual page size.
The cur_protection, max_protection, and inheritance
parameters set the
protection and inheritance attributes for the mapped object.
As a rule, at least the
maximum protection should be specified so that a server can make
a restricted (for
example, read-only) mapping in a client atomically. The current
inheritance parameters are provided for convenience so that the
caller does not
have to call vm_inherit and vm_protect separately.
The same memory object can be mapped more than once and by more than one
task. If an object is mapped by multiple tasks, the kernel maintains
for all the mappings if they use the same page alignment for offset
and are on
the same host. In this case, the virtual memory to which the
object is mapped is
shared by all the tasks. Changes made by one task in its address space are
visible to all the other tasks.
The call will not return until the
memory object is ready for
vm_map allocates a region in a task's address space
and maps the specified
memory object to this region. vm_allocate allocates
a zero-filled temporary
region in a task's address space.
Before a memory object can be mapped, a port naming it must be acquired from
the memory manager serving it.
This interface is machine word length specific because of the virtual address
Do not attempt to map a memory object unless it has been provided by a
memory manager that implements the memory object interface.
If another type of port
is specified, a thread that accesses the mapped virtual memory may become
permanently hung or may receive a memory exception.
There is not enough space in the task's address space to allocate the
new region for the memory object.
max_protection or cur_protection exceeds
that permitted by memory_object.
The memory manager failed to map the memory object.