summaryrefslogtreecommitdiffstats
path: root/pcilib/irq.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-04-24 05:35:48 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-04-24 05:35:48 +0200
commitdcd8ad63316eac672492bc18112bbbb52811c3fc (patch)
tree321ed207442ebfe9b1feb8375de03847ed2e2de3 /pcilib/irq.c
parent5f6fb4e4e77f121e0756744df8498520d4deddb8 (diff)
downloadpcitool-dcd8ad63316eac672492bc18112bbbb52811c3fc.tar.gz
pcitool-dcd8ad63316eac672492bc18112bbbb52811c3fc.tar.bz2
pcitool-dcd8ad63316eac672492bc18112bbbb52811c3fc.tar.xz
pcitool-dcd8ad63316eac672492bc18112bbbb52811c3fc.zip
More structural changes to get ready for stand-alone event engines
Diffstat (limited to 'pcilib/irq.c')
-rw-r--r--pcilib/irq.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/pcilib/irq.c b/pcilib/irq.c
new file mode 100644
index 0000000..3d387bb
--- /dev/null
+++ b/pcilib/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_hw_source_t source, pcilib_timeout_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_hw_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;
+}
+
+