Writing Device Drivers

Allocating a DMA Handle

A DMA handle is an opaque object that is used as a reference to subsequently allocated DMA resources. It is usually allocated in the driver's attach entry point using ddi_dma_alloc_handle(9F). ddi_dma_alloc_handle(9F) takes the device information referred to by dip and the device's DMA attributes described by a ddi_dma_attr(9S) structure as parameters. ddi_dma_alloc_handle(9F) has the following syntax:

int ddi_dma_alloc_handle(dev_info_t *dip,
    ddi_dma_attr_t *attr, int (*callback)(caddr_t),
    caddr_t arg, ddi_dma_handle_t *handlep);
dip

Pointer to the device's dev_info structure

attr

Pointer to a ddi_dma_attr(9S) structure as described in DMA Attributes

callback

Address of the callback function for handling resource allocation failures

arg

Argument to be passed to the callback function

handlep

Pointer to a DMA handle to store the returned handle