|Skip Navigation Links|
|Exit Print View|
|man pages section 9: DDI and DKI Kernel Functions Oracle Solaris 11 Express 11/10|
- allocate and free sequentially accessed memory
#include <sys/ddi.h> #include <sys/sunddi.h> int ddi_mem_alloc(dev_info_t *dip, ddi_dma_lim_t *limits, uint_t length, uint_t flags, caddr_t *kaddrp, uint_t *real_length);
void ddi_mem_free(caddr_t kaddr);
A pointer to the device's dev_info structure.
The length in bytes of the desired allocation.
The possible flags 1 and 0 are taken to mean, respectively, wait until memory is available, or do not wait.
On a successful return, *kaddrp points to the allocated memory.
The length in bytes that was allocated. Alignment and padding requirements may cause ddi_mem_alloc() to allocate more memory than requested in length.
The memory returned from a successful call to ddi_mem_alloc().
The ddi_mem_alloc() function allocates memory for DMA transfers and should be used if the device is performing sequential, unidirectional, block-sized and block-aligned transfers to or from memory. This type of access is commonly known as streaming access. The allocation will obey the alignment and padding constraints as specified by the limits argument and other limits imposed by the system.
Note that you must still use DMA resource allocation functions (see ddi_dma_setup(9F)) to establish DMA resources for the memory allocated using ddi_mem_alloc(). ddi_mem_alloc() returns the actual size of the allocated memory object. Because of padding and alignment requirements, the actual size might be larger than the requested size. ddi_dma_setup(9F) requires the actual length.
The ddi_mem_free() function frees up memory allocated by ddi_mem_alloc().
The ddi_mem_alloc() function returns:
Memory successfully allocated.
The ddi_mem_alloc() function can be called from user, interrupt, or kernel context, except when flags is set to 1, in which case it cannot be called from interrupt context.
See attributes(5) for a description of the following attributes: