* [PATCH v4 00/11] QOM'ify PIIX southbridge creation
@ 2022-06-03 18:50 Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 01/11] hw/southbridge/piix: Aggregate all PIIX southbridge type names Bernhard Beschow
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow
v4:
* Rebase onto https://patchew.org/QEMU/20220530112718.26582-1-philippe.mathieu.daude@gmail.com/
* Cosmetics (fix typo, omit "include") (Mark, Philippe)
* Split piix3 and piix4 (Philippe)
* s/Found-by/Reported-by/ (Philippe)
* Don't alias smbus (Mark)
v3:
* Rebase onto 'hw/acpi/piix4: remove legacy piix4_pm_init() function' (Mark) [1]
* Use embedded structs for touched PCI devices (Mark)
* Fix piix4's rtc embedded struct to be initialized by
object_initialize_child() (Peter) [2]
Testing done:
1)
`make check-avocado` for --target-list=x86_64-softmmu,mips-softmmu
Result: All pass.
2)
* `qemu-system-x86_64 -M pc -m 2G -cdrom archlinux-2022.05.01-x86_64.iso`
* `qemu-system-mipsel -M malta -kernel vmlinux-3.2.0-4-4kc-malta -hda
debian_wheezy_mipsel_standard.qcow2 -append "root=/dev/sda1 console=tty0"`
In both cases the system booted successfully and it was possible to shut down
the system using the `poweroff` command.
v2:
* Preserve `DeviceState *` as return value of piix4_create() (Mark)
* Aggregate all type name movements into first commit (Mark)
* Have piix4 southbridge rather than malta board instantiate piix4 pm (me)
Testing done:
1)
`make check-avocado` for --target-list=x86_64-softmmu,mips-softmmu
Result: All pass.
2)
Modify pci_piix3_realize() to start with
error_setg(errp, "This is a test");
Then start `qemu-system-x86_64 -M pc -m 1G -accel kvm -cpu host -cdrom
archlinux-2022.05.01-x86_64.iso`.
Result: qemu-system-x86_64 aborts with: "This is a test"
v1:
The piix3 and piix4 southbridge devices still rely on create() functions which
are deprecated. This series resolves these functions piece by piece to
modernize the code.
Both devices are modified in lockstep where possible to provide more context.
Testing done:
* `qemu-system-x86_64 -M pc -m 2G -cdrom archlinux-2022.05.01-x86_64.iso`
* `qemu-system-mipsel -M malta -kernel vmlinux-3.2.0-4-4kc-malta -hda
debian_wheezy_mipsel_standard.qcow2 -append "root=/dev/sda1 console=tty0"`
In both cases the system booted successfully and it was possible to shut down
the system using the `poweroff` command.
[1] https://lists.gnu.org/archive/html/qemu-devel/2022-05/msg05686.html
[2] https://lists.gnu.org/archive/html/qemu-devel/2022-02/msg01128.html
Bernhard Beschow (11):
hw/southbridge/piix: Aggregate all PIIX southbridge type names
hw/isa/piix4: Use object_initialize_child() for embedded struct
hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn
hw/isa/piix4: QOM'ify PCI device creation and wiring
hw/isa/piix4: Factor out ISABus retrieval from piix4_create()
hw/isa/piix4: QOM'ify PIIX4 PM creation
hw/isa/piix4: Inline and remove piix4_create()
hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn
hw/isa/piix3: QOM'ify PCI device creation and wiring
hw/isa/piix3: Factor out ISABus retrieval from piix3_create()
hw/isa/piix3: Inline and remove piix3_create()
hw/i386/pc_piix.c | 7 +-
hw/isa/piix3.c | 98 +++++++++++++++-------------
hw/isa/piix4.c | 119 +++++++++++++++++-----------------
hw/mips/malta.c | 9 ++-
include/hw/isa/isa.h | 2 -
include/hw/southbridge/piix.h | 6 +-
6 files changed, 128 insertions(+), 113 deletions(-)
--
2.36.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 01/11] hw/southbridge/piix: Aggregate all PIIX southbridge type names
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 02/11] hw/isa/piix4: Use object_initialize_child() for embedded struct Bernhard Beschow
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow,
Mark Cave-Ayland
TYPE_PIIX3_PCI_DEVICE resides there as already, so add the remaining
ones, too.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/isa/piix3.c | 3 ---
include/hw/isa/isa.h | 2 --
include/hw/southbridge/piix.h | 4 ++++
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
index dab901c9ad..d96ce2b788 100644
--- a/hw/isa/piix3.c
+++ b/hw/isa/piix3.c
@@ -35,9 +35,6 @@
#define XEN_PIIX_NUM_PIRQS 128ULL
-#define TYPE_PIIX3_DEVICE "PIIX3"
-#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen"
-
static void piix3_set_irq_pic(PIIX3State *piix3, int pic_irq)
{
qemu_set_irq(piix3->pic[pic_irq],
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index 034d706ba1..e9fa2f5cea 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -144,6 +144,4 @@ static inline ISABus *isa_bus_from_device(ISADevice *d)
return ISA_BUS(qdev_get_parent_bus(DEVICE(d)));
}
-#define TYPE_PIIX4_PCI_DEVICE "piix4-isa"
-
#endif
diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h
index 976b4da582..3b97186f75 100644
--- a/include/hw/southbridge/piix.h
+++ b/include/hw/southbridge/piix.h
@@ -64,6 +64,10 @@ typedef struct PIIXState PIIX3State;
DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
TYPE_PIIX3_PCI_DEVICE)
+#define TYPE_PIIX3_DEVICE "PIIX3"
+#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen"
+#define TYPE_PIIX4_PCI_DEVICE "piix4-isa"
+
PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus);
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 02/11] hw/isa/piix4: Use object_initialize_child() for embedded struct
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 01/11] hw/southbridge/piix: Aggregate all PIIX southbridge type names Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 03/11] hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn Bernhard Beschow
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow,
Peter Maydell
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/isa/piix4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 9a6d981037..1d04fb6a55 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -224,7 +224,7 @@ static void piix4_init(Object *obj)
{
PIIX4State *s = PIIX4_PCI_DEVICE(obj);
- object_initialize(&s->rtc, sizeof(s->rtc), TYPE_MC146818_RTC);
+ object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
}
static void piix4_class_init(ObjectClass *klass, void *data)
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 03/11] hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 01/11] hw/southbridge/piix: Aggregate all PIIX southbridge type names Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 02/11] hw/isa/piix4: Use object_initialize_child() for embedded struct Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 04/11] hw/isa/piix4: QOM'ify PCI device creation and wiring Bernhard Beschow
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow,
Mark Cave-Ayland
The pci_map_irq_fn was implemented below type_init() which made it
inaccessible to QOM functions. So move it up.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/isa/piix4.c | 50 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 1d04fb6a55..18aa24424f 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -74,6 +74,31 @@ static void piix4_set_irq(void *opaque, int irq_num, int level)
}
}
+static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
+{
+ int slot;
+
+ slot = PCI_SLOT(pci_dev->devfn);
+
+ switch (slot) {
+ /* PIIX4 USB */
+ case 10:
+ return 3;
+ /* AMD 79C973 Ethernet */
+ case 11:
+ return 1;
+ /* Crystal 4281 Sound */
+ case 12:
+ return 2;
+ /* PCI slot 1 to 4 */
+ case 18 ... 21:
+ return ((slot - 18) + irq_num) & 0x03;
+ /* Unknown device, don't do any translation */
+ default:
+ return irq_num;
+ }
+}
+
static void piix4_isa_reset(DeviceState *dev)
{
PIIX4State *d = PIIX4_PCI_DEVICE(dev);
@@ -266,31 +291,6 @@ static void piix4_register_types(void)
type_init(piix4_register_types)
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num)
-{
- int slot;
-
- slot = PCI_SLOT(pci_dev->devfn);
-
- switch (slot) {
- /* PIIX4 USB */
- case 10:
- return 3;
- /* AMD 79C973 Ethernet */
- case 11:
- return 1;
- /* Crystal 4281 Sound */
- case 12:
- return 2;
- /* PCI slot 1 to 4 */
- case 18 ... 21:
- return ((slot - 18) + irq_num) & 0x03;
- /* Unknown device, don't do any translation */
- default:
- return irq_num;
- }
-}
-
DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
{
PIIX4State *s;
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 04/11] hw/isa/piix4: QOM'ify PCI device creation and wiring
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (2 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 03/11] hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 05/11] hw/isa/piix4: Factor out ISABus retrieval from piix4_create() Bernhard Beschow
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow
PCI interrupt wiring and device creation were performed in create()
functions which are obsolete. Move these tasks into QOM functions to
modernize the code.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/isa/piix4.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 18aa24424f..058bebb5e2 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -35,6 +35,7 @@
#include "hw/rtc/mc146818rtc.h"
#include "hw/ide/pci.h"
#include "hw/acpi/piix4.h"
+#include "hw/usb/hcd-uhci.h"
#include "migration/vmstate.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
@@ -46,6 +47,8 @@ struct PIIX4State {
qemu_irq *isa;
RTCState rtc;
+ PCIIDEState ide;
+ UHCIState uhci;
/* Reset Control Register */
MemoryRegion rcr_mem;
uint8_t rcr;
@@ -205,6 +208,7 @@ static const MemoryRegionOps piix4_rcr_ops = {
static void piix4_realize(PCIDevice *dev, Error **errp)
{
PIIX4State *s = PIIX4_PCI_DEVICE(dev);
+ PCIBus *pci_bus = pci_get_bus(dev);
ISABus *isa_bus;
qemu_irq *i8259_out_irq;
@@ -243,6 +247,21 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
return;
}
s->rtc.irq = isa_get_irq(ISA_DEVICE(&s->rtc), s->rtc.isairq);
+
+ /* IDE */
+ qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1);
+ if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) {
+ return;
+ }
+ pci_ide_create_devs(PCI_DEVICE(&s->ide));
+
+ /* USB */
+ qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2);
+ if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) {
+ return;
+ }
+
+ pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
}
static void piix4_init(Object *obj)
@@ -250,6 +269,8 @@ static void piix4_init(Object *obj)
PIIX4State *s = PIIX4_PCI_DEVICE(obj);
object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
+ object_initialize_child(obj, "ide", &s->ide, "piix4-ide");
+ object_initialize_child(obj, "uhci", &s->uhci, "piix4-usb-uhci");
}
static void piix4_class_init(ObjectClass *klass, void *data)
@@ -293,7 +314,6 @@ type_init(piix4_register_types)
DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
{
- PIIX4State *s;
PCIDevice *pci;
DeviceState *dev;
int devfn = PCI_DEVFN(10, 0);
@@ -301,15 +321,11 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
pci = pci_create_simple_multifunction(pci_bus, devfn, true,
TYPE_PIIX4_PCI_DEVICE);
dev = DEVICE(pci);
- s = PIIX4_PCI_DEVICE(pci);
+
if (isa_bus) {
*isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
}
- pci = pci_create_simple(pci_bus, devfn + 1, "piix4-ide");
- pci_ide_create_devs(pci);
-
- pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci");
if (smbus) {
pci = pci_new(devfn + 3, TYPE_PIIX4_PM);
qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100);
@@ -320,7 +336,5 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
*smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pci), "i2c"));
}
- pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
-
return dev;
}
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 05/11] hw/isa/piix4: Factor out ISABus retrieval from piix4_create()
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (3 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 04/11] hw/isa/piix4: QOM'ify PCI device creation and wiring Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 06/11] hw/isa/piix4: QOM'ify PIIX4 PM creation Bernhard Beschow
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow,
Mark Cave-Ayland
Modernizes the code.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/isa/piix4.c | 6 +-----
hw/mips/malta.c | 3 ++-
include/hw/southbridge/piix.h | 2 +-
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 058bebb5e2..96df21a610 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -312,7 +312,7 @@ static void piix4_register_types(void)
type_init(piix4_register_types)
-DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
+DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus)
{
PCIDevice *pci;
DeviceState *dev;
@@ -322,10 +322,6 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus)
TYPE_PIIX4_PCI_DEVICE);
dev = DEVICE(pci);
- if (isa_bus) {
- *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
- }
-
if (smbus) {
pci = pci_new(devfn + 3, TYPE_PIIX4_PM);
qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100);
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 9ffdc5b8f1..e446b25ad0 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -1399,7 +1399,8 @@ void mips_malta_init(MachineState *machine)
empty_slot_init("GT64120", 0, 0x20000000);
/* Southbridge */
- dev = piix4_create(pci_bus, &isa_bus, &smbus);
+ dev = piix4_create(pci_bus, &smbus);
+ isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
/* Interrupt controller */
qdev_connect_gpio_out_named(dev, "intr", 0, i8259_irq);
diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h
index 3b97186f75..dab5c9704e 100644
--- a/include/hw/southbridge/piix.h
+++ b/include/hw/southbridge/piix.h
@@ -70,6 +70,6 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
-DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus);
+DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus);
#endif
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 06/11] hw/isa/piix4: QOM'ify PIIX4 PM creation
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (4 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 05/11] hw/isa/piix4: Factor out ISABus retrieval from piix4_create() Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 07/11] hw/isa/piix4: Inline and remove piix4_create() Bernhard Beschow
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow
Just like the real hardware, create the PIIX4 ACPI controller as part of
the PIIX4 southbridge. This also mirrors how the IDE and USB functions
are already created.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/isa/piix4.c | 24 +++++++++++++-----------
hw/mips/malta.c | 5 ++++-
include/hw/southbridge/piix.h | 2 +-
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 96df21a610..d97b245df3 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -49,6 +49,7 @@ struct PIIX4State {
RTCState rtc;
PCIIDEState ide;
UHCIState uhci;
+ PIIX4PMState pm;
/* Reset Control Register */
MemoryRegion rcr_mem;
uint8_t rcr;
@@ -261,6 +262,13 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
return;
}
+ /* ACPI controller */
+ qdev_prop_set_int32(DEVICE(&s->pm), "addr", dev->devfn + 3);
+ if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
+ return;
+ }
+ qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]);
+
pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS);
}
@@ -271,6 +279,10 @@ static void piix4_init(Object *obj)
object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
object_initialize_child(obj, "ide", &s->ide, "piix4-ide");
object_initialize_child(obj, "uhci", &s->uhci, "piix4-usb-uhci");
+
+ object_initialize_child(obj, "pm", &s->pm, TYPE_PIIX4_PM);
+ qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", 0x1100);
+ qdev_prop_set_bit(DEVICE(&s->pm), "smm-enabled", 0);
}
static void piix4_class_init(ObjectClass *klass, void *data)
@@ -312,7 +324,7 @@ static void piix4_register_types(void)
type_init(piix4_register_types)
-DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus)
+DeviceState *piix4_create(PCIBus *pci_bus)
{
PCIDevice *pci;
DeviceState *dev;
@@ -322,15 +334,5 @@ DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus)
TYPE_PIIX4_PCI_DEVICE);
dev = DEVICE(pci);
- if (smbus) {
- pci = pci_new(devfn + 3, TYPE_PIIX4_PM);
- qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100);
- qdev_prop_set_bit(DEVICE(pci), "smm-enabled", 0);
- pci_realize_and_unref(pci, pci_bus, &error_fatal);
- qdev_connect_gpio_out(DEVICE(pci), 0,
- qdev_get_gpio_in_named(dev, "isa", 9));
- *smbus = I2C_BUS(qdev_get_child_bus(DEVICE(pci), "i2c"));
- }
-
return dev;
}
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index e446b25ad0..be9f26d841 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -1238,6 +1238,7 @@ void mips_malta_init(MachineState *machine)
int be;
MaltaState *s;
DeviceState *dev;
+ DeviceState *pm_dev;
s = MIPS_MALTA(qdev_new(TYPE_MIPS_MALTA));
sysbus_realize_and_unref(SYS_BUS_DEVICE(s), &error_fatal);
@@ -1399,8 +1400,10 @@ void mips_malta_init(MachineState *machine)
empty_slot_init("GT64120", 0, 0x20000000);
/* Southbridge */
- dev = piix4_create(pci_bus, &smbus);
+ dev = piix4_create(pci_bus);
isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
+ pm_dev = DEVICE(object_resolve_path_component(OBJECT(dev), "pm"));
+ smbus = I2C_BUS(qdev_get_child_bus(pm_dev, "i2c"));
/* Interrupt controller */
qdev_connect_gpio_out_named(dev, "intr", 0, i8259_irq);
diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h
index dab5c9704e..2357ce0287 100644
--- a/include/hw/southbridge/piix.h
+++ b/include/hw/southbridge/piix.h
@@ -70,6 +70,6 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
-DeviceState *piix4_create(PCIBus *pci_bus, I2CBus **smbus);
+DeviceState *piix4_create(PCIBus *pci_bus);
#endif
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 07/11] hw/isa/piix4: Inline and remove piix4_create()
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (5 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 06/11] hw/isa/piix4: QOM'ify PIIX4 PM creation Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 08/11] hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn Bernhard Beschow
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow
During the previous changesets piix4_create() became a trivial
wrapper around more generic functions. Modernize the code.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/isa/piix4.c | 13 -------------
hw/mips/malta.c | 5 ++++-
include/hw/southbridge/piix.h | 2 --
3 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index d97b245df3..15f344dbb7 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -323,16 +323,3 @@ static void piix4_register_types(void)
}
type_init(piix4_register_types)
-
-DeviceState *piix4_create(PCIBus *pci_bus)
-{
- PCIDevice *pci;
- DeviceState *dev;
- int devfn = PCI_DEVFN(10, 0);
-
- pci = pci_create_simple_multifunction(pci_bus, devfn, true,
- TYPE_PIIX4_PCI_DEVICE);
- dev = DEVICE(pci);
-
- return dev;
-}
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index be9f26d841..7a0ec513b0 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -1237,6 +1237,7 @@ void mips_malta_init(MachineState *machine)
int fl_idx = 0;
int be;
MaltaState *s;
+ PCIDevice *piix4;
DeviceState *dev;
DeviceState *pm_dev;
@@ -1400,7 +1401,9 @@ void mips_malta_init(MachineState *machine)
empty_slot_init("GT64120", 0, 0x20000000);
/* Southbridge */
- dev = piix4_create(pci_bus);
+ piix4 = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0), true,
+ TYPE_PIIX4_PCI_DEVICE);
+ dev = DEVICE(piix4);
isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
pm_dev = DEVICE(object_resolve_path_component(OBJECT(dev), "pm"));
smbus = I2C_BUS(qdev_get_child_bus(pm_dev, "i2c"));
diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h
index 2357ce0287..9a2dd93c2d 100644
--- a/include/hw/southbridge/piix.h
+++ b/include/hw/southbridge/piix.h
@@ -70,6 +70,4 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
-DeviceState *piix4_create(PCIBus *pci_bus);
-
#endif
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 08/11] hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (6 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 07/11] hw/isa/piix4: Inline and remove piix4_create() Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 09/11] hw/isa/piix3: QOM'ify PCI device creation and wiring Bernhard Beschow
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow,
Mark Cave-Ayland
The pci_map_irq_fn was implemented below type_init() which made it
inaccessible to QOM functions. So move it up.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/isa/piix3.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
index d96ce2b788..c7a9014c3f 100644
--- a/hw/isa/piix3.c
+++ b/hw/isa/piix3.c
@@ -78,6 +78,17 @@ static void piix3_set_irq(void *opaque, int pirq, int level)
piix3_set_irq_level(piix3, pirq, level);
}
+/*
+ * Return the global irq number corresponding to a given device irq
+ * pin. We could also use the bus number to have a more precise mapping.
+ */
+static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
+{
+ int slot_addend;
+ slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
+ return (pci_intx + slot_addend) & 3;
+}
+
static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int pin)
{
PIIX3State *piix3 = opaque;
@@ -350,17 +361,6 @@ static void piix3_register_types(void)
type_init(piix3_register_types)
-/*
- * Return the global irq number corresponding to a given device irq
- * pin. We could also use the bus number to have a more precise mapping.
- */
-static int pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx)
-{
- int slot_addend;
- slot_addend = PCI_SLOT(pci_dev->devfn) - 1;
- return (pci_intx + slot_addend) & 3;
-}
-
PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus)
{
PIIX3State *piix3;
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 09/11] hw/isa/piix3: QOM'ify PCI device creation and wiring
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (7 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 08/11] hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 10/11] hw/isa/piix3: Factor out ISABus retrieval from piix3_create() Bernhard Beschow
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow
PCI interrupt wiring was performed in create() functions which are
obsolete. Move these tasks into QOM functions to modernize the code.
In order to avoid duplicate checking for xen_enabled() the realize
methods are now split.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/isa/piix3.c | 67 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 45 insertions(+), 22 deletions(-)
diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
index c7a9014c3f..de532cc692 100644
--- a/hw/isa/piix3.c
+++ b/hw/isa/piix3.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qemu/range.h"
+#include "qapi/error.h"
#include "hw/southbridge/piix.h"
#include "hw/irq.h"
#include "hw/isa/isa.h"
@@ -277,7 +278,7 @@ static const MemoryRegionOps rcr_ops = {
.endianness = DEVICE_LITTLE_ENDIAN
};
-static void piix3_realize(PCIDevice *dev, Error **errp)
+static void pci_piix3_realize(PCIDevice *dev, Error **errp)
{
PIIX3State *d = PIIX3_PCI_DEVICE(dev);
@@ -302,7 +303,6 @@ static void pci_piix3_class_init(ObjectClass *klass, void *data)
dc->desc = "ISA bridge";
dc->vmsd = &vmstate_piix3;
dc->hotpluggable = false;
- k->realize = piix3_realize;
k->vendor_id = PCI_VENDOR_ID_INTEL;
/* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */
k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0;
@@ -326,11 +326,28 @@ static const TypeInfo piix3_pci_type_info = {
},
};
+static void piix3_realize(PCIDevice *dev, Error **errp)
+{
+ ERRP_GUARD();
+ PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev);
+ PCIBus *pci_bus = pci_get_bus(dev);
+
+ pci_piix3_realize(dev, errp);
+ if (*errp) {
+ return;
+ }
+
+ pci_bus_irqs(pci_bus, piix3_set_irq, pci_slot_get_pirq,
+ piix3, PIIX_NUM_PIRQS);
+ pci_bus_set_route_irq_fn(pci_bus, piix3_route_intx_pin_to_irq);
+};
+
static void piix3_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->config_write = piix3_write_config;
+ k->realize = piix3_realize;
}
static const TypeInfo piix3_info = {
@@ -339,11 +356,33 @@ static const TypeInfo piix3_info = {
.class_init = piix3_class_init,
};
+static void piix3_xen_realize(PCIDevice *dev, Error **errp)
+{
+ ERRP_GUARD();
+ PIIX3State *piix3 = PIIX3_PCI_DEVICE(dev);
+ PCIBus *pci_bus = pci_get_bus(dev);
+
+ pci_piix3_realize(dev, errp);
+ if (*errp) {
+ return;
+ }
+
+ /*
+ * Xen supports additional interrupt routes from the PCI devices to
+ * the IOAPIC: the four pins of each PCI device on the bus are also
+ * connected to the IOAPIC directly.
+ * These additional routes can be discovered through ACPI.
+ */
+ pci_bus_irqs(pci_bus, xen_piix3_set_irq, xen_pci_slot_get_pirq,
+ piix3, XEN_PIIX_NUM_PIRQS);
+};
+
static void piix3_xen_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->config_write = piix3_write_config_xen;
+ k->realize = piix3_xen_realize;
};
static const TypeInfo piix3_xen_info = {
@@ -365,27 +404,11 @@ PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus)
{
PIIX3State *piix3;
PCIDevice *pci_dev;
+ const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE
+ : TYPE_PIIX3_DEVICE;
- /*
- * Xen supports additional interrupt routes from the PCI devices to
- * the IOAPIC: the four pins of each PCI device on the bus are also
- * connected to the IOAPIC directly.
- * These additional routes can be discovered through ACPI.
- */
- if (xen_enabled()) {
- pci_dev = pci_create_simple_multifunction(pci_bus, -1, true,
- TYPE_PIIX3_XEN_DEVICE);
- piix3 = PIIX3_PCI_DEVICE(pci_dev);
- pci_bus_irqs(pci_bus, xen_piix3_set_irq, xen_pci_slot_get_pirq,
- piix3, XEN_PIIX_NUM_PIRQS);
- } else {
- pci_dev = pci_create_simple_multifunction(pci_bus, -1, true,
- TYPE_PIIX3_DEVICE);
- piix3 = PIIX3_PCI_DEVICE(pci_dev);
- pci_bus_irqs(pci_bus, piix3_set_irq, pci_slot_get_pirq,
- piix3, PIIX_NUM_PIRQS);
- pci_bus_set_route_irq_fn(pci_bus, piix3_route_intx_pin_to_irq);
- }
+ pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type);
+ piix3 = PIIX3_PCI_DEVICE(pci_dev);
*isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
return piix3;
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 10/11] hw/isa/piix3: Factor out ISABus retrieval from piix3_create()
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (8 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 09/11] hw/isa/piix3: QOM'ify PCI device creation and wiring Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 11/11] hw/isa/piix3: Inline and remove piix3_create() Bernhard Beschow
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow,
Mark Cave-Ayland
Modernizes the code.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/i386/pc_piix.c | 3 ++-
hw/isa/piix3.c | 3 +--
include/hw/southbridge/piix.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index d6668b7c06..c884d1a489 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -207,9 +207,10 @@ static void pc_init1(MachineState *machine,
pci_memory, ram_memory);
pcms->bus = pci_bus;
- piix3 = piix3_create(pci_bus, &isa_bus);
+ piix3 = piix3_create(pci_bus);
piix3->pic = x86ms->gsi;
piix3_devfn = piix3->dev.devfn;
+ isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
} else {
pci_bus = NULL;
i440fx_state = NULL;
diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
index de532cc692..c6ff7795f4 100644
--- a/hw/isa/piix3.c
+++ b/hw/isa/piix3.c
@@ -400,7 +400,7 @@ static void piix3_register_types(void)
type_init(piix3_register_types)
-PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus)
+PIIX3State *piix3_create(PCIBus *pci_bus)
{
PIIX3State *piix3;
PCIDevice *pci_dev;
@@ -409,7 +409,6 @@ PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus)
pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type);
piix3 = PIIX3_PCI_DEVICE(pci_dev);
- *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
return piix3;
}
diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h
index 9a2dd93c2d..f805fb8683 100644
--- a/include/hw/southbridge/piix.h
+++ b/include/hw/southbridge/piix.h
@@ -68,6 +68,6 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen"
#define TYPE_PIIX4_PCI_DEVICE "piix4-isa"
-PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus);
+PIIX3State *piix3_create(PCIBus *pci_bus);
#endif
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 11/11] hw/isa/piix3: Inline and remove piix3_create()
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (9 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 10/11] hw/isa/piix3: Factor out ISABus retrieval from piix3_create() Bernhard Beschow
@ 2022-06-03 18:50 ` Bernhard Beschow
2022-06-06 10:38 ` [PATCH v4 00/11] QOM'ify PIIX southbridge creation Mark Cave-Ayland
2022-06-11 9:47 ` Philippe Mathieu-Daudé via
12 siblings, 0 replies; 14+ messages in thread
From: Bernhard Beschow @ 2022-06-03 18:50 UTC (permalink / raw)
To: qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini, Bernhard Beschow
During the previous changesets piix3_create() became a trivial
wrapper around more generic functions. Modernize the code.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/i386/pc_piix.c | 6 +++++-
hw/isa/piix3.c | 13 -------------
include/hw/southbridge/piix.h | 2 --
3 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index c884d1a489..b58fbd4815 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -197,6 +197,9 @@ static void pc_init1(MachineState *machine,
if (pcmc->pci_enabled) {
PIIX3State *piix3;
+ PCIDevice *pci_dev;
+ const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE
+ : TYPE_PIIX3_DEVICE;
pci_bus = i440fx_init(host_type,
pci_type,
@@ -207,7 +210,8 @@ static void pc_init1(MachineState *machine,
pci_memory, ram_memory);
pcms->bus = pci_bus;
- piix3 = piix3_create(pci_bus);
+ pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type);
+ piix3 = PIIX3_PCI_DEVICE(pci_dev);
piix3->pic = x86ms->gsi;
piix3_devfn = piix3->dev.devfn;
isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c
index c6ff7795f4..01c376b39a 100644
--- a/hw/isa/piix3.c
+++ b/hw/isa/piix3.c
@@ -399,16 +399,3 @@ static void piix3_register_types(void)
}
type_init(piix3_register_types)
-
-PIIX3State *piix3_create(PCIBus *pci_bus)
-{
- PIIX3State *piix3;
- PCIDevice *pci_dev;
- const char *type = xen_enabled() ? TYPE_PIIX3_XEN_DEVICE
- : TYPE_PIIX3_DEVICE;
-
- pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, type);
- piix3 = PIIX3_PCI_DEVICE(pci_dev);
-
- return piix3;
-}
diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h
index f805fb8683..2693778b23 100644
--- a/include/hw/southbridge/piix.h
+++ b/include/hw/southbridge/piix.h
@@ -68,6 +68,4 @@ DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE,
#define TYPE_PIIX3_XEN_DEVICE "PIIX3-xen"
#define TYPE_PIIX4_PCI_DEVICE "piix4-isa"
-PIIX3State *piix3_create(PCIBus *pci_bus);
-
#endif
--
2.36.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v4 00/11] QOM'ify PIIX southbridge creation
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (10 preceding siblings ...)
2022-06-03 18:50 ` [PATCH v4 11/11] hw/isa/piix3: Inline and remove piix3_create() Bernhard Beschow
@ 2022-06-06 10:38 ` Mark Cave-Ayland
2022-06-11 9:47 ` Philippe Mathieu-Daudé via
12 siblings, 0 replies; 14+ messages in thread
From: Mark Cave-Ayland @ 2022-06-06 10:38 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Aurelien Jarno, Philippe Mathieu-Daudé, Marcel Apfelbaum,
Richard Henderson, Eduardo Habkost, Michael S. Tsirkin,
Hervé Poussineau, Paolo Bonzini
On 03/06/2022 19:50, Bernhard Beschow wrote:
> v4:
> * Rebase onto https://patchew.org/QEMU/20220530112718.26582-1-philippe.mathieu.daude@gmail.com/
> * Cosmetics (fix typo, omit "include") (Mark, Philippe)
> * Split piix3 and piix4 (Philippe)
> * s/Found-by/Reported-by/ (Philippe)
> * Don't alias smbus (Mark)
>
> v3:
> * Rebase onto 'hw/acpi/piix4: remove legacy piix4_pm_init() function' (Mark) [1]
> * Use embedded structs for touched PCI devices (Mark)
> * Fix piix4's rtc embedded struct to be initialized by
> object_initialize_child() (Peter) [2]
>
> Testing done:
>
> 1)
> `make check-avocado` for --target-list=x86_64-softmmu,mips-softmmu
> Result: All pass.
>
> 2)
> * `qemu-system-x86_64 -M pc -m 2G -cdrom archlinux-2022.05.01-x86_64.iso`
> * `qemu-system-mipsel -M malta -kernel vmlinux-3.2.0-4-4kc-malta -hda
> debian_wheezy_mipsel_standard.qcow2 -append "root=/dev/sda1 console=tty0"`
>
> In both cases the system booted successfully and it was possible to shut down
> the system using the `poweroff` command.
>
> v2:
> * Preserve `DeviceState *` as return value of piix4_create() (Mark)
> * Aggregate all type name movements into first commit (Mark)
> * Have piix4 southbridge rather than malta board instantiate piix4 pm (me)
>
> Testing done:
>
> 1)
> `make check-avocado` for --target-list=x86_64-softmmu,mips-softmmu
> Result: All pass.
>
> 2)
> Modify pci_piix3_realize() to start with
> error_setg(errp, "This is a test");
> Then start `qemu-system-x86_64 -M pc -m 1G -accel kvm -cpu host -cdrom
> archlinux-2022.05.01-x86_64.iso`.
> Result: qemu-system-x86_64 aborts with: "This is a test"
>
> v1:
> The piix3 and piix4 southbridge devices still rely on create() functions which
> are deprecated. This series resolves these functions piece by piece to
> modernize the code.
>
> Both devices are modified in lockstep where possible to provide more context.
>
> Testing done:
> * `qemu-system-x86_64 -M pc -m 2G -cdrom archlinux-2022.05.01-x86_64.iso`
> * `qemu-system-mipsel -M malta -kernel vmlinux-3.2.0-4-4kc-malta -hda
> debian_wheezy_mipsel_standard.qcow2 -append "root=/dev/sda1 console=tty0"`
>
> In both cases the system booted successfully and it was possible to shut down
> the system using the `poweroff` command.
>
> [1] https://lists.gnu.org/archive/html/qemu-devel/2022-05/msg05686.html
> [2] https://lists.gnu.org/archive/html/qemu-devel/2022-02/msg01128.html
>
> Bernhard Beschow (11):
> hw/southbridge/piix: Aggregate all PIIX southbridge type names
> hw/isa/piix4: Use object_initialize_child() for embedded struct
> hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn
> hw/isa/piix4: QOM'ify PCI device creation and wiring
> hw/isa/piix4: Factor out ISABus retrieval from piix4_create()
> hw/isa/piix4: QOM'ify PIIX4 PM creation
> hw/isa/piix4: Inline and remove piix4_create()
> hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn
> hw/isa/piix3: QOM'ify PCI device creation and wiring
> hw/isa/piix3: Factor out ISABus retrieval from piix3_create()
> hw/isa/piix3: Inline and remove piix3_create()
>
> hw/i386/pc_piix.c | 7 +-
> hw/isa/piix3.c | 98 +++++++++++++++-------------
> hw/isa/piix4.c | 119 +++++++++++++++++-----------------
> hw/mips/malta.c | 9 ++-
> include/hw/isa/isa.h | 2 -
> include/hw/southbridge/piix.h | 6 +-
> 6 files changed, 128 insertions(+), 113 deletions(-)
I've had quick look over this and it seems fine to me, so for the entire series:
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
ATB,
Mark.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 00/11] QOM'ify PIIX southbridge creation
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
` (11 preceding siblings ...)
2022-06-06 10:38 ` [PATCH v4 00/11] QOM'ify PIIX southbridge creation Mark Cave-Ayland
@ 2022-06-11 9:47 ` Philippe Mathieu-Daudé via
12 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-06-11 9:47 UTC (permalink / raw)
To: Bernhard Beschow, qemu-devel
Cc: Aurelien Jarno, Marcel Apfelbaum, Richard Henderson,
Eduardo Habkost, Michael S. Tsirkin, Hervé Poussineau,
Paolo Bonzini
On 3/6/22 20:50, Bernhard Beschow wrote:
> Bernhard Beschow (11):
> hw/southbridge/piix: Aggregate all PIIX southbridge type names
> hw/isa/piix4: Use object_initialize_child() for embedded struct
> hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn
> hw/isa/piix4: QOM'ify PCI device creation and wiring
> hw/isa/piix4: Factor out ISABus retrieval from piix4_create()
> hw/isa/piix4: QOM'ify PIIX4 PM creation
> hw/isa/piix4: Inline and remove piix4_create()
> hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn
> hw/isa/piix3: QOM'ify PCI device creation and wiring
> hw/isa/piix3: Factor out ISABus retrieval from piix3_create()
> hw/isa/piix3: Inline and remove piix3_create()
Series queued via mips-next, thanks!
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2022-06-11 9:49 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-03 18:50 [PATCH v4 00/11] QOM'ify PIIX southbridge creation Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 01/11] hw/southbridge/piix: Aggregate all PIIX southbridge type names Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 02/11] hw/isa/piix4: Use object_initialize_child() for embedded struct Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 03/11] hw/isa/piix4: Move pci_map_irq_fn' near pci_set_irq_fn Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 04/11] hw/isa/piix4: QOM'ify PCI device creation and wiring Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 05/11] hw/isa/piix4: Factor out ISABus retrieval from piix4_create() Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 06/11] hw/isa/piix4: QOM'ify PIIX4 PM creation Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 07/11] hw/isa/piix4: Inline and remove piix4_create() Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 08/11] hw/isa/piix3: Move pci_map_irq_fn near pci_set_irq_fn Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 09/11] hw/isa/piix3: QOM'ify PCI device creation and wiring Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 10/11] hw/isa/piix3: Factor out ISABus retrieval from piix3_create() Bernhard Beschow
2022-06-03 18:50 ` [PATCH v4 11/11] hw/isa/piix3: Inline and remove piix3_create() Bernhard Beschow
2022-06-06 10:38 ` [PATCH v4 00/11] QOM'ify PIIX southbridge creation Mark Cave-Ayland
2022-06-11 9:47 ` Philippe Mathieu-Daudé via
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).