#include "driver.h" int alloc_dmabuf(struct aureal_state *softstate) { if (ddi_dma_mem_alloc(softstate->dmahandle, 16384, &dev_sample_attr, DDI_DMA_CONSISTENT, DDI_DMA_DONTWAIT, NULL, (caddr_t*) &softstate->dmadata, &softstate->dmalen, &softstate->accdma) != DDI_SUCCESS) { cmn_err(CE_NOTE, "alloc_dmabuf(): ddi_dma_mem_alloc() failed\n"); return DDI_FAILURE; } if (ddi_dma_addr_bind_handle(softstate->dmahandle, NULL, (caddr_t)softstate->dmadata, 16384, DDI_DMA_RDWR | DDI_DMA_CONSISTENT, DDI_DMA_DONTWAIT, NULL, &softstate->cookie, &softstate->count) != DDI_DMA_MAPPED) { cmn_err(CE_NOTE, "alloc_dmabuf(): ddi_dma_addr_bind_handle() failed\n"); return DDI_FAILURE; } cmn_err(CE_NOTE, "alloc_dmabuf(): len is %d, count is %d, cookie says 0x%x\n", softstate->dmalen, softstate->count, softstate->cookie.dmac_address); } void dealloc_dmabuf(struct aureal_state *softstate) { ddi_dma_unbind_handle(softstate->dmahandle); ddi_dma_mem_free(&softstate->accdma); }