From 4240abff5a6fb5d88867b51f46c0235518dac564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 20 Aug 2012 19:07:56 +0200 Subject: pci: Make host bridge TypeInfos const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the QOM migration they were amended with further info but this is no longer the case. All static TypeInfos can be const these days. Signed-off-by: Andreas Färber Acked-by: Michael S. Tsirkin Signed-off-by: Anthony Liguori --- hw/dec_pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hw/dec_pci.c') diff --git a/hw/dec_pci.c b/hw/dec_pci.c index 37337bf..5194a9f 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -66,7 +66,7 @@ static void dec_21154_pci_bridge_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_pci_device; } -static TypeInfo dec_21154_pci_bridge_info = { +static const TypeInfo dec_21154_pci_bridge_info = { .name = "dec-21154-p2p-bridge", .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PCIBridge), @@ -119,7 +119,7 @@ static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data) k->is_bridge = 1; } -static TypeInfo dec_21154_pci_host_info = { +static const TypeInfo dec_21154_pci_host_info = { .name = "dec-21154", .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PCIDevice), @@ -133,7 +133,7 @@ static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data) sdc->init = pci_dec_21154_device_init; } -static TypeInfo pci_dec_21154_device_info = { +static const TypeInfo pci_dec_21154_device_info = { .name = "dec-21154-sysbus", .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(DECState), -- cgit v1.1 From ab6153673727cc1b88258675fa02113cf3271aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 20 Aug 2012 19:07:59 +0200 Subject: dec_pci: QOM'ify DEC 21154 PCI-PCI bridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce type constant. Introduce cast macro and drop dummy busdev field used with FROM_SYSBUS() that would've broken SYS_BUS_DEVICE(). Avoid accessing parent fields directly. Signed-off-by: Andreas Färber Acked-by: Michael S. Tsirkin Signed-off-by: Anthony Liguori --- hw/dec_pci.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'hw/dec_pci.c') diff --git a/hw/dec_pci.c b/hw/dec_pci.c index 5194a9f..19aed1b 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -40,8 +40,9 @@ #define DEC_DPRINTF(fmt, ...) #endif +#define DEC_21154(obj) OBJECT_CHECK(DECState, (obj), TYPE_DEC_21154) + typedef struct DECState { - SysBusDevice busdev; PCIHostState host_state; } DECState; @@ -88,16 +89,16 @@ PCIBus *pci_dec_21154_init(PCIBus *parent_bus, int devfn) static int pci_dec_21154_device_init(SysBusDevice *dev) { - DECState *s; + PCIHostState *phb; - s = FROM_SYSBUS(DECState, dev); + phb = FROM_SYSBUS(PCIHostState, dev); - memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, - &s->host_state, "pci-conf-idx", 0x1000); - memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops, - &s->host_state, "pci-data-idx", 0x1000); - sysbus_init_mmio(dev, &s->host_state.conf_mem); - sysbus_init_mmio(dev, &s->host_state.data_mem); + memory_region_init_io(&phb->conf_mem, &pci_host_conf_le_ops, + dev, "pci-conf-idx", 0x1000); + memory_region_init_io(&phb->data_mem, &pci_host_data_le_ops, + dev, "pci-data-idx", 0x1000); + sysbus_init_mmio(dev, &phb->conf_mem); + sysbus_init_mmio(dev, &phb->data_mem); return 0; } @@ -134,7 +135,7 @@ static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data) } static const TypeInfo pci_dec_21154_device_info = { - .name = "dec-21154-sysbus", + .name = TYPE_DEC_21154, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(DECState), .class_init = pci_dec_21154_device_class_init, -- cgit v1.1 From 8558d942b665a9ff0847851615e107308f6386a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 20 Aug 2012 19:08:08 +0200 Subject: pci: Derive PCI host bridges from TYPE_PCI_HOST_BRIDGE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use PCIHostState and PCI_HOST_BRIDGE() where appropriate. Signed-off-by: Andreas Färber Signed-off-by: Anthony Liguori --- hw/dec_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'hw/dec_pci.c') diff --git a/hw/dec_pci.c b/hw/dec_pci.c index 19aed1b..de16361 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -91,7 +91,7 @@ static int pci_dec_21154_device_init(SysBusDevice *dev) { PCIHostState *phb; - phb = FROM_SYSBUS(PCIHostState, dev); + phb = PCI_HOST_BRIDGE(dev); memory_region_init_io(&phb->conf_mem, &pci_host_conf_le_ops, dev, "pci-conf-idx", 0x1000); @@ -136,7 +136,7 @@ static void pci_dec_21154_device_class_init(ObjectClass *klass, void *data) static const TypeInfo pci_dec_21154_device_info = { .name = TYPE_DEC_21154, - .parent = TYPE_SYS_BUS_DEVICE, + .parent = TYPE_PCI_HOST_BRIDGE, .instance_size = sizeof(DECState), .class_init = pci_dec_21154_device_class_init, }; -- cgit v1.1 From 67c332fd12326a6ef572f07b9d71370ada6a287f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 20 Aug 2012 19:08:09 +0200 Subject: pci: Tidy up PCI host bridges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adopt the QOM parent field name and enforce QOM-style access via casts. Don't just typedef PCIHostState, either use it directly or embed it. Signed-off-by: Andreas Färber Signed-off-by: Anthony Liguori --- hw/dec_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/dec_pci.c') diff --git a/hw/dec_pci.c b/hw/dec_pci.c index de16361..c30ade3 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -43,7 +43,7 @@ #define DEC_21154(obj) OBJECT_CHECK(DECState, (obj), TYPE_DEC_21154) typedef struct DECState { - PCIHostState host_state; + PCIHostState parent_obj; } DECState; static int dec_map_irq(PCIDevice *pci_dev, int irq_num) -- cgit v1.1 From a2cb15b0ddfa05f81a42d7b65dd0c7c50e420c33 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 12 Dec 2012 14:24:50 +0200 Subject: pci: update all users to look in pci/ update all users so we can remove the makefile hack. Signed-off-by: Michael S. Tsirkin --- hw/dec_pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'hw/dec_pci.c') diff --git a/hw/dec_pci.c b/hw/dec_pci.c index c30ade3..a6a7c84 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -25,10 +25,10 @@ #include "dec_pci.h" #include "sysbus.h" -#include "pci.h" -#include "pci_host.h" -#include "pci_bridge.h" -#include "pci_internals.h" +#include "pci/pci.h" +#include "pci/pci_host.h" +#include "pci/pci_bridge.h" +#include "pci/pci_internals.h" /* debug DEC */ //#define DEBUG_DEC -- cgit v1.1 From 06aac7bd50cd934f416fe355633c045fee832905 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 12 Dec 2012 15:00:45 +0200 Subject: pci: rename pci_internals.h pci_bus.h There are lots of external users of pci_internals.h, apparently making it an internal interface only didn't work out. Let's stop pretending it's an internal header. Signed-off-by: Michael S. Tsirkin --- hw/dec_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/dec_pci.c') diff --git a/hw/dec_pci.c b/hw/dec_pci.c index a6a7c84..ee3f4ca 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -28,7 +28,7 @@ #include "pci/pci.h" #include "pci/pci_host.h" #include "pci/pci_bridge.h" -#include "pci/pci_internals.h" +#include "pci/pci_bus.h" /* debug DEC */ //#define DEBUG_DEC -- cgit v1.1