From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Stefano Stabellini" <sstabellini@kernel.org>,
xen-devel@lists.xenproject.org,
"Bernhard Beschow" <shentey@gmail.com>,
"Thomas Huth" <thuth@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Anthony Perard" <anthony.perard@citrix.com>,
"Ani Sinha" <anisinha@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [RFC PATCH-for-9.1 04/29] hw/i386/pc: Introduce PC_PCI_MACHINE QOM type
Date: Thu, 28 Mar 2024 16:54:12 +0100 [thread overview]
Message-ID: <20240328155439.58719-5-philmd@linaro.org> (raw)
In-Reply-To: <20240328155439.58719-1-philmd@linaro.org>
Introduce TYPE_PC_PCI_MACHINE for machines where PCI
is expected (as opposition to the ISA-only PC machine).
This type inherits from the well known TYPE_PC_MACHINE.
Convert I440FX/PIIX and Q35 machines to use it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/i386/pc.h | 25 ++++++++++++++++---------
hw/i386/pc.c | 25 +++++++++++++++++++++++++
hw/i386/pc_piix.c | 6 +++---
hw/i386/pc_q35.c | 2 +-
4 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 33023ebbbe..1a4a61148a 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -22,11 +22,8 @@
* @boot_cpus: number of present VCPUs
*/
typedef struct PCMachineState {
- /*< private >*/
X86MachineState parent_obj;
- /* <public> */
-
/* State for other subsystems/APIs: */
Notifier machine_done;
@@ -60,6 +57,12 @@ typedef struct PCMachineState {
CXLState cxl_devices_state;
} PCMachineState;
+typedef struct PcPciMachineState {
+ PCMachineState parent_obj;
+
+ Notifier machine_done;
+} PcPciMachineState;
+
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
#define PC_MACHINE_VMPORT "vmport"
@@ -80,12 +83,9 @@ typedef struct PCMachineState {
* way we can use 1GByte pages in the host.
*
*/
-struct PCMachineClass {
- /*< private >*/
+typedef struct PCMachineClass {
X86MachineClass parent_class;
- /*< public >*/
-
/* Device configuration: */
bool pci_enabled;
const char *default_south_bridge;
@@ -124,13 +124,20 @@ struct PCMachineClass {
* check for memory.
*/
bool broken_32bit_mem_addr_check;
-};
+} PCMachineClass;
-#define TYPE_PC_MACHINE "generic-pc-machine"
+typedef struct PcPciMachineClass {
+ PCMachineClass parent_class;
+} PcPciMachineClass;
+
+#define TYPE_PC_MACHINE "common-pc-machine"
OBJECT_DECLARE_TYPE(PCMachineState, PCMachineClass, PC_MACHINE)
bool pc_machine_is_pci_enabled(PCMachineState *pcms);
+#define TYPE_PC_PCI_MACHINE "pci-pc-machine"
+OBJECT_DECLARE_TYPE(PcPciMachineState, PcPciMachineClass, PC_PCI_MACHINE)
+
/* ioapic.c */
GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled);
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 7065f11e97..eafd521489 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -621,6 +621,10 @@ void pc_machine_done(Notifier *notifier, void *data)
pc_cmos_init_late(pcms);
}
+static void pc_pci_machine_done(Notifier *notifier, void *data)
+{
+}
+
/* setup pci memory address space mapping into system address space */
void pc_pci_as_mapping_init(MemoryRegion *system_memory,
MemoryRegion *pci_address_space)
@@ -1678,6 +1682,14 @@ static void pc_machine_initfn(Object *obj)
qemu_add_machine_init_done_notifier(&pcms->machine_done);
}
+static void pc_pci_machine_initfn(Object *obj)
+{
+ PcPciMachineState *ppms = PC_PCI_MACHINE(obj);
+
+ ppms->machine_done.notify = pc_pci_machine_done;
+ qemu_add_machine_init_done_notifier(&ppms->machine_done);
+}
+
static void pc_machine_reset(MachineState *machine, ShutdownCause reason)
{
CPUState *cs;
@@ -1812,6 +1824,10 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
pc_machine_set_fd_bootchk);
}
+static void pc_pci_machine_class_init(ObjectClass *oc, void *data)
+{
+}
+
bool pc_machine_is_pci_enabled(PCMachineState *pcms)
{
return PC_MACHINE_GET_CLASS(pcms)->pci_enabled;
@@ -1831,6 +1847,15 @@ static const TypeInfo pc_machine_types[] = {
{ }
},
},
+ {
+ .name = TYPE_PC_PCI_MACHINE,
+ .parent = TYPE_PC_MACHINE,
+ .abstract = true,
+ .instance_size = sizeof(PcPciMachineState),
+ .instance_init = pc_pci_machine_initfn,
+ .class_size = sizeof(PcPciMachineClass),
+ .class_init = pc_pci_machine_class_init,
+ },
};
DEFINE_TYPES(pc_machine_types)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index b9f85148e3..7ada452f91 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -463,7 +463,7 @@ static void pc_xen_hvm_init(MachineState *machine)
pc_init1(machine, TYPE_I440FX_PCI_DEVICE); \
} \
DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn, \
- TYPE_PC_MACHINE)
+ TYPE_PC_PCI_MACHINE)
static void pc_i440fx_machine_options(MachineClass *m)
{
@@ -838,7 +838,7 @@ static void xenfv_4_2_machine_options(MachineClass *m)
}
DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init,
- xenfv_4_2_machine_options, TYPE_PC_MACHINE);
+ xenfv_4_2_machine_options, TYPE_PC_PCI_MACHINE);
static void xenfv_3_1_machine_options(MachineClass *m)
{
@@ -850,5 +850,5 @@ static void xenfv_3_1_machine_options(MachineClass *m)
}
DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init,
- xenfv_3_1_machine_options, TYPE_PC_MACHINE);
+ xenfv_3_1_machine_options, TYPE_PC_PCI_MACHINE);
#endif
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 7dbee38f03..c3b0467ef3 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -339,7 +339,7 @@ static void pc_q35_init(MachineState *machine)
pc_q35_init(machine); \
} \
DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn, \
- TYPE_PC_MACHINE)
+ TYPE_PC_PCI_MACHINE)
static void pc_q35_machine_options(MachineClass *m)
--
2.41.0
next prev parent reply other threads:[~2024-03-28 15:55 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 15:54 [RFC PATCH-for-9.1 00/29] hw/i386/pc: Decouple ISA vs PCI-based machines Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 01/29] hw/i386/pc: Declare CPU QOM types using DEFINE_TYPES() macro Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 02/29] hw/i386/pc: Extract pc_machine_is_pci_enabled() helper Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 03/29] hw/i386/pc: Pass base machine type as argument to DEFINE_PC_MACHINE() Philippe Mathieu-Daudé
2024-03-28 15:54 ` Philippe Mathieu-Daudé [this message]
2024-03-28 15:54 ` [RFC PATCH-for-9.1 05/29] hw/i386/pc: Remove PCMachineClass::pci_enabled field Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 06/29] hw/i386/pc: Move pci_root_uid field to PcPciMachineClass Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 07/29] hw/i386/pc: Call fw_cfg_add_extra_pci_roots() in pc_pci_machine_done() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 08/29] hw/i386/pc: Move CXLState to PcPciMachineState Philippe Mathieu-Daudé
2024-04-01 16:05 ` Jonathan Cameron via
2024-03-28 15:54 ` [RFC PATCH-for-9.1 09/29] hw/i386/pc: Pass PCMachineState argument to acpi_setup() Philippe Mathieu-Daudé
2024-03-28 18:45 ` BALATON Zoltan
2024-03-29 10:23 ` Philippe Mathieu-Daudé
2024-04-06 10:38 ` Bernhard Beschow
2024-03-28 15:54 ` [RFC PATCH-for-9.1 10/29] hw/i386/pc: Remove PCMachineClass::has_acpi_build field Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 11/29] hw/i386/pc: Move acpi_setup() call to pc_pci_machine_done() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 12/29] hw/i386/pc: Move acpi_build_enabled to PcPciMachineState Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 13/29] hw/i386/pc: Remove non-PCI code from pc_system_firmware_init() Philippe Mathieu-Daudé
2024-03-28 18:50 ` BALATON Zoltan
2024-04-06 10:35 ` Bernhard Beschow
2024-03-28 15:54 ` [RFC PATCH-for-9.1 14/29] hw/i386/pc: Move pc_system_flash_create() to pc_pci_machine_initfn() Philippe Mathieu-Daudé
2024-03-28 18:52 ` BALATON Zoltan
2024-03-28 15:54 ` [RFC PATCH-for-9.1 15/29] hw/i386/pc: Move FW/pflash related fields to PcPciMachineState Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 16/29] hw/i386/pc: Move south-bridge related fields to PcPciMachine Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 17/29] hw/i386/pc: Inline gigabyte_align() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 18/29] hw/i386/pc: Inline has_reserved_memory() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 19/29] hw/i386/pc: Pass PcPciMachineState argument to CXL helpers Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 20/29] hw/i386/pc: Pass PcPciMachineState argument to pc_pci_hole64_start() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 21/29] hw/i386/fw_cfg: Include missing 'qapi-types-machine.h' header Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 22/29] hw/i386/fw_cfg: Define fw_cfg_build_smbios() stub Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 23/29] hw/i386/fw_cfg: Inline smbios_defaults() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 24/29] hw/i386/fw_cfg: Inline smbios_legacy_mode() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 25/29] hw/i386/fw_cfg: Replace smbios_defaults() by !smbios_legacy_mode() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 26/29] hw/i386/fw_cfg: Factor fw_cfg_build_smbios_legacy() out Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 27/29] hw/i386/pc: Call fw_cfg_build_smbios_legacy() in pc_machine_done() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 28/29] hw/i386/pc: Rename pc_init1() -> pc_piix_init() Philippe Mathieu-Daudé
2024-03-28 15:54 ` [RFC PATCH-for-9.1 29/29] hw/i386/pc: Move ISA-only PC machine to pc_isa.c Philippe Mathieu-Daudé
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=20240328155439.58719-5-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=anisinha@redhat.com \
--cc=anthony.perard@citrix.com \
--cc=eduardo@habkost.net \
--cc=imammedo@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shentey@gmail.com \
--cc=sstabellini@kernel.org \
--cc=thuth@redhat.com \
--cc=xen-devel@lists.xenproject.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).