NAME | SYNOPSIS | FEATURES | EXTENDED DESCRIPTION | ATTRIBUTES | SEE ALSO
#include <dki/f_dki.h>KnError svPhysMap(KnPhMemChunk * chunk, PteCntlBits cntlBits);
typedef struct { PhAddr paddr; /* physical start address */ PhSize psize; /* size */ VmAddr vaddr; /* virtual start address */ } KnPhMemChunk;
DKI
The microkernel provides services to allow device drivers to map physical space to virtual memory space. These services should be used mainly by primary bus drivers to map bus I/O space, or DMA memory.
svPhysMap
svPhysMap allocates a range of virtual addresses within the supervisor address space and maps it to a given range of physical addresses.
The chunk argument points to the KnPhMemChunk structure.
The paddr and psize fields specify the chunk of physical memory being mapped to.
The vaddr field is used by svPhysMap to return the virtual address to which the physical one is mapped.
For Intel ix86 family processor, the cntlBits argument is a direct mapping of the Page Control bits of Page Table Entries, as described in the Intel 386/486 Programming Reference Manual. Therefore, the cntlBits argument should be constructed by "oring" the following values:
The mapped memory must be present in physical memory.
The mapped memory allows write accesses to be performed.
The mapped memory can be used in user space.
The memory is mapped with the Write-Through attribute (bit PWT). Thus, a store operation updates the cache if necessary, and in addition the update is written to memory.
The memory is mapped with caching disabled (bit PCD). Thus, memory accesses go to main memory, bypassing the caches.
On success K_OK is returned, otherwise a negative error code is returned:
The system is out of memory.
The psize argument is equal to zero.
svPhysUnmap
svPhysUnmap unmaps the physical memory chunk previously mapped by svPhysMap . The chunk argument points to the KnPhMemChunk structure which specifies the virtual and physical chunk start addresses and the chunk size. Note that the paddr and psize fields must have the values previously specified in svPhysMap . The vaddr field must have the value previously returned by svPhysMap (typically, a driver uses the same KnPhMemChunk structure for the svPhysMap and svPhysUnmap calls and the structure fields are not modified by the driver once svPhysMap is done).
vmMapToPhys
vmMapToPhys maps a given physical memory chunk to the target actor address space.
The actor argument specifies the target actor capability. If actor is K_MYACTOR , the address space of the current actor is used. If actor is K_SVACTOR , the supervisor address space is used.
The chunk argument points to the KnPhMemChunk structure which specifies the physical and virtual chunk start addresses and the chunk size. The specified virtual address range must be allocated using the K_RESERVED option (see rgnAllocate (2K)) prior to the invocation of vmMapToPhys . The specified actor can be a supervisor actor as well as a user actor. The mapping produced by vmMapToPhys can only be invalidated by rgnFree .
vaddr , paddr and psize must be page-aligned.
For Intel x86 family processors, the cntlBits is defined in the same way as for the svPhysMap routine above.
On success K_OK is returned, otherwise a negative error code is returned:
The actor argument points to the outside of the caller's address space.
An inconsistent actor capability was provided.
actorcap does not specify a reachable actor.
The system is out of memory.
The psize argument is equal to zero.
vaddr or paddr or psize is not page-aligned.
Some or all addresses from the target virual address range are out of a region allocated with the K_RESERVED option (for performance reasons the current implementation does not guarantee that any attempt to map a physical address to a virtual address out of a region allocated with K_RESERVED option would effectively produce a K_EADDR error).
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | FEATURES | EXTENDED DESCRIPTION | ATTRIBUTES | SEE ALSO