summaryrefslogtreecommitdiffstats
path: root/dma.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-10-22 01:44:28 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-10-22 01:44:28 +0200
commita710557ef4f33bc286d8240fff950b974c9d5b01 (patch)
tree4b119f7df96df3f4583e5c47ce32f86dacea306d /dma.c
parent32bd82e4b4748cbe7b4734030dfb135feab4dffc (diff)
downloadpcitool-a710557ef4f33bc286d8240fff950b974c9d5b01.tar.gz
pcitool-a710557ef4f33bc286d8240fff950b974c9d5b01.tar.bz2
pcitool-a710557ef4f33bc286d8240fff950b974c9d5b01.tar.xz
pcitool-a710557ef4f33bc286d8240fff950b974c9d5b01.zip
Provide information about active DMA engines & buffers
Diffstat (limited to 'dma.c')
-rw-r--r--dma.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/dma.c b/dma.c
index 1bab0f9..9527c0b 100644
--- a/dma.c
+++ b/dma.c
@@ -235,7 +235,7 @@ int pcilib_read_dma(pcilib_t *ctx, pcilib_dma_engine_t dma, uintptr_t addr, size
pcilib_dma_read_callback_context_t opts = {
size, buf, 0
};
-
+
err = pcilib_stream_dma(ctx, dma, addr, size, PCILIB_DMA_FLAGS_DEFAULT, PCILIB_DMA_TIMEOUT, pcilib_dma_read_callback, &opts);
if (read_bytes) *read_bytes = opts.pos;
return err;
@@ -325,3 +325,31 @@ double pcilib_benchmark_dma(pcilib_t *ctx, pcilib_dma_engine_addr_t dma, uintptr
return ctx->model_info.dma_api->benchmark(ctx->dma_ctx, dma, addr, size, iterations, direction);
}
+
+int pcilib_get_dma_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 err;
+
+ const pcilib_dma_info_t *info = pcilib_get_dma_info(ctx);
+ if (!info) {
+ pcilib_error("DMA is not supported by the device");
+ return 0;
+ }
+
+ if (!ctx->model_info.dma_api) {
+ pcilib_error("DMA Engine is not configured in the current model");
+ return -1;
+ }
+
+ if (!ctx->model_info.dma_api->status) {
+ memset(status, 0, sizeof(pcilib_dma_engine_status_t));
+ return -1;
+ }
+
+ if (!info->engines[dma]) {
+ pcilib_error("The DMA engine (%i) is not supported by device", dma);
+ return -1;
+ }
+
+ return ctx->model_info.dma_api->status(ctx->dma_ctx, dma, status, n_buffers, buffers);
+
+}