]> xenbits.xensource.com Git - qemu-xen-4.3-testing.git/commitdiff
qemu-xen: Change prototype for pt_pci_host_read/write
authorJean Guyader <jean.guyader@eu.citrix.com>
Thu, 1 Dec 2011 18:22:28 +0000 (18:22 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Thu, 1 Dec 2011 18:22:28 +0000 (18:22 +0000)
Cleanup.

pt_pci_host_read/write now takes a struct pci_dev*.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
hw/pass-through.c
hw/pass-through.h
hw/pt-graphics.c

index 9c5620da2076f32add7356e15ec6021c54d4f049..bd46b2d3b21eb1bb4d39a63b9e26a75fb9ef3b01 100644 (file)
@@ -2055,31 +2055,26 @@ static void pci_access_init(void)
     dpci_infos.pci_access = pci_access;
 }
 
-u32 pt_pci_host_read(int bus, int dev, int fn, u32 addr, int len)
+struct pci_dev *pt_pci_get_dev(int bus, int dev, int fn)
 {
+    pci_access_init();
+    return pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn);
+}
 
-    struct pci_dev *pci_dev;
+u32 pt_pci_host_read(struct pci_dev *pci_dev, u32 addr, int len)
+{
     u32 val = -1;
 
     pci_access_init();
-    pci_dev = pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn);
-    if ( !pci_dev )
-        return 0;
-
     pci_read_block(pci_dev, addr, (u8 *) &val, len);
     return val;
 }
 
-int pt_pci_host_write(int bus, int dev, int fn, u32 addr, u32 val, int len)
+int pt_pci_host_write(struct pci_dev *pci_dev, u32 addr, u32 val, int len)
 {
-    struct pci_dev *pci_dev;
     int ret = 0;
 
     pci_access_init();
-    pci_dev = pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn);
-    if ( !pci_dev )
-        return 0;
-
     ret = pci_write_block(pci_dev, addr, (u8 *) &val, len);
     return ret;
 }
index dd218f79587e53563639fd4b59570fcedceb2161..bb31acd55b96993ac6d54f0b594c70e1d8e3ab1e 100644 (file)
@@ -406,8 +406,9 @@ static inline pciaddr_t pt_pci_base_addr(pciaddr_t base)
 }
 
 uint8_t pci_intx(struct pt_dev *ptdev);
-u32 pt_pci_host_read(int bus, int dev, int fn, u32 addr, int len);
-int pt_pci_host_write(int bus, int dev, int fn, u32 addr, u32 val, int len);
+struct pci_dev *pt_pci_get_dev(int bus, int dev, int func);
+u32 pt_pci_host_read(struct pci_dev *pci_dev, u32 addr, int len);
+int pt_pci_host_write(struct pci_dev *pci_dev, u32 addr, u32 val, int len);
 void intel_pch_init(PCIBus *bus);
 int register_vga_regions(struct pt_dev *real_device);
 int unregister_vga_regions(struct pt_dev *real_device);
index 889772d9939fb5fcf246ab0acc4e55846d4a2614..73c5a43e397848fd1e2139fa356cc0c0b6d0b60c 100644 (file)
@@ -23,13 +23,14 @@ void intel_pch_init(PCIBus *bus)
 {
     uint16_t vid, did;
     uint8_t  rid;
+    struct pci_dev *pci_dev_1f = pt_pci_get_dev(0, 0x1f, 0);
 
-    if ( !gfx_passthru )
+    if ( !gfx_passthru || !pci_dev_1f )
         return;
 
-    vid = pt_pci_host_read(0, 0x1f, 0, 0, 2);
-    did = pt_pci_host_read(0, 0x1f, 0, 2, 2);
-    rid = pt_pci_host_read(0, 0x1f, 0, 8, 1);
+    vid = pt_pci_host_read(pci_dev_1f, PCI_VENDOR_ID, 2);
+    did = pt_pci_host_read(pci_dev_1f, PCI_DEVICE_ID, 2);
+    rid = pt_pci_host_read(pci_dev_1f, PCI_REVISION, 1);
 
     if ( vid == 0x8086 ) 
         pci_bridge_init(bus, PCI_DEVFN(0x1f, 0), vid, did, rid,
@@ -38,6 +39,7 @@ void intel_pch_init(PCIBus *bus)
 
 void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int len)
 {
+    struct pci_dev *pci_dev_host_bridge = pt_pci_get_dev(0, 0, 0);
     assert(pci_dev->devfn == 0x00);
     if ( !igd_passthru ) {
         pci_default_write_config(pci_dev, config_addr, val, len);
@@ -47,7 +49,7 @@ void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int l
     switch (config_addr)
     {
         case 0x58:        // PAVPC Offset
-            pt_pci_host_write(0, 0, 0, config_addr, val, len);
+            pt_pci_host_write(pci_dev_host_bridge, config_addr, val, len);
             PT_LOG("pci_config_write: %x:%x.%x: addr=%x len=%x val=%x\n",
                    pci_bus_num(pci_dev->bus), PCI_SLOT(pci_dev->devfn),
                    PCI_FUNC(pci_dev->devfn), config_addr, len, val);
@@ -59,6 +61,7 @@ void igd_pci_write(PCIDevice *pci_dev, uint32_t config_addr, uint32_t val, int l
 
 uint32_t igd_pci_read(PCIDevice *pci_dev, uint32_t config_addr, int len)
 {
+    struct pci_dev *pci_dev_host_bridge = pt_pci_get_dev(0, 0, 0);
     uint32_t val;
 
     assert(pci_dev->devfn == 0x00);
@@ -77,8 +80,7 @@ uint32_t igd_pci_read(PCIDevice *pci_dev, uint32_t config_addr, int len)
         case 0x58:        /* SNB: PAVPC Offset */
         case 0xa4:        /* SNB: graphics base of stolen memory */
         case 0xa8:        /* SNB: base of GTT stolen memory */
-            val = pt_pci_host_read(0, PCI_SLOT(pci_dev->devfn),
-                                   0, config_addr, len);
+            val = pt_pci_host_read(pci_dev_host_bridge, config_addr, len);
             PT_LOG("pci_config_read: %x:%x.%x: addr=%x len=%x val=%x\n",
                    pci_bus_num(pci_dev->bus), PCI_SLOT(pci_dev->devfn),
                    PCI_FUNC(pci_dev->devfn), config_addr, len, val);
@@ -114,8 +116,8 @@ int register_vga_regions(struct pt_dev *real_device)
             DPCI_ADD_MAPPING);
 
     /* 1:1 map ASL Storage register value */
-    vendor_id = pt_pci_host_read(0, 2, 0, 0, 2);
-    igd_opregion = pt_pci_host_read(0, 2, 0, 0xfc, 4);
+    vendor_id = pt_pci_host_read(real_device->pci_dev, 0, 2);
+    igd_opregion = pt_pci_host_read(real_device->pci_dev, 0xfc, 4);
     if ( (vendor_id == 0x8086) && igd_opregion )
     {
         ret |= xc_domain_memory_mapping(xc_handle, domid,
@@ -155,8 +157,8 @@ int unregister_vga_regions(struct pt_dev *real_device)
             20,
             DPCI_REMOVE_MAPPING);
 
-    vendor_id = pt_pci_host_read(0, 2, 0, 0, 2);
-    igd_opregion = pt_pci_host_read(0, 2, 0, 0xfc, 4);
+    vendor_id = pt_pci_host_read(real_device->pci_dev, 0, 2);
+    igd_opregion = pt_pci_host_read(real_device->pci_dev, 0xfc, 4);
     if ( (vendor_id == 0x8086) && igd_opregion )
     {
         ret |= xc_domain_memory_mapping(xc_handle, domid,