diff options
Diffstat (limited to 'dma')
-rw-r--r-- | dma/nwl_dma.h | 3 | ||||
-rw-r--r-- | dma/nwl_engine_buffers.h | 34 |
2 files changed, 37 insertions, 0 deletions
diff --git a/dma/nwl_dma.h b/dma/nwl_dma.h index d5068e2..f87c68f 100644 --- a/dma/nwl_dma.h +++ b/dma/nwl_dma.h @@ -9,6 +9,8 @@ pcilib_dma_context_t *dma_nwl_init(pcilib_t *ctx, pcilib_dma_modification_t type, void *arg); void dma_nwl_free(pcilib_dma_context_t *vctx); +int dma_nwl_get_status(pcilib_t *ctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers); + int dma_nwl_enable_irq(pcilib_dma_context_t *vctx, pcilib_irq_type_t type, pcilib_dma_flags_t flags); int dma_nwl_disable_irq(pcilib_dma_context_t *vctx, pcilib_dma_flags_t flags); int dma_nwl_acknowledge_irq(pcilib_dma_context_t *ctx, pcilib_irq_type_t irq_type, pcilib_irq_source_t irq_source); @@ -25,6 +27,7 @@ double dma_nwl_benchmark(pcilib_dma_context_t *vctx, pcilib_dma_engine_addr_t dm pcilib_dma_api_description_t nwl_dma_api = { dma_nwl_init, dma_nwl_free, + dma_nwl_get_status, dma_nwl_enable_irq, dma_nwl_disable_irq, dma_nwl_acknowledge_irq, diff --git a/dma/nwl_engine_buffers.h b/dma/nwl_engine_buffers.h index 77484a2..bbafae4 100644 --- a/dma/nwl_engine_buffers.h +++ b/dma/nwl_engine_buffers.h @@ -375,3 +375,37 @@ static int dma_nwl_return_buffer(nwl_dma_t *ctx, pcilib_nwl_engine_description_t info->tail++; if (info->tail == info->ring_size) info->tail = 0; } + +int dma_nwl_get_status(pcilib_t *vctx, pcilib_dma_engine_t dma, pcilib_dma_engine_status_t *status, size_t n_buffers, pcilib_dma_buffer_status_t *buffers) { + size_t i; + nwl_dma_t *ctx = (nwl_dma_t*)vctx; + pcilib_nwl_engine_description_t *info = ctx->engines + dma; + uint32_t bstatus; + + if (!status) return -1; + + status->started = info->started; + status->ring_size = info->ring_size; + status->buffer_size = info->page_size; + status->ring_head = info->head; + status->ring_tail = info->tail; + + if (buffers) { + unsigned char *ring = (unsigned char*)pcilib_kmem_get_ua(ctx->pcilib, info->ring); + + for (i = 0; (i < info->ring_size)&&(i < n_buffers); i++) { + bstatus = NWL_RING_GET(ring, DMA_BD_BUFL_STATUS_OFFSET); + + buffers[i].error = bstatus & (DMA_BD_ERROR_MASK/*|DMA_BD_SHORT_MASK*/); + buffers[i].used = bstatus & DMA_BD_COMP_MASK; + buffers[i].size = bstatus & DMA_BD_BUFL_MASK; + buffers[i].first = bstatus & DMA_BD_SOP_MASK; + buffers[i].last = bstatus & DMA_BD_EOP_MASK; + + ring += PCILIB_NWL_DMA_DESCRIPTOR_SIZE; + } + } + + return 0; +} + |