summaryrefslogtreecommitdiffstats
path: root/cli.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-17 06:25:14 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-17 06:25:14 +0200
commitec5fd54c7559392139fa704a57185f4d4244dfde (patch)
tree05c138b1d5a350f5454a1a18bd051546e7cf8632 /cli.c
parent112030c40f88dde281073e00e4c24cc48daa99d2 (diff)
downloadpcitool-ec5fd54c7559392139fa704a57185f4d4244dfde.tar.gz
pcitool-ec5fd54c7559392139fa704a57185f4d4244dfde.tar.bz2
pcitool-ec5fd54c7559392139fa704a57185f4d4244dfde.tar.xz
pcitool-ec5fd54c7559392139fa704a57185f4d4244dfde.zip
Few fixes
Diffstat (limited to 'cli.c')
-rw-r--r--cli.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/cli.c b/cli.c
index 924fd5b..8cdab0c 100644
--- a/cli.c
+++ b/cli.c
@@ -894,37 +894,46 @@ int StartStopDMA(pcilib_t *handle, pcilib_model_description_t *model_info, pcil
int err;
pcilib_dma_engine_t dmaid;
- if (dma_direction&PCILIB_DMA_FROM_DEVICE) {
- if (dma == PCILIB_DMA_ENGINE_ADDR_INVALID) {
- if (start) Error("DMA engine should be specified");
- dmaid = PCILIB_DMA_ENGINE_INVALID;
- } else {
- dmaid = pcilib_find_dma_by_addr(handle, PCILIB_DMA_FROM_DEVICE, dma);
- if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (C2S %lu) is specified", dma);
+ if (dma == PCILIB_DMA_ENGINE_ADDR_INVALID) {
+ const pcilib_dma_info_t *dma_info = pcilib_get_dma_info(handle);
+
+ if (start) Error("DMA engine should be specified");
+
+ for (dmaid = 0; dma_info->engines[dmaid]; dmaid++) {
+ err = pcilib_start_dma(handle, dmaid, 0);
+ if (err) Error("Error starting DMA Engine (%s %i)", ((dma_info->engines[dmaid]->direction == PCILIB_DMA_FROM_DEVICE)?"C2S":"S2C"), dma_info->engines[dmaid]->addr);
+ err = pcilib_stop_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
+ if (err) Error("Error stopping DMA Engine (%s %i)", ((dma_info->engines[dmaid]->direction == PCILIB_DMA_FROM_DEVICE)?"C2S":"S2C"), dma_info->engines[dmaid]->addr);
}
+ return 0;
+ }
+
+ if (dma_direction&PCILIB_DMA_FROM_DEVICE) {
+ dmaid = pcilib_find_dma_by_addr(handle, PCILIB_DMA_FROM_DEVICE, dma);
+ if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (C2S %lu) is specified", dma);
+
if (start) {
err = pcilib_start_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
if (err) Error("Error starting DMA engine (C2S %lu)", dma);
} else {
+ err = pcilib_start_dma(handle, dmaid, 0);
+ if (err) Error("Error starting DMA engine (C2S %lu)", dma);
err = pcilib_stop_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
if (err) Error("Error stopping DMA engine (C2S %lu)", dma);
}
}
-
+
if (dma_direction&PCILIB_DMA_TO_DEVICE) {
- if (dma == PCILIB_DMA_ENGINE_ADDR_INVALID) {
- if (start) Error("DMA engine should be specified");
- dmaid = PCILIB_DMA_ENGINE_INVALID;
- } else {
- dmaid = pcilib_find_dma_by_addr(handle, PCILIB_DMA_TO_DEVICE, dma);
- if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (S2C %lu) is specified", dma);
- }
+ dmaid = pcilib_find_dma_by_addr(handle, PCILIB_DMA_TO_DEVICE, dma);
+ if (dmaid == PCILIB_DMA_ENGINE_INVALID) Error("Invalid DMA engine (S2C %lu) is specified", dma);
if (start) {
err = pcilib_start_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
if (err) Error("Error starting DMA engine (S2C %lu)", dma);
} else {
+ err = pcilib_start_dma(handle, dmaid, 0);
+ if (err) Error("Error starting DMA engine (S2C %lu)", dma);
err = pcilib_stop_dma(handle, dmaid, PCILIB_DMA_FLAG_PERSISTENT);
if (err) Error("Error stopping DMA engine (S2C %lu)", dma);
}