bzr branch
http://suren.me/webbzr/alps/pcitool
58
by Suren A. Chilingaryan
Wait for the completion of DMA operations during writes |
1 |
#include <stdio.h> |
2 |
#include <string.h> |
|
3 |
#include <strings.h> |
|
4 |
#include <stdlib.h> |
|
5 |
#include <stdint.h> |
|
6 |
#include <stdarg.h> |
|
7 |
#include <fcntl.h> |
|
8 |
#include <unistd.h> |
|
9 |
#include <sys/ioctl.h> |
|
10 |
#include <sys/mman.h> |
|
11 |
#include <arpa/inet.h> |
|
12 |
#include <errno.h> |
|
13 |
#include <assert.h> |
|
14 |
||
15 |
#include "pci.h" |
|
16 |
||
17 |
#include "tools.h" |
|
18 |
#include "error.h" |
|
19 |
||
88
by Suren A. Chilingaryan
IRQ acknowledgement support in the engine API |
20 |
int pcilib_wait_irq(pcilib_t *ctx, pcilib_irq_hw_source_t source, pcilib_timeout_t timeout, size_t *count) { |
58
by Suren A. Chilingaryan
Wait for the completion of DMA operations during writes |
21 |
int err; |
22 |
||
23 |
interrupt_wait_t arg = { 0 }; |
|
24 |
||
25 |
arg.source = source; |
|
26 |
arg.timeout = timeout; |
|
27 |
||
28 |
if (count) arg.count = 1; |
|
29 |
||
30 |
err = ioctl(ctx->handle, PCIDRIVER_IOC_WAITI, &arg); |
|
31 |
if (err) { |
|
32 |
pcilib_error("PCIDRIVER_IOC_WAITI ioctl have failed"); |
|
33 |
return PCILIB_ERROR_FAILED; |
|
34 |
}
|
|
35 |
||
36 |
if (!arg.count) return PCILIB_ERROR_TIMEOUT; |
|
37 |
||
38 |
if (count) *count = arg.count; |
|
39 |
||
40 |
return 0; |
|
41 |
}
|
|
42 |
||
88
by Suren A. Chilingaryan
IRQ acknowledgement support in the engine API |
43 |
int pcilib_clear_irq(pcilib_t *ctx, pcilib_irq_hw_source_t source) { |
58
by Suren A. Chilingaryan
Wait for the completion of DMA operations during writes |
44 |
int err; |
45 |
||
46 |
err = ioctl(ctx->handle, PCIDRIVER_IOC_CLEAR_IOQ, source); |
|
47 |
if (err) { |
|
48 |
pcilib_error("PCIDRIVER_IOC_CLEAR_IOQ ioctl have failed"); |
|
49 |
return PCILIB_ERROR_FAILED; |
|
50 |
}
|
|
51 |
||
52 |
return 0; |
|
53 |
}
|
|
54 |
||
55 |