To use pci host framework, use PCIHostState instead of PCIBus in PCIVPBState.

Cc: Paul Brook <p...@codesourcery.com>
Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp>
---
 hw/versatile_pci.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c
index 153c651..d99b7fa 100644
--- a/hw/versatile_pci.c
+++ b/hw/versatile_pci.c
@@ -12,7 +12,7 @@
 #include "pci_host.h"
 
 typedef struct {
-    SysBusDevice busdev;
+    PCIHostState pci_host;
     qemu_irq irq[4];
     int realview;
     int mem_config;
@@ -26,38 +26,43 @@ static inline uint32_t 
vpb_pci_config_addr(target_phys_addr_t addr)
 static void pci_vpb_config_writeb (void *opaque, target_phys_addr_t addr,
                                    uint32_t val)
 {
-    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 1);
+    PCIHostState *s = opaque;
+    pci_data_write(s->bus, vpb_pci_config_addr (addr), val, 1);
 }
 
 static void pci_vpb_config_writew (void *opaque, target_phys_addr_t addr,
                                    uint32_t val)
 {
+    PCIHostState *s = opaque;
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap16(val);
 #endif
-    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 2);
+    pci_data_write(s->bus, vpb_pci_config_addr (addr), val, 2);
 }
 
 static void pci_vpb_config_writel (void *opaque, target_phys_addr_t addr,
                                    uint32_t val)
 {
+    PCIHostState *s = opaque;
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap32(val);
 #endif
-    pci_data_write(opaque, vpb_pci_config_addr (addr), val, 4);
+    pci_data_write(s->bus, vpb_pci_config_addr (addr), val, 4);
 }
 
 static uint32_t pci_vpb_config_readb (void *opaque, target_phys_addr_t addr)
 {
+    PCIHostState *s = opaque;
     uint32_t val;
-    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 1);
+    val = pci_data_read(s->bus, vpb_pci_config_addr (addr), 1);
     return val;
 }
 
 static uint32_t pci_vpb_config_readw (void *opaque, target_phys_addr_t addr)
 {
+    PCIHostState *s = opaque;
     uint32_t val;
-    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 2);
+    val = pci_data_read(s->bus, vpb_pci_config_addr (addr), 2);
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap16(val);
 #endif
@@ -66,8 +71,9 @@ static uint32_t pci_vpb_config_readw (void *opaque, 
target_phys_addr_t addr)
 
 static uint32_t pci_vpb_config_readl (void *opaque, target_phys_addr_t addr)
 {
+    PCIHostState *s = opaque;
     uint32_t val;
-    val = pci_data_read(opaque, vpb_pci_config_addr (addr), 4);
+    val = pci_data_read(s->bus, vpb_pci_config_addr (addr), 4);
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap32(val);
 #endif
@@ -114,7 +120,8 @@ static void pci_vpb_map(SysBusDevice *dev, 
target_phys_addr_t base)
 
 static int pci_vpb_init(SysBusDevice *dev)
 {
-    PCIVPBState *s = FROM_SYSBUS(PCIVPBState, dev);
+    PCIHostState *pci_host = FROM_SYSBUS(PCIHostState, dev);
+    PCIVPBState *s = DO_UPCAST(PCIVPBState, pci_host, pci_host);
     PCIBus *bus;
     int i;
 
@@ -124,11 +131,12 @@ static int pci_vpb_init(SysBusDevice *dev)
     bus = pci_register_bus(&dev->qdev, "pci",
                            pci_vpb_set_irq, pci_vpb_map_irq, s->irq,
                            11 << 3, 4);
+    pci_host->bus = bus;
 
     /* ??? Register memory space.  */
 
     s->mem_config = cpu_register_io_memory(pci_vpb_config_read,
-                                           pci_vpb_config_write, bus);
+                                           pci_vpb_config_write, pci_host);
     sysbus_init_mmio_cb(dev, 0x04000000, pci_vpb_map);
 
     pci_create_simple(bus, -1, "versatile_pci_host");
@@ -137,7 +145,8 @@ static int pci_vpb_init(SysBusDevice *dev)
 
 static int pci_realview_init(SysBusDevice *dev)
 {
-    PCIVPBState *s = FROM_SYSBUS(PCIVPBState, dev);
+    PCIHostState *pci_host = FROM_SYSBUS(PCIHostState, dev);
+    PCIVPBState *s = DO_UPCAST(PCIVPBState, pci_host, pci_host);
     s->realview = 1;
     return pci_vpb_init(dev);
 }
-- 
1.6.5.4



Reply via email to