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. The DMA handle is usually allocated in the driver's attach() entry point that uses ddi_dma_alloc_handle(9F). The ddi_dma_alloc_handle() function takes the device information that is referred to by dip and the device's DMA attributes described by a ddi_dma_attr(9S) structure as parameters. The ddi_dma_alloc_handle() function 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);

where:

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.