Writing Device Drivers

Determining Maximum Burst Sizes

Drivers specify the DMA burst sizes their device supports in the dma_attr_burstsizes field of the ddi_dma_attr(9S) structure. This is a bitmap of the supported burst sizes. However, when DMA resources are allocated, the system might impose further restrictions on the burst sizes that may actually be used by the device. The ddi_dma_burstsizes(9F) routine can be used to obtain the allowed burst sizes. It returns the appropriate burst size bitmap for the device. When DMA resources are allocated, a driver can ask the system for appropriate burst sizes to use for its DMA engine.

	#define BEST_BURST_SIZE 0x20 /* 32 bytes */

 	if (ddi_dma_buf_bind_handle(xsp->handle,xsp->bp,flags, xxstart,
 		(caddr_t)xsp, &cookie, &ccount) != DDI_DMA_MAPPED) {
 			/* error handling */
 			return (0);
 	}
	burst = ddi_dma_burstsizes(xsp->handle);
	/* check which bit is set and choose one burstsize to */
 	/* program the DMA engine */
 	if (burst & BEST_BURST_SIZE) {
 		program DMA engine to use this burst size
 	} else {
 		other cases
 	}