bzr branch
http://darksoft.org/webbzr/alps/pcitool
258
by Suren A. Chilingaryan
Split bar manipulation and fifo operations in stand-alone source and publish kmem and bar headers |
1 |
#define _BSD_SOURCE
|
303
by Suren A. Chilingaryan
Initial integration of XML support |
2 |
#define _DEFAULT_SOURCE
|
258
by Suren A. Chilingaryan
Split bar manipulation and fifo operations in stand-alone source and publish kmem and bar headers |
3 |
#define _POSIX_C_SOURCE 200809L
|
4 |
||
5 |
#include <stdio.h> |
|
6 |
#include <string.h> |
|
7 |
#include <strings.h> |
|
8 |
#include <stdlib.h> |
|
9 |
#include <stdint.h> |
|
10 |
#include <fcntl.h> |
|
11 |
#include <unistd.h> |
|
12 |
#include <sys/ioctl.h> |
|
13 |
#include <sys/mman.h> |
|
14 |
#include <arpa/inet.h> |
|
15 |
#include <errno.h> |
|
16 |
#include <assert.h> |
|
17 |
||
18 |
#include "pcilib.h" |
|
19 |
#include "pci.h" |
|
20 |
#include "tools.h" |
|
21 |
#include "error.h" |
|
22 |
#include "model.h" |
|
23 |
#include "plugin.h" |
|
24 |
#include "bar.h" |
|
25 |
||
26 |
int pcilib_read_fifo(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, uint8_t fifo_size, size_t n, void *buf) { |
|
27 |
int i; |
|
28 |
void *data; |
|
29 |
||
30 |
pcilib_detect_address(ctx, &bar, &addr, fifo_size); |
|
31 |
data = pcilib_map_bar(ctx, bar); |
|
32 |
||
33 |
for (i = 0; i < n; i++) { |
|
345
by Suren A. Chilingaryan
64-bit access to BAR memory |
34 |
pcilib_memcpy(buf + i * fifo_size, data + addr, fifo_size, 1); |
258
by Suren A. Chilingaryan
Split bar manipulation and fifo operations in stand-alone source and publish kmem and bar headers |
35 |
}
|
36 |
||
37 |
pcilib_unmap_bar(ctx, bar, data); |
|
38 |
||
39 |
return 0; |
|
40 |
}
|
|
41 |
||
42 |
int pcilib_write_fifo(pcilib_t *ctx, pcilib_bar_t bar, uintptr_t addr, uint8_t fifo_size, size_t n, void *buf) { |
|
43 |
int i; |
|
44 |
void *data; |
|
45 |
||
46 |
pcilib_detect_address(ctx, &bar, &addr, fifo_size); |
|
47 |
data = pcilib_map_bar(ctx, bar); |
|
48 |
||
49 |
for (i = 0; i < n; i++) { |
|
345
by Suren A. Chilingaryan
64-bit access to BAR memory |
50 |
pcilib_memcpy(data + addr, buf + i * fifo_size, fifo_size, 1); |
258
by Suren A. Chilingaryan
Split bar manipulation and fifo operations in stand-alone source and publish kmem and bar headers |
51 |
}
|
52 |
||
53 |
pcilib_unmap_bar(ctx, bar, data); |
|
54 |
||
55 |
return 0; |
|
56 |
}
|