This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 7th, 2012  |  syntax: Diff  |  size: 6.45 KB  |  views: 3,086  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/src/common_interface.c b/src/common_interface.c
  2. index 6dccf8e..b8b02d5 100644
  3. --- a/src/common_interface.c
  4. +++ b/src/common_interface.c
  5. @@ -84,6 +84,8 @@
  6.  
  7.  #endif /* others */
  8.  
  9. +#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)
  10. +
  11.  /**
  12.   * Read a device's expansion ROM.
  13.   *
  14. @@ -104,6 +106,7 @@ pci_device_read_rom( struct pci_device * dev, void * buffer )
  15.         return EFAULT;
  16.      }
  17.  
  18. +  FIX_DEV;
  19.  
  20.      return (pci_sys->methods->read_rom)( dev, buffer );
  21.  }
  22. @@ -120,6 +123,7 @@ pci_device_is_boot_vga( struct pci_device * dev )
  23.  {
  24.         if (!pci_sys->methods->boot_vga)
  25.                 return 0;
  26. +  FIX_DEV;
  27.         return pci_sys->methods->boot_vga( dev );
  28.  }
  29.  
  30. @@ -135,6 +139,7 @@ pci_device_has_kernel_driver( struct pci_device * dev )
  31.  {
  32.         if (!pci_sys->methods->has_kernel_driver)
  33.                 return 0;
  34. +  FIX_DEV;
  35.         return pci_sys->methods->has_kernel_driver( dev );
  36.  }
  37.  
  38. @@ -159,6 +164,7 @@ pci_device_probe( struct pci_device * dev )
  39.      }
  40.  
  41.  
  42. +  FIX_DEV;
  43.      return (pci_sys->methods->probe)( dev );
  44.  }
  45.  
  46. @@ -187,7 +193,9 @@ pci_device_map_region(struct pci_device * dev, unsigned region,
  47.      const unsigned map_flags =
  48.          (write_enable) ? PCI_DEV_MAP_FLAG_WRITABLE : 0;
  49.  
  50. -    if ((region > 5) || (dev->regions[region].size == 0))  {
  51. +  FIX_DEV;
  52. +
  53. +  if ((region > 5) || (dev->regions[region].size == 0))  {
  54.          return ENOENT;
  55.      }
  56.  
  57. @@ -252,6 +260,7 @@ pci_device_map_range(struct pci_device *dev, pciaddr_t base,
  58.                       pciaddr_t size, unsigned map_flags,
  59.                       void **addr)
  60.  {
  61. +  FIX_DEV;
  62.      struct pci_device_private *const devp =
  63.          (struct pci_device_private *) dev;
  64.      struct pci_device_mapping *mappings;
  65. @@ -347,6 +356,7 @@ pci_device_unmap_region( struct pci_device * dev, unsigned region )
  66.  {
  67.      int err;
  68.  
  69. +  FIX_DEV;
  70.      if (dev == NULL) {
  71.          return EFAULT;
  72.      }
  73. @@ -408,6 +418,7 @@ int
  74.  pci_device_unmap_range(struct pci_device *dev, void *memory,
  75.                         pciaddr_t size)
  76.  {
  77. +  FIX_DEV;
  78.      struct pci_device_private *const devp =
  79.          (struct pci_device_private *) dev;
  80.      unsigned i;
  81. @@ -483,6 +494,7 @@ pci_device_cfg_read( struct pci_device * dev, void * data,
  82.         return EFAULT;
  83.      }
  84.  
  85. +  FIX_DEV;
  86.      return pci_sys->methods->read( dev, data, offset, size,
  87.                                    (bytes_read == NULL)
  88.                                    ? & scratch : bytes_read );
  89. @@ -494,6 +506,7 @@ pci_device_cfg_read_u8( struct pci_device * dev, uint8_t * data,
  90.                         pciaddr_t offset )
  91.  {
  92.      pciaddr_t bytes;
  93. +  FIX_DEV;
  94.      int err = pci_device_cfg_read( dev, data, offset, 1, & bytes );
  95.  
  96.      if ( (err == 0) && (bytes != 1) ) {
  97. @@ -509,6 +522,7 @@ pci_device_cfg_read_u16( struct pci_device * dev, uint16_t * data,
  98.                          pciaddr_t offset )
  99.  {
  100.      pciaddr_t bytes;
  101. +  FIX_DEV;
  102.      int err = pci_device_cfg_read( dev, data, offset, 2, & bytes );
  103.  
  104.      if ( (err == 0) && (bytes != 2) ) {
  105. @@ -525,6 +539,7 @@ pci_device_cfg_read_u32( struct pci_device * dev, uint32_t * data,
  106.                          pciaddr_t offset )
  107.  {
  108.      pciaddr_t bytes;
  109. +  FIX_DEV;
  110.      int err = pci_device_cfg_read( dev, data, offset, 4, & bytes );
  111.  
  112.      if ( (err == 0) && (bytes != 4) ) {
  113. @@ -570,6 +585,7 @@ pci_device_cfg_write( struct pci_device * dev, const void * data,
  114.         return EFAULT;
  115.      }
  116.  
  117. +  FIX_DEV;
  118.      return pci_sys->methods->write( dev, data, offset, size,
  119.                                     (bytes_written == NULL)
  120.                                     ? & scratch : bytes_written );
  121. @@ -581,6 +597,7 @@ pci_device_cfg_write_u8(struct pci_device *dev, uint8_t data,
  122.                         pciaddr_t offset)
  123.  {
  124.      pciaddr_t bytes;
  125. +  FIX_DEV;
  126.      int err = pci_device_cfg_write(dev, & data, offset, 1, & bytes);
  127.  
  128.      if ( (err == 0) && (bytes != 1) ) {
  129. @@ -598,6 +615,7 @@ pci_device_cfg_write_u16(struct pci_device *dev, uint16_t data,
  130.  {
  131.      pciaddr_t bytes;
  132.      const uint16_t temp = HTOLE_16(data);
  133. +  FIX_DEV;
  134.      int err = pci_device_cfg_write( dev, & temp, offset, 2, & bytes );
  135.  
  136.      if ( (err == 0) && (bytes != 2) ) {
  137. @@ -615,6 +633,7 @@ pci_device_cfg_write_u32(struct pci_device *dev, uint32_t data,
  138.  {
  139.      pciaddr_t bytes;
  140.      const uint32_t temp = HTOLE_32(data);
  141. +  FIX_DEV;
  142.      int err = pci_device_cfg_write( dev, & temp, offset, 4, & bytes );
  143.  
  144.      if ( (err == 0) && (bytes != 4) ) {
  145. @@ -633,6 +652,7 @@ pci_device_cfg_write_bits( struct pci_device * dev, uint32_t mask,
  146.      uint32_t  temp;
  147.      int err;
  148.  
  149. +  FIX_DEV;
  150.      err = pci_device_cfg_read_u32( dev, & temp, offset );
  151.      if ( ! err ) {
  152.         temp &= ~mask;
  153. @@ -651,6 +671,7 @@ pci_device_enable(struct pci_device *dev)
  154.         return;
  155.      }
  156.  
  157. +  FIX_DEV;
  158.      if (pci_sys->methods->enable)
  159.         pci_sys->methods->enable(dev);
  160.  }
  161. @@ -677,6 +698,7 @@ pci_device_map_legacy(struct pci_device *dev, pciaddr_t base, pciaddr_t size,
  162.      if (!pci_sys->methods->map_legacy)
  163.         return ENOSYS;
  164.  
  165. +  FIX_DEV;
  166.      return pci_sys->methods->map_legacy(dev, base, size, map_flags, addr);
  167.  }
  168.  
  169. @@ -696,5 +718,6 @@ pci_device_unmap_legacy(struct pci_device *dev, void *addr, pciaddr_t size)
  170.      if (!pci_sys->methods->unmap_legacy)
  171.         return ENOSYS;
  172.  
  173. +  FIX_DEV;
  174.      return pci_sys->methods->unmap_legacy(dev, addr, size);
  175.  }
  176. diff --git a/src/common_io.c b/src/common_io.c
  177. index f5c9e45..0a07d86 100644
  178. --- a/src/common_io.c
  179. +++ b/src/common_io.c
  180. @@ -28,6 +28,7 @@
  181.  #include "pciaccess.h"
  182.  #include "pciaccess_private.h"
  183.  
  184. +#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)
  185.  static struct pci_io_handle *
  186.  new_io_handle(void)
  187.  {
  188. @@ -69,6 +70,8 @@ pci_device_open_io(struct pci_device *dev, pciaddr_t base, pciaddr_t size)
  189.      if (!pci_sys->methods->open_device_io)
  190.         return NULL;
  191.  
  192. +    FIX_DEV;
  193. +
  194.      for (bar = 0; bar < 6; bar++) {
  195.         struct pci_mem_region *region = &(dev->regions[bar]);
  196.         if (!region->is_IO)
  197. @@ -110,6 +113,8 @@ pci_legacy_open_io(struct pci_device *dev, pciaddr_t base, pciaddr_t size)
  198.      if (!pci_sys->methods->open_legacy_io)
  199.         return NULL;
  200.  
  201. +    FIX_DEV;
  202. +
  203.      ret = new_io_handle();
  204.      if (!ret)
  205.         return NULL;
  206. @@ -128,6 +133,8 @@ pci_legacy_open_io(struct pci_device *dev, pciaddr_t base, pciaddr_t size)
  207.  void
  208.  pci_device_close_io(struct pci_device *dev, struct pci_io_handle *handle)
  209.  {
  210. +  FIX_DEV;
  211. +
  212.      if (dev && handle && pci_sys->methods->close_io)
  213.         pci_sys->methods->close_io(dev, handle);
clone this paste RAW Paste Data