[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v19 8/9] pc: put PIIX3 in slot 1 explicitly and clea
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH v19 8/9] pc: put PIIX3 in slot 1 explicitly and cleanup functions assignment |
Date: |
Thu, 28 Jan 2016 11:54:29 +0100 |
currently slot for PIIX3 bridge is selected
dynamically but it's always in slot 1 for
existing machine types.
However it's easy to regress if another PCI
device were added before PIIX3 is created and
also requires passing around devfn of the
created bridge.
Replace dynamic slot assignment with a static
one like it's done for ICH9_LPC, explicitly
setting slot # for the bridge.
While at it cleanup IDE/USB/PIIX4_PM functions
assignment, replacing magic offsets with defines.
Signed-off-by: Igor Mammedov <address@hidden>
---
Static assignment will help with adding other
functions to multifunction bridge in following
patch.
---
hw/i386/pc_piix.c | 17 ++++++++++-------
hw/pci-host/piix.c | 9 ++++-----
include/hw/i386/pc.h | 8 +++++++-
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index bc74557..2ea3d84 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -73,7 +73,6 @@ static void pc_init1(MachineState *machine,
PCIBus *pci_bus;
ISABus *isa_bus;
PCII440FXState *i440fx_state;
- int piix3_devfn = -1;
qemu_irq *gsi;
qemu_irq *i8259;
qemu_irq smi_irq;
@@ -179,7 +178,7 @@ static void pc_init1(MachineState *machine,
if (pcmc->pci_enabled) {
pci_bus = i440fx_init(host_type,
pci_type,
- &i440fx_state, &piix3_devfn, &isa_bus, gsi,
+ &i440fx_state, &isa_bus, gsi,
system_memory, system_io, machine->ram_size,
pcms->below_4g_mem_size,
pcms->above_4g_mem_size,
@@ -229,9 +228,11 @@ static void pc_init1(MachineState *machine,
if (pcmc->pci_enabled) {
PCIDevice *dev;
if (xen_enabled()) {
- dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
+ dev = pci_piix3_xen_ide_init(pci_bus, hd,
+ PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_IDE_FUNC));
} else {
- dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
+ dev = pci_piix3_ide_init(pci_bus, hd,
+ PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_IDE_FUNC));
}
idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
@@ -254,7 +255,8 @@ static void pc_init1(MachineState *machine,
pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
if (pcmc->pci_enabled && usb_enabled()) {
- pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
+ pci_create_simple(pci_bus, PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_USB_FUNC),
+ "piix3-usb-uhci");
}
if (pcmc->pci_enabled && acpi_enabled) {
@@ -263,8 +265,9 @@ static void pc_init1(MachineState *machine,
smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
/* TODO: Populate SPD eeprom data. */
- smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
- gsi[9], smi_irq,
+ smbus = piix4_pm_init(pci_bus,
+ PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_PIIX4_PM_FUNC),
+ 0xb100, gsi[9], smi_irq,
pc_machine_is_smm_enabled(pcms),
&piix4_pm);
smbus_eeprom_init(smbus, 8, NULL, 0);
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index b0d7e31..b8bf1fc 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -310,7 +310,6 @@ static void i440fx_realize(PCIDevice *dev, Error **errp)
PCIBus *i440fx_init(const char *host_type, const char *pci_type,
PCII440FXState **pi440fx_state,
- int *piix3_devfn,
ISABus **isa_bus, qemu_irq *pic,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
@@ -382,13 +381,15 @@ PCIBus *i440fx_init(const char *host_type, const char
*pci_type,
* These additional routes can be discovered through ACPI. */
if (xen_enabled()) {
PCIDevice *pci_dev = pci_create_simple_multifunction(b,
- -1, true, "PIIX3-xen");
+ PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_PCI_FUNC),
+ true, "PIIX3-xen");
piix3 = PIIX3_PCI_DEVICE(pci_dev);
pci_bus_irqs(b, xen_piix3_set_irq, xen_pci_slot_get_pirq,
piix3, XEN_PIIX_NUM_PIRQS);
} else {
PCIDevice *pci_dev = pci_create_simple_multifunction(b,
- -1, true, "PIIX3");
+ PCI_DEVFN(PIIX3_PCI_SLOT, PIIX3_PCI_FUNC),
+ true, "PIIX3");
piix3 = PIIX3_PCI_DEVICE(pci_dev);
pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3,
PIIX_NUM_PIRQS);
@@ -397,8 +398,6 @@ PCIBus *i440fx_init(const char *host_type, const char
*pci_type,
piix3->pic = pic;
*isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix3), "isa.0"));
- *piix3_devfn = piix3->dev.devfn;
-
ram_size = ram_size / 8 / 1024 / 1024;
if (ram_size > 255) {
ram_size = 255;
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 7713361..69ed687 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -291,8 +291,14 @@ typedef struct PCII440FXState PCII440FXState;
#define TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE "igd-passthrough-i440FX"
+#define PIIX3_PCI_SLOT 1
+#define PIIX3_PCI_FUNC 0
+#define PIIX3_IDE_FUNC 1
+#define PIIX3_USB_FUNC 2
+#define PIIX3_PIIX4_PM_FUNC 3
+
PCIBus *i440fx_init(const char *host_type, const char *pci_type,
- PCII440FXState **pi440fx_state, int *piix_devfn,
+ PCII440FXState **pi440fx_state,
ISABus **isa_bus, qemu_irq *pic,
MemoryRegion *address_space_mem,
MemoryRegion *address_space_io,
--
1.8.3.1
- [Qemu-devel] [PATCH v19 3/9] pc: add a Virtual Machine Generation ID device, (continued)
[Qemu-devel] [PATCH v19 4/9] tests: add a unit test for the vmgenid device., Igor Mammedov, 2016/01/28
[Qemu-devel] [PATCH v19 5/9] qmp/hmp: add query-vm-generation-id and 'info vm-generation-id' commands, Igor Mammedov, 2016/01/28
[Qemu-devel] [PATCH v19 6/9] qmp/hmp: add set-vm-generation-id commands, Igor Mammedov, 2016/01/28
[Qemu-devel] [PATCH v19 9/9] pc/q53: by default put vmgenid device as an function of ISA bridge, Igor Mammedov, 2016/01/28
[Qemu-devel] [PATCH v19 8/9] pc: put PIIX3 in slot 1 explicitly and cleanup functions assignment,
Igor Mammedov <=
[Qemu-devel] [PATCH v19 7/9] machine: add properties to compat_props incrementaly, Igor Mammedov, 2016/01/28