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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
--- libpciaccess-0.13.2.orig/src/linux_sysfs.c 2013-07-21 00:54:34.000000000 +0200
+++ libpciaccess-0.13.2/src/linux_sysfs.c 2014-03-24 13:26:10.484152334 +0100
@@ -759,6 +759,7 @@ pci_device_linux_sysfs_open_device_io(st
ret->base = base;
ret->size = size;
+ ret->is_legacy = 0;
return ret;
}
@@ -796,6 +797,7 @@ pci_device_linux_sysfs_open_legacy_io(st
ret->base = base;
ret->size = size;
+ ret->is_legacy = 1;
return ret;
}
@@ -813,10 +815,14 @@ pci_device_linux_sysfs_read32(struct pci
{
uint32_t ret;
- if (handle->fd > -1)
- pread(handle->fd, &ret, 4, port + handle->base);
- else
+ if (handle->fd > -1) {
+ if (handle->is_legacy)
+ pread(handle->fd, &ret, 4, port + handle->base);
+ else
+ pread(handle->fd, &ret, 4, port);
+ } else {
ret = inl(port + handle->base);
+ }
return ret;
}
@@ -826,10 +832,14 @@ pci_device_linux_sysfs_read16(struct pci
{
uint16_t ret;
- if (handle->fd > -1)
- pread(handle->fd, &ret, 2, port + handle->base);
- else
+ if (handle->fd > -1) {
+ if (handle->is_legacy)
+ pread(handle->fd, &ret, 2, port + handle->base);
+ else
+ pread(handle->fd, &ret, 2, port);
+ } else {
ret = inw(port + handle->base);
+ }
return ret;
}
@@ -839,10 +849,14 @@ pci_device_linux_sysfs_read8(struct pci_
{
uint8_t ret;
- if (handle->fd > -1)
- pread(handle->fd, &ret, 1, port + handle->base);
- else
+ if (handle->fd > -1) {
+ if (handle->is_legacy)
+ pread(handle->fd, &ret, 1, port + handle->base);
+ else
+ pread(handle->fd, &ret, 1, port);
+ } else {
ret = inb(port + handle->base);
+ }
return ret;
}
@@ -851,30 +865,42 @@ static void
pci_device_linux_sysfs_write32(struct pci_io_handle *handle, uint32_t port,
uint32_t data)
{
- if (handle->fd > -1)
- pwrite(handle->fd, &data, 4, port + handle->base);
- else
+ if (handle->fd > -1) {
+ if (handle->is_legacy)
+ pwrite(handle->fd, &data, 4, port + handle->base);
+ else
+ pwrite(handle->fd, &data, 4, port);
+ } else {
outl(data, port + handle->base);
+ }
}
static void
pci_device_linux_sysfs_write16(struct pci_io_handle *handle, uint32_t port,
uint16_t data)
{
- if (handle->fd > -1)
- pwrite(handle->fd, &data, 2, port + handle->base);
- else
+ if (handle->fd > -1) {
+ if (handle->is_legacy)
+ pwrite(handle->fd, &data, 2, port + handle->base);
+ else
+ pwrite(handle->fd, &data, 2, port);
+ } else {
outw(data, port + handle->base);
+ }
}
static void
pci_device_linux_sysfs_write8(struct pci_io_handle *handle, uint32_t port,
uint8_t data)
{
- if (handle->fd > -1)
- pwrite(handle->fd, &data, 1, port + handle->base);
- else
+ if (handle->fd > -1) {
+ if (handle->is_legacy)
+ pwrite(handle->fd, &data, 1, port + handle->base);
+ else
+ pwrite(handle->fd, &data, 1, port);
+ } else {
outb(data, port + handle->base);
+ }
}
static int
|