Device memory #
Device memory capabilities hold a range of physical memory addresses from which pages may be allocated for the purpose of memory-mapped I/O. Device memory capabilities may be subdivided into smaller device memory capabilities, and userspace must strategically choose the size of the sub-capabilities in a manner appropriate for the allocation the desired physical memory addresses.
For example, consider a device memory capability which represents the physical memory range 0x4000000-0x8000000. If the user wants to allocate a page for memory mapped I/O at address 0x4800000, the user must first allocate a device memory capability of size 0x8000000, then allocate a page. The former may be used to allocate additional memory between 0x4000000-0x4800000, and the latter may be mapped to access the device at address 0x4800000.
Device memory maintains a “watermark” to store the highest allocated physical address. When all capabilities allocated from a device memory capability are destroyed, the watermark is reset and the user may allocate pages from the start of its physical address range again.
Operations #
DevMem::ALLOCATE #
Allocates an object from the invoked device memory capability.
This operation is atomic; if insufficient memory is available then no objects will be allocated. However, the value of the out parameter in the caller’s IPC buffer is undefined in such cases.
Parameters #
Register | Details |
---|---|
r0 | Capability type (DEVMEM or PAGE) |
r1 | Object size (optional) |
Note: The object size is the number of pages to allocate when sub-dividing device memory.
Capabilities #
CSlot | Usage | Type | Details |
---|---|---|---|
… | Out | CAddr | Capabilities to allocate |
Note: If more than one “out” capability address is provided, more than one page may be allocated at once at successive physical memory addresses.
Results #
Error code | Meaning |
---|---|
NONE | Success |
NOMEM | Insufficient memory to allocate objects |
INVALID_CTYPE | An attempt was made to allocate objects other than DEVMEM or PAGE |
INVALID_CTYPE | A size parameter was included (PAGE) or omitted (DEVMEM) where the opposite usage was required |
Semantics #
Destroy #
Destroying a memory capability will destroy all objects allocated from that capability.