123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- --- 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 21:01:44.000000000 +0100
- @@ -41,11 +41,12 @@
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- +#include <limits.h>
- #include <sys/mman.h>
- #include <dirent.h>
- #include <errno.h>
-
- -#if defined(__i386__) || defined(__x86_64__) || defined(__arm__)
- +#if defined(__i386__) || defined(__x86_64__)
- #include <sys/io.h>
- #else
- #define inb(x) -1
- @@ -759,6 +760,7 @@ pci_device_linux_sysfs_open_device_io(st
-
- ret->base = base;
- ret->size = size;
- + ret->is_legacy = 0;
-
- return ret;
- }
- @@ -796,6 +798,7 @@ pci_device_linux_sysfs_open_legacy_io(st
-
- ret->base = base;
- ret->size = size;
- + ret->is_legacy = 1;
-
- return ret;
- }
- @@ -813,10 +816,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 +833,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 +850,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 +866,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
|