summaryrefslogtreecommitdiffstats
path: root/irq.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-11 03:48:13 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-11 03:48:13 +0200
commit40c61a3b927ce31e05a6eb0d7b36e09e67c6ca97 (patch)
treebaf559a19f5dd348856012d469935b2b29a86de1 /irq.c
parent82167742d62f1cd583d7eb99b356864df70afd8b (diff)
downloadpcitool-40c61a3b927ce31e05a6eb0d7b36e09e67c6ca97.tar.gz
pcitool-40c61a3b927ce31e05a6eb0d7b36e09e67c6ca97.tar.bz2
pcitool-40c61a3b927ce31e05a6eb0d7b36e09e67c6ca97.tar.xz
pcitool-40c61a3b927ce31e05a6eb0d7b36e09e67c6ca97.zip
Wait for the completion of DMA operations during writes
Diffstat (limited to 'irq.c')
-rw-r--r--irq.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/irq.c b/irq.c
new file mode 100644
index 0000000..0154511
--- /dev/null
+++ b/irq.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <arpa/inet.h>
+#include <errno.h>
+#include <assert.h>
+
+#include "pci.h"
+
+#include "tools.h"
+#include "error.h"
+
+int pcilib_wait_irq(pcilib_t *ctx, pcilib_irq_source_t source, size_t timeout, size_t *count) {
+ int err;
+
+ interrupt_wait_t arg = { 0 };
+
+ arg.source = source;
+ arg.timeout = timeout;
+
+ if (count) arg.count = 1;
+
+ err = ioctl(ctx->handle, PCIDRIVER_IOC_WAITI, &arg);
+ if (err) {
+ pcilib_error("PCIDRIVER_IOC_WAITI ioctl have failed");
+ return PCILIB_ERROR_FAILED;
+ }
+
+ if (!arg.count) return PCILIB_ERROR_TIMEOUT;
+
+ if (count) *count = arg.count;
+
+ return 0;
+}
+
+int pcilib_clear_irq(pcilib_t *ctx, pcilib_irq_source_t source) {
+ int err;
+
+ err = ioctl(ctx->handle, PCIDRIVER_IOC_CLEAR_IOQ, source);
+ if (err) {
+ pcilib_error("PCIDRIVER_IOC_CLEAR_IOQ ioctl have failed");
+ return PCILIB_ERROR_FAILED;
+ }
+
+ return 0;
+}
+
+