From 1f622394b9a6d1b4e28de0ad82ef2da6d20861e2 Mon Sep 17 00:00:00 2001
From: Blue Swirl <blauwirbel@gmail.com>
Date: Sun, 7 Feb 2010 16:06:12 +0000
Subject: [PATCH] WIP

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 Makefile.target |    2 +-
 hw/apb_pci.c    |    2 +-
 hw/pci_host.c   |    7 ++++++-
 hw/sun4u.c      |    5 +++--
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index f498574..d8aea72 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -269,7 +269,7 @@ obj-cris-y += etraxfs_ser.o
 obj-cris-y += pflash_cfi02.o
 
 ifeq ($(TARGET_ARCH), sparc64)
-obj-sparc-y = sun4u.o pckbd.o apb_pci.o
+obj-sparc-y = sun4u.o pckbd.o apb_pci.o dec_pci.o
 obj-sparc-y += ide/core.o ide/qdev.o ide/pci.o ide/cmd646.o
 obj-sparc-y += vga.o vga-pci.o
 obj-sparc-y += fdc.o mc146818rtc.o serial.o
diff --git a/hw/apb_pci.c b/hw/apb_pci.c
index 46d5b0e..885ae54 100644
--- a/hw/apb_pci.c
+++ b/hw/apb_pci.c
@@ -403,7 +403,7 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base,
                             "Advanced PCI Bus secondary bridge 1");
     apb_pci_bridge_init(*bus2);
 
-    *bus3 = pci_bridge_init(d->host_state.bus, PCI_DEVFN(1, 1),
+    *bus3 = pci_bridge_init(*bus2, -1,
                             PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_SIMBA,
                             pci_apb_map_irq,
                             "Advanced PCI Bus secondary bridge 2");
diff --git a/hw/pci_host.c b/hw/pci_host.c
index 6289ead..9a5e750 100644
--- a/hw/pci_host.c
+++ b/hw/pci_host.c
@@ -53,8 +53,11 @@ void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len)
     PCIDevice *pci_dev = pci_dev_find_by_addr(s, addr);
     uint32_t config_addr = addr & (PCI_CONFIG_SPACE_SIZE - 1);
 
-    if (!pci_dev)
+    if (!pci_dev) {
+        PCI_DPRINTF("%s: not found, addr=%02" PRIx32 " val=%08" PRIx32 " len=%d\n",
+                    __func__, addr, val, len);
         return;
+    }
 
     PCI_DPRINTF("%s: %s: addr=%02" PRIx32 " val=%08" PRIx32 " len=%d\n",
                 __func__, pci_dev->name, config_addr, val, len);
@@ -69,6 +72,8 @@ uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len)
 
     assert(len == 1 || len == 2 || len == 4);
     if (!pci_dev) {
+        PCI_DPRINTF("%s: not found, addr=%02" PRIx32 " len=%d\n",
+                    __func__, addr, len);
         return ~0x0;
     }
 
diff --git a/hw/sun4u.c b/hw/sun4u.c
index f339df3..e9f5253 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -756,11 +756,12 @@ static void sun4uv_init(ram_addr_t RAM_size,
     irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
     pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, irq, &pci_bus2,
                            &pci_bus3);
+    pci_create_simple(pci_bus3, -1, "dec-21154");
     isa_mem_base = VGA_BASE;
     pci_vga_init(pci_bus, 0, 0);
 
     // XXX Should be pci_bus3
-    pci_ebus_init(pci_bus, -1);
+    pci_ebus_init(pci_bus2, -1);
 
     i = 0;
     if (hwdef->console_serial_base) {
@@ -792,7 +793,7 @@ static void sun4uv_init(ram_addr_t RAM_size,
                           i % MAX_IDE_DEVS);
     }
 
-    pci_cmd646_ide_init(pci_bus, hd, 1);
+    pci_cmd646_ide_init(pci_bus3, hd, 1);
 
     isa_create_simple("i8042");
     for(i = 0; i < MAX_FD; i++) {
-- 
1.5.6.5

