qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, aik@ozlabs.ru, agraf@suse.de,
	hpoussin@reactos.org, jan.kiszka@siemens.com,
	aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH 19/28] sh4: unbreak r2d
Date: Mon, 22 Jul 2013 15:54:29 +0200	[thread overview]
Message-ID: <1374501278-31549-20-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1374501278-31549-1-git-send-email-pbonzini@redhat.com>

... by making sh_pci a subclass of TYPE_PCI_HOST_BRIDGE.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/sh4/sh_pci.c | 39 +++++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/hw/sh4/sh_pci.c b/hw/sh4/sh_pci.c
index 53e9eb8..e81176a 100644
--- a/hw/sh4/sh_pci.c
+++ b/hw/sh4/sh_pci.c
@@ -28,9 +28,14 @@
 #include "qemu/bswap.h"
 #include "exec/address-spaces.h"
 
+#define TYPE_SH_PCI_HOST_BRIDGE "sh_pci"
+
+#define SH_PCI_HOST_BRIDGE(obj) \
+    OBJECT_CHECK(SHPCIState, (obj), TYPE_SH_PCI_HOST_BRIDGE)
+
 typedef struct SHPCIState {
-    SysBusDevice busdev;
-    PCIBus *bus;
+    PCIHostState parent_obj;
+
     PCIDevice *dev;
     qemu_irq irq[4];
     MemoryRegion memconfig_p4;
@@ -45,6 +50,8 @@ static void sh_pci_reg_write (void *p, hwaddr addr, uint64_t val,
                               unsigned size)
 {
     SHPCIState *pcic = p;
+    PCIHostState *phb = PCI_HOST_BRIDGE(pcic);
+
     switch(addr) {
     case 0 ... 0xfc:
         cpu_to_le32w((uint32_t*)(pcic->dev->config + addr), val);
@@ -64,7 +71,7 @@ static void sh_pci_reg_write (void *p, hwaddr addr, uint64_t val,
         }
         break;
     case 0x220:
-        pci_data_write(pcic->bus, pcic->par, val, 4);
+        pci_data_write(phb->bus, pcic->par, val, 4);
         break;
     }
 }
@@ -73,6 +80,8 @@ static uint64_t sh_pci_reg_read (void *p, hwaddr addr,
                                  unsigned size)
 {
     SHPCIState *pcic = p;
+    PCIHostState *phb = PCI_HOST_BRIDGE(pcic);
+
     switch(addr) {
     case 0 ... 0xfc:
         return le32_to_cpup((uint32_t*)(pcic->dev->config + addr));
@@ -83,7 +92,7 @@ static uint64_t sh_pci_reg_read (void *p, hwaddr addr,
     case 0x1c8:
         return pcic->iobr;
     case 0x220:
-        return pci_data_read(pcic->bus, pcic->par, 4);
+        return pci_data_read(phb->bus, pcic->par, 4);
     }
     return 0;
 }
@@ -112,19 +121,21 @@ static void sh_pci_set_irq(void *opaque, int irq_num, int level)
 
 static int sh_pci_device_init(SysBusDevice *dev)
 {
+    PCIHostState *phb;
     SHPCIState *s;
     int i;
 
-    s = FROM_SYSBUS(SHPCIState, dev);
+    s = SH_PCI_HOST_BRIDGE(dev);
+    phb = PCI_HOST_BRIDGE(s);
     for (i = 0; i < 4; i++) {
         sysbus_init_irq(dev, &s->irq[i]);
     }
-    s->bus = pci_register_bus(&s->busdev.qdev, "pci",
-                              sh_pci_set_irq, sh_pci_map_irq,
-                              s->irq,
-                              get_system_memory(),
-                              get_system_io(),
-                              PCI_DEVFN(0, 0), 4, TYPE_PCI_BUS);
+    phb->bus = pci_register_bus(DEVICE(dev), "pci",
+                                sh_pci_set_irq, sh_pci_map_irq,
+                                s->irq,
+                                get_system_memory(),
+                                get_system_io(),
+                                PCI_DEVFN(0, 0), 4, TYPE_PCI_BUS);
     memory_region_init_io(&s->memconfig_p4, OBJECT(s), &sh_pci_reg_ops, s,
                           "sh_pci", 0x224);
     memory_region_init_alias(&s->memconfig_a7, OBJECT(s), "sh_pci.2",
@@ -136,7 +147,7 @@ static int sh_pci_device_init(SysBusDevice *dev)
     s->iobr = 0xfe240000;
     memory_region_add_subregion(get_system_memory(), s->iobr, &s->isa);
 
-    s->dev = pci_create_simple(s->bus, PCI_DEVFN(0, 0), "sh_pci_host");
+    s->dev = pci_create_simple(phb->bus, PCI_DEVFN(0, 0), "sh_pci_host");
     return 0;
 }
 
@@ -172,8 +183,8 @@ static void sh_pci_device_class_init(ObjectClass *klass, void *data)
 }
 
 static const TypeInfo sh_pci_device_info = {
-    .name          = "sh_pci",
-    .parent        = TYPE_SYS_BUS_DEVICE,
+    .name          = TYPE_SH_PCI_HOST_BRIDGE,
+    .parent        = TYPE_PCI_HOST_BRIDGE,
     .instance_size = sizeof(SHPCIState),
     .class_init    = sh_pci_device_class_init,
 };
-- 
1.8.1.4

  parent reply	other threads:[~2013-07-22 13:55 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22 13:54 [Qemu-devel] [PATCH 00/28] Memory API for 1.6: fix I/O port endianness mess Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 01/28] sh4: do not use isa_mmio Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 02/28] ppc_oldworld: " Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 03/28] ppc_newworld: " Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 04/28] spapr_pci: remove indirection for I/O port access Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 05/28] prep: fix I/O port endianness Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 06/28] mips_jazz: do not use isa_mmio Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 07/28] mips_r4k: " Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 08/28] mips_malta: " Paolo Bonzini
2013-08-28 11:03   ` Aurelien Jarno
2013-08-28 11:13     ` Aurelien Jarno
2013-08-28 11:30       ` Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 09/28] ppc440_bamboo: " Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 10/28] mipssim: " Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 11/28] mips_fulong2e: " Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 12/28] sparc64: remove indirection for I/O port access Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 13/28] ebus: do not use isa_mmio Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 14/28] isa_mmio: delete Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 15/28] Revert "ioport: remove LITTLE_ENDIAN mark for portio" Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 16/28] pc-testdev: support 8 and 16-bit accesses to 0xe0 Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 17/28] pc-testdev: remove useless cpu_to_le64/le64_to_cpu Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 18/28] mips: degrade BIOS error to warning Paolo Bonzini
2013-07-22 13:54 ` Paolo Bonzini [this message]
2013-07-22 13:54 ` [Qemu-devel] [PATCH 20/28] sparc64: unbreak Paolo Bonzini
2013-07-22 15:32   ` Andreas Färber
2013-07-22 13:54 ` [Qemu-devel] [PATCH 21/28] default-configs: add test device to all machines supporting ISA Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 22/28] default-configs: add SuperIO to SH4 Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 23/28] default-configs/ppc64: add all components of i82378 SuperIO chip used by prep Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 24/28] qtest: add test for ISA I/O space endianness Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 25/28] memory: move functions around Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 26/28] memory: pass MemoryRegion to access_with_adjusted_size Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 27/28] memory: check memory region endianness, not target's Paolo Bonzini
2013-07-22 13:54 ` [Qemu-devel] [PATCH 28/28] pc-testdev: add I/O port to test memory.c auto split/combine Paolo Bonzini
2013-07-22 14:32 ` [Qemu-devel] [PATCH 00/28] Memory API for 1.6: fix I/O port endianness mess Peter Maydell
2013-07-22 14:36   ` Paolo Bonzini
2013-07-22 15:04     ` Peter Maydell
2013-07-22 15:07       ` Paolo Bonzini
2013-07-22 20:16         ` Hervé Poussineau
2013-07-22 21:22           ` Alexander Graf
2013-07-22 21:26           ` Andreas Färber
2013-07-23  9:30           ` Paolo Bonzini
2013-07-22 15:34 ` Anthony Liguori
2013-07-25  5:26   ` Benjamin Herrenschmidt
2013-07-25  5:47     ` Benjamin Herrenschmidt
2013-07-25  6:04       ` Jan Kiszka
2013-07-25  6:59         ` Alexey Kardashevskiy
2013-07-25  8:41         ` Paolo Bonzini
2013-07-25  8:40       ` Paolo Bonzini
2013-07-25  9:00         ` Benjamin Herrenschmidt
2013-07-25  9:38           ` Peter Maydell
2013-07-25  9:40             ` Paolo Bonzini
2013-07-25 10:25               ` Benjamin Herrenschmidt
2013-07-25 10:23             ` Benjamin Herrenschmidt
2013-07-25 10:25               ` Paolo Bonzini
2013-07-25 13:25                 ` Anthony Liguori
2013-07-25 13:28                   ` Peter Maydell
2013-07-25 13:33                     ` Paolo Bonzini
2013-07-25 13:45                       ` Peter Maydell
2013-07-25 14:44                         ` Anthony Liguori
2013-07-25 15:16                         ` Anthony Liguori
2013-07-25 13:23           ` Anthony Liguori
2013-07-25 14:19 ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374501278-31549-20-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=aliguori@us.ibm.com \
    --cc=aurelien@aurel32.net \
    --cc=hpoussin@reactos.org \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).