|DDI_DMA_GETWIN(9F)||Kernel Functions for Drivers||DDI_DMA_GETWIN(9F)|
#include <sys/ddi.h> #include <sys/sunddi.h> int ddi_dma_getwin(ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp, ddi_dma_cookie_t *cookiep, uint_t *ccountp);
The caller must first determine the number of DMA windows, N, using ddi_dma_numwin(9F). ddi_dma_getwin() takes a DMA window number from the range [0..N-1] as the parameter win and makes it the current DMA window.
ddi_dma_getwin() allocates and assosciates a number of DMA cookies with handle. To get the total number of cookies, callers should use the ddi_dma_ncookies(9F) function. To get all of the cookies, callers should use the ddi_dma_cookie_iter(9F) or ddi_dma_cookie_get(9F) functions. Callers should pass NULL for cookiep and ccountp. These values are required if using the deprecated ddi_dma_nextcookie(9F) interface, in which case cookiep is filled in with the first ddi_dma_cookie(9S) structure.
ddi_dma_getwin() takes care of underlying resource synchronizations required to shift the window. However accessing the data prior to or after moving the window requires further synchronization steps using ddi_dma_sync(9F).
ddi_dma_getwin() is normally called from an interrupt routine. The first invocation of the DMA engine is done from the driver. All subsequent invocations of the DMA engine are done from the interrupt routine. The interrupt routine checks to see if the request has been completed. If it has, the interrupt routine returns without invoking another DMA transfer. Otherwise, it calls ddi_dma_getwin() to shift the current window and start another DMA transfer.
Writing Device Drivers
|January 18, 2020||OmniOS|