NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO
#include <mem/chMem.h>int rgnPhysMap(KnCap *actorcap, KnRgnDesc *rgndesc, KnMemoryHandler handler, void *opaque);
MEM_VIRTUAL
The rgnPhysMap function creates a region in the address space of the target actor.
The target actor is specified by actorcap - a pointer to the target actor capability. If actorcap is K_MYACTOR, the address space of the current actor is used. If actorcap is K_SVACTOR, the region is allocated in the supervisor address space and isn't attached to any particular supervisor actor; therefore, it can't be implicitly deallocated by performing an actorDelete(2K) on a supervisor actor.
The rgndesc field points to a KnRgnDesc structure containing the specification of the region to be created as described in rgnAllocate (2K).
The caller can specify any of the rgndesc->options as described in rgnAllocate (2K); with the exceptions that the K_FILLZERO flag is ignored, and the K_RESERVED flag is prohibited.
The handler argument specifies a memory handler which is attached to the newly created region. When access to a virtual page of the region is required (for example, a fault happens), the kernel invokes the memory handler. The handler returns the physical address to be mapped and the mapping attributes to the required virtual address.
The memory handler interface is machine-dependent. The kernel on i386/i486 hardware defines the following handler interface:
#include <mem/chMem.h> #include <mem/f_chMem.h> int handler (opaque, offset, paddr, access, cntlBits) void* opaque ; VmOffset offset ; PhysAddr *paddr ; VmFlags access ; PteCntlBits *cntlBits ; |
Where opaque is an input argument specified by the opaque argument of rgnPhysMap.;offset is another input argument which specifies the required page offset within the region. The paddr output argument specifies the physical address to be mapped. The last input argument is access, which defines the type of access rights required. If the K_WRITABLE bit is set in the access argument, write access is required. The second output argument, cntlBitsspecifies the mapping control bits as defined in the Intel386/Intel486 Programmer's Reference Manual. The valid bits are the following:
PTE_PRESENT (0x01)
PTE_READ_WRITE (0x02)
PTE_USER_SUPERVISOR (0x04)
PTE_WRITE_TRANSPARENT (0x08)
PTE_CACHE_DISABLE (0x10)
As the the memory handler is designed for mapping I/O devices it doesn't include a feature to detect and write back the data modified in the region.
If successful K_OK is returned, otherwise a negative error code is returned.
Some of the provided arguments are outside the caller's address space.
An inconsistent actor capability was given.
actorcap does not specify a reachable actor.
rgndesc->startAddr is not page-aligned.
Triedto create a region outside the valid range for the address space of an actor as returned by vmStat(2K).
rgndesc->size is zero.
The K_ANYWHERE option was specified and there is insufficient room available in the address space to create the region.
The K_RESTRICTIVE option was specified and there is insufficient room in the target address range.
The created region overlaps an existing region.
The system is out of resources.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO