diff -ur /home/alex/instaladores-linux/xserver/xorg-git/lib/libpciaccess/src/linux_devmem.c libpciaccess/src/linux_devmem.c --- /home/alex/instaladores-linux/xserver/xorg-git/lib/libpciaccess/src/linux_devmem.c 2008-10-27 10:57:37.000000000 -0500 +++ libpciaccess/src/linux_devmem.c 2009-01-15 10:21:24.000000000 -0500 @@ -124,9 +124,12 @@ else { size_t bytes; + memset(buffer, 0, rom_size); for (bytes = 0; bytes < rom_size; /* empty */) { - const ssize_t got = pread(fd, buffer, rom_size - bytes, - rom_base + bytes); + const ssize_t got = pread64(fd, + (unsigned char *)buffer + bytes, + rom_size - bytes, + rom_base + bytes); if (got == -1) { err = errno; break; diff -ur /home/alex/instaladores-linux/xserver/xorg-git/lib/libpciaccess/src/linux_sysfs.c libpciaccess/src/linux_sysfs.c --- /home/alex/instaladores-linux/xserver/xorg-git/lib/libpciaccess/src/linux_sysfs.c 2008-10-27 10:57:37.000000000 -0500 +++ libpciaccess/src/linux_sysfs.c 2009-01-15 10:44:52.000000000 -0500 @@ -56,6 +56,7 @@ #include "linux_devmem.h" static void pci_device_linux_sysfs_enable(struct pci_device *dev); +static void pci_device_linux_sysfs_disable(struct pci_device *dev); static int pci_device_linux_sysfs_read_rom( struct pci_device * dev, void * buffer ); @@ -334,6 +335,9 @@ return errno; } + /* devices need to be enabled in order to read their ROM (refcount +1)*/ + pci_device_linux_sysfs_enable(dev); + rom_size = st.st_size; if ( rom_size == 0 ) rom_size = 0x10000; @@ -365,6 +369,14 @@ write( fd, "0", 1 ); close( fd ); + if (total_bytes == 0) { + /* Failed to read entire ROM, falling back to /dev/mem */ + err = pci_device_linux_devmem_read_rom(dev, buffer); + } + + /* undo enabling of pci device (refcount -1) */ + pci_device_linux_sysfs_disable(dev); + return err; } @@ -698,3 +710,23 @@ write( fd, "1", 1 ); close(fd); } + +static void pci_device_linux_sysfs_disable(struct pci_device *dev) +{ + char name[256]; + int fd; + + snprintf( name, 255, "%s/%04x:%02x:%02x.%1u/enable", + SYS_BUS_PCI, + dev->domain, + dev->bus, + dev->dev, + dev->func ); + + fd = open( name, O_RDWR ); + if (fd == -1) + return; + + write( fd, "0", 1 ); + close(fd); +}