Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/common_interface.c b/src/common_interface.c
- index 6dccf8e..b8b02d5 100644
- --- a/src/common_interface.c
- +++ b/src/common_interface.c
- @@ -84,6 +84,8 @@
- #endif /* others */
- +#define FIX_DEV do { if (dev != NULL) dev = (void*)(((size_t)(pci_device_find_by_slot(0, 1, 0, 0)) & 0xffffffff00000000) | (((size_t)dev)&0xffffffff)); } while (0)
- +
- /**
- * Read a device's expansion ROM.
- *
- @@ -104,6 +106,7 @@ pci_device_read_rom( struct pci_device * dev, void * buffer )
- return EFAULT;
- }
- + FIX_DEV;
- return (pci_sys->methods->read_rom)( dev, buffer );
- }
- @@ -120,6 +123,7 @@ pci_device_is_boot_vga( struct pci_device * dev )
- {
- if (!pci_sys->methods->boot_vga)
- return 0;
- + FIX_DEV;
- return pci_sys->methods->boot_vga( dev );
- }
- @@ -135,6 +139,7 @@ pci_device_has_kernel_driver( struct pci_device * dev )
- {
- if (!pci_sys->methods->has_kernel_driver)
- return 0;
- + FIX_DEV;
- return pci_sys->methods->has_kernel_driver( dev );
- }
- @@ -159,6 +164,7 @@ pci_device_probe( struct pci_device * dev )
- }
- + FIX_DEV;
- return (pci_sys->methods->probe)( dev );
- }
- @@ -187,7 +193,9 @@ pci_device_map_region(struct pci_device * dev, unsigned region,
- const unsigned map_flags =
- (write_enable) ? PCI_DEV_MAP_FLAG_WRITABLE : 0;
- - if ((region > 5) || (dev->regions[region].size == 0)) {
- + FIX_DEV;
- +
- + if ((region > 5) || (dev->regions[region].size == 0)) {
- return ENOENT;
- }
- @@ -252,6 +260,7 @@ pci_device_map_range(struct pci_device *dev, pciaddr_t base,
- pciaddr_t size, unsigned map_flags,
- void **addr)
- {
- + FIX_DEV;
- struct pci_device_private *const devp =
- (struct pci_device_private *) dev;
- struct pci_device_mapping *mappings;
- @@ -347,6 +356,7 @@ pci_device_unmap_region( struct pci_device * dev, unsigned region )
- {
- int err;
- + FIX_DEV;
- if (dev == NULL) {
- return EFAULT;
- }
- @@ -408,6 +418,7 @@ int
- pci_device_unmap_range(struct pci_device *dev, void *memory,
- pciaddr_t size)
- {
- + FIX_DEV;
- struct pci_device_private *const devp =
- (struct pci_device_private *) dev;
- unsigned i;
- @@ -483,6 +494,7 @@ pci_device_cfg_read( struct pci_device * dev, void * data,
- return EFAULT;
- }
- + FIX_DEV;
- return pci_sys->methods->read( dev, data, offset, size,
- (bytes_read == NULL)
- ? & scratch : bytes_read );
- @@ -494,6 +506,7 @@ pci_device_cfg_read_u8( struct pci_device * dev, uint8_t * data,
- pciaddr_t offset )
- {
- pciaddr_t bytes;
- + FIX_DEV;
- int err = pci_device_cfg_read( dev, data, offset, 1, & bytes );
- if ( (err == 0) && (bytes != 1) ) {
- @@ -509,6 +522,7 @@ pci_device_cfg_read_u16( struct pci_device * dev, uint16_t * data,
- pciaddr_t offset )
- {
- pciaddr_t bytes;
- + FIX_DEV;
- int err = pci_device_cfg_read( dev, data, offset, 2, & bytes );
- if ( (err == 0) && (bytes != 2) ) {
- @@ -525,6 +539,7 @@ pci_device_cfg_read_u32( struct pci_device * dev, uint32_t * data,
- pciaddr_t offset )
- {
- pciaddr_t bytes;
- + FIX_DEV;
- int err = pci_device_cfg_read( dev, data, offset, 4, & bytes );
- if ( (err == 0) && (bytes != 4) ) {
- @@ -570,6 +585,7 @@ pci_device_cfg_write( struct pci_device * dev, const void * data,
- return EFAULT;
- }
- + FIX_DEV;
- return pci_sys->methods->write( dev, data, offset, size,
- (bytes_written == NULL)
- ? & scratch : bytes_written );
- @@ -581,6 +597,7 @@ pci_device_cfg_write_u8(struct pci_device *dev, uint8_t data,
- pciaddr_t offset)
- {
- pciaddr_t bytes;
- + FIX_DEV;
- int err = pci_device_cfg_write(dev, & data, offset, 1, & bytes);
- if ( (err == 0) && (bytes != 1) ) {
- @@ -598,6 +615,7 @@ pci_device_cfg_write_u16(struct pci_device *dev, uint16_t data,
- {
- pciaddr_t bytes;
- const uint16_t temp = HTOLE_16(data);
- + FIX_DEV;
- int err = pci_device_cfg_write( dev, & temp, offset, 2, & bytes );
- if ( (err == 0) && (bytes != 2) ) {
- @@ -615,6 +633,7 @@ pci_device_cfg_write_u32(struct pci_device *dev, uint32_t data,
- {
- pciaddr_t bytes;
- const uint32_t temp = HTOLE_32(data);
- + FIX_DEV;
- int err = pci_device_cfg_write( dev, & temp, offset, 4, & bytes );
- if ( (err == 0) && (bytes != 4) ) {
- @@ -633,6 +652,7 @@ pci_device_cfg_write_bits( struct pci_device * dev, uint32_t mask,
- uint32_t temp;
- int err;
- + FIX_DEV;
- err = pci_device_cfg_read_u32( dev, & temp, offset );
- if ( ! err ) {
- temp &= ~mask;
- @@ -651,6 +671,7 @@ pci_device_enable(struct pci_device *dev)
- return;
- }
- + FIX_DEV;
- if (pci_sys->methods->enable)
- pci_sys->methods->enable(dev);
- }
- @@ -677,6 +698,7 @@ pci_device_map_legacy(struct pci_device *dev, pciaddr_t base, pciaddr_t size,
- if (!pci_sys->methods->map_legacy)
- return ENOSYS;
- + FIX_DEV;
- return pci_sys->methods->map_legacy(dev, base, size, map_flags, addr);
- }
- @@ -696,5 +718,6 @@ pci_device_unmap_legacy(struct pci_device *dev, void *addr, pciaddr_t size)
- if (!pci_sys->methods->unmap_legacy)
- return ENOSYS;
- + FIX_DEV;
- return pci_sys->methods->unmap_legacy(dev, addr, size);
- }
- diff --git a/src/common_io.c b/src/common_io.c
- index f5c9e45..0a07d86 100644
- --- a/src/common_io.c
- +++ b/src/common_io.c
- @@ -28,6 +28,7 @@
- #include "pciaccess.h"
- #include "pciaccess_private.h"
- +#define FIX_DEV do { if (dev != NULL) dev = (void*)(((size_t)(pci_device_find_by_slot(0, 1, 0, 0)) & 0xffffffff00000000) | (((size_t)dev)&0xffffffff)); } while (0)
- static struct pci_io_handle *
- new_io_handle(void)
- {
- @@ -69,6 +70,8 @@ pci_device_open_io(struct pci_device *dev, pciaddr_t base, pciaddr_t size)
- if (!pci_sys->methods->open_device_io)
- return NULL;
- + FIX_DEV;
- +
- for (bar = 0; bar < 6; bar++) {
- struct pci_mem_region *region = &(dev->regions[bar]);
- if (!region->is_IO)
- @@ -110,6 +113,8 @@ pci_legacy_open_io(struct pci_device *dev, pciaddr_t base, pciaddr_t size)
- if (!pci_sys->methods->open_legacy_io)
- return NULL;
- + FIX_DEV;
- +
- ret = new_io_handle();
- if (!ret)
- return NULL;
- @@ -128,6 +133,8 @@ pci_legacy_open_io(struct pci_device *dev, pciaddr_t base, pciaddr_t size)
- void
- pci_device_close_io(struct pci_device *dev, struct pci_io_handle *handle)
- {
- + FIX_DEV;
- +
- if (dev && handle && pci_sys->methods->close_io)
- pci_sys->methods->close_io(dev, handle);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement