[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/20] hw/isa/piix4: Move piix4_create() to hw/isa/piix4.c
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 11/20] hw/isa/piix4: Move piix4_create() to hw/isa/piix4.c |
Date: |
Mon, 28 Oct 2019 17:34:38 +0100 |
From: Philippe Mathieu-Daudé <address@hidden>
Now that we properly refactored the piix4_create() function, let's
move it to hw/isa/piix4.c where it belongs, so it can be reused
on other places.
Reviewed-by: Aleksandar Markovic <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/isa/piix4.c | 30 ++++++++++++++++++++++++++++++
hw/mips/gt64xxx_pci.c | 1 +
hw/mips/mips_malta.c | 28 ----------------------------
include/hw/i386/pc.h | 2 --
include/hw/southbridge/piix.h | 6 ++++++
5 files changed, 37 insertions(+), 30 deletions(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 6bf6f0c5d9..f3e21ea76d 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -27,12 +27,14 @@
#include "qapi/error.h"
#include "hw/irq.h"
#include "hw/i386/pc.h"
+#include "hw/southbridge/piix.h"
#include "hw/pci/pci.h"
#include "hw/isa/isa.h"
#include "hw/sysbus.h"
#include "hw/dma/i8257.h"
#include "hw/timer/i8254.h"
#include "hw/rtc/mc146818rtc.h"
+#include "hw/ide.h"
#include "migration/vmstate.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
@@ -237,3 +239,31 @@ static void piix4_register_types(void)
}
type_init(piix4_register_types)
+
+DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus,
+ I2CBus **smbus, size_t ide_buses)
+{
+ size_t ide_drives = ide_buses * MAX_IDE_DEVS;
+ DriveInfo **hd;
+ PCIDevice *pci;
+ DeviceState *dev;
+
+ pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),
+ true, TYPE_PIIX4_PCI_DEVICE);
+ dev = DEVICE(pci);
+ if (isa_bus) {
+ *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
+ }
+
+ hd = g_new(DriveInfo *, ide_drives);
+ ide_drive_get(hd, ide_drives);
+ pci_piix4_ide_init(pci_bus, hd, pci->devfn + 1);
+ g_free(hd);
+ pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
+ if (smbus) {
+ *smbus = piix4_pm_init(pci_bus, pci->devfn + 3, 0x1100,
+ isa_get_irq(NULL, 9), NULL, 0, NULL);
+ }
+
+ return dev;
+}
diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c
index f325bd6c1c..c277398c0d 100644
--- a/hw/mips/gt64xxx_pci.c
+++ b/hw/mips/gt64xxx_pci.c
@@ -28,6 +28,7 @@
#include "hw/mips/mips.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_host.h"
+#include "hw/southbridge/piix.h"
#include "migration/vmstate.h"
#include "hw/i386/pc.h"
#include "hw/irq.h"
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 9014d77b7a..92e9ca5bfa 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -1210,34 +1210,6 @@ static void mips_create_cpu(MachineState *ms, MaltaState
*s,
}
}
-static DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus,
- I2CBus **smbus, size_t ide_buses)
-{
- const size_t ide_drives = ide_buses * MAX_IDE_DEVS;
- DriveInfo **hd;
- PCIDevice *pci;
- DeviceState *dev;
-
- pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),
- true, TYPE_PIIX4_PCI_DEVICE);
- dev = DEVICE(pci);
- if (isa_bus) {
- *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0"));
- }
-
- hd = g_new(DriveInfo *, ide_drives);
- ide_drive_get(hd, ide_drives);
- pci_piix4_ide_init(pci_bus, hd, pci->devfn + 1);
- g_free(hd);
- pci_create_simple(pci_bus, pci->devfn + 2, "piix4-usb-uhci");
- if (smbus) {
- *smbus = piix4_pm_init(pci_bus, pci->devfn + 3, 0x1100,
- isa_get_irq(NULL, 9), NULL, 0, NULL);
- }
-
- return dev;
-}
-
static
void mips_malta_init(MachineState *machine)
{
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index c933c0d3a1..2fd40ceebe 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -258,8 +258,6 @@ PCIBus *i440fx_init(const char *host_type, const char
*pci_type,
MemoryRegion *ram_memory);
PCIBus *find_i440fx(void);
-/* piix4.c */
-extern PCIDevice *piix4_dev;
/* pc_sysfw.c */
void pc_system_flash_create(PCMachineState *pcms);
diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h
index b8ce26fec4..add352456b 100644
--- a/include/hw/southbridge/piix.h
+++ b/include/hw/southbridge/piix.h
@@ -2,6 +2,7 @@
* QEMU PIIX South Bridge Emulation
*
* Copyright (c) 2006 Fabrice Bellard
+ * Copyright (c) 2018 Hervé Poussineau
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
@@ -17,4 +18,9 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t
smb_io_base,
qemu_irq sci_irq, qemu_irq smi_irq,
int smm_enabled, DeviceState **piix4_pm);
+extern PCIDevice *piix4_dev;
+
+DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus,
+ I2CBus **smbus, size_t ide_buses);
+
#endif
--
2.21.0
- [PULL 00/20] hw/i386/pc: Split PIIX3 southbridge from i440FX northbridge, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 01/20] MAINTAINERS: Keep PIIX4 South Bridge separate from PC Chipsets, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 02/20] piix4: Add the Reset Control Register, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 03/20] piix4: Add an i8259 Interrupt Controller as specified in datasheet, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 05/20] piix4: Rename PIIX4 object to piix4-isa, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 04/20] Revert "irq: introduce qemu_irq_proxy()", Philippe Mathieu-Daudé, 2019/10/28
- [PULL 06/20] piix4: Add an i8257 DMA Controller as specified in datasheet, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 07/20] piix4: Add an i8254 PIT Controller as specified in datasheet, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 09/20] hw/mips/mips_malta: Create IDE hard drive array dynamically, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 08/20] piix4: Add a MC146818 RTC Controller as specified in datasheet, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 11/20] hw/isa/piix4: Move piix4_create() to hw/isa/piix4.c,
Philippe Mathieu-Daudé <=
- [PULL 10/20] hw/mips/mips_malta: Extract the PIIX4 creation code as piix4_create(), Philippe Mathieu-Daudé, 2019/10/28
- [PULL 12/20] hw/i386: Remove obsolete LoadStateHandler::load_state_old handlers, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 13/20] hw/pci-host/piix: Extract piix3_create(), Philippe Mathieu-Daudé, 2019/10/28
- [PULL 14/20] hw/pci-host/piix: Move RCR_IOPORT register definition, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 15/20] hw/pci-host/piix: Define and use the PIIX IRQ Route Control Registers, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 17/20] hw/pci-host/piix: Fix code style issues, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 16/20] hw/pci-host/piix: Move i440FX declarations to hw/pci-host/i440fx.h, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 19/20] hw/pci-host: Rename incorrectly named 'piix' as 'i440fx', Philippe Mathieu-Daudé, 2019/10/28
- [PULL 18/20] hw/pci-host/piix: Extract PIIX3 functions to hw/isa/piix3.c, Philippe Mathieu-Daudé, 2019/10/28
- [PULL 20/20] hw/pci-host/i440fx: Remove the last PIIX3 traces, Philippe Mathieu-Daudé, 2019/10/28