[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen-unstable] qemu-xen: Change prototype for pt_pci_host_read/write



commit a4ffb6a847258740cd1ce9700e12aebbecfe349f
Author: Jean Guyader <jean.guyader@xxxxxxxxxxxxx>
Date:   Thu Dec 1 18:22:28 2011 +0000

    qemu-xen: Change prototype for pt_pci_host_read/write
    
    Cleanup.
    
    pt_pci_host_read/write now takes a struct pci_dev*.
    
    Signed-off-by: Jean Guyader <jean.guyader@xxxxxxxxxxxxx>
    Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 hw/pass-through.c |   19 +++++++------------
 hw/pass-through.h |    5 +++--
 hw/pt-graphics.c  |   24 +++++++++++++-----------
 3 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/hw/pass-through.c b/hw/pass-through.c
index 9c5620d..bd46b2d 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -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;
 }
diff --git a/hw/pass-through.h b/hw/pass-through.h
index dd218f7..bb31acd 100644
--- a/hw/pass-through.h
+++ b/hw/pass-through.h
@@ -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);
diff --git a/hw/pt-graphics.c b/hw/pt-graphics.c
index 889772d..73c5a43 100644
--- a/hw/pt-graphics.c
+++ b/hw/pt-graphics.c
@@ -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,
--
generated by git-patchbot for /home/xen/git/qemu-xen-unstable.git

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.