blob: 6b2164cb7639837298bff8843c522ad45466c095 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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, 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_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;
}
|