qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: "Michael S . Tsirkin" <mst@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Marcel Apfelbaum" <marcel@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Alexey Kardashevskiy" <aik@ozlabs.ru>,
	"Thomas Huth" <thuth@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org, "Richard Henderson" <rth@twiddle.net>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Yongbok Kim" <yongbok.kim@mips.com>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Guan Xuetao" <gxt@mprc.pku.edu.cn>
Subject: [Qemu-devel] [PATCH 25/25] hw/i386/pc: Factor out the superio code
Date: Thu,  8 Mar 2018 23:39:46 +0100	[thread overview]
Message-ID: <20180308223946.26784-26-f4bug@amsat.org> (raw)
In-Reply-To: <20180308223946.26784-1-f4bug@amsat.org>

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/i386/pc.c | 72 ++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 41 insertions(+), 31 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index cdcdfafe8e..20fa62f5d6 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1519,6 +1519,44 @@ static const MemoryRegionOps ioportF0_io_ops = {
     },
 };
 
+static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_vmport)
+{
+    int i;
+    DriveInfo *fd[MAX_FD];
+    qemu_irq *a20_line;
+    ISADevice *i8042, *port92, *vmmouse;
+
+    serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
+    parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
+
+    for (i = 0; i < MAX_FD; i++) {
+        fd[i] = drive_get(IF_FLOPPY, 0, i);
+        create_fdctrl |= !!fd[i];
+    }
+    if (create_fdctrl) {
+        fdctrl_init_isa(isa_bus, fd);
+    }
+
+    i8042 = isa_create_simple(isa_bus, "i8042");
+    if (!no_vmport) {
+        vmport_init(isa_bus);
+        vmmouse = isa_try_create(isa_bus, "vmmouse");
+    } else {
+        vmmouse = NULL;
+    }
+    if (vmmouse) {
+        DeviceState *dev = DEVICE(vmmouse);
+        qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
+        qdev_init_nofail(dev);
+    }
+    port92 = isa_create_simple(isa_bus, "port92");
+
+    a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
+    i8042_setup_a20_line(i8042, a20_line[0]);
+    port92_init(port92, a20_line[1]);
+    g_free(a20_line);
+}
+
 void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
                           ISADevice **rtc_state,
                           bool create_fdctrl,
@@ -1527,13 +1565,11 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
                           uint32_t hpet_irqs)
 {
     int i;
-    DriveInfo *fd[MAX_FD];
     DeviceState *hpet = NULL;
     int pit_isa_irq = 0;
     qemu_irq pit_alt_irq = NULL;
     qemu_irq rtc_irq = NULL;
-    qemu_irq *a20_line;
-    ISADevice *i8042, *port92, *vmmouse, *pit = NULL;
+    ISADevice *pit = NULL;
     MemoryRegion *ioport80_io = g_new(MemoryRegion, 1);
     MemoryRegion *ioportF0_io = g_new(MemoryRegion, 1);
 
@@ -1590,36 +1626,10 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
         pcspk_init(isa_bus, pit);
     }
 
-    serial_hds_isa_init(isa_bus, 0, MAX_SERIAL_PORTS);
-    parallel_hds_isa_init(isa_bus, MAX_PARALLEL_PORTS);
-
-    a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
-    i8042 = isa_create_simple(isa_bus, "i8042");
-    i8042_setup_a20_line(i8042, a20_line[0]);
-    if (!no_vmport) {
-        vmport_init(isa_bus);
-        vmmouse = isa_try_create(isa_bus, "vmmouse");
-    } else {
-        vmmouse = NULL;
-    }
-    if (vmmouse) {
-        DeviceState *dev = DEVICE(vmmouse);
-        qdev_prop_set_ptr(dev, "ps2_mouse", i8042);
-        qdev_init_nofail(dev);
-    }
-    port92 = isa_create_simple(isa_bus, "port92");
-    port92_init(port92, a20_line[1]);
-    g_free(a20_line);
-
     i8257_dma_init(isa_bus, 0);
 
-    for(i = 0; i < MAX_FD; i++) {
-        fd[i] = drive_get(IF_FLOPPY, 0, i);
-        create_fdctrl |= !!fd[i];
-    }
-    if (create_fdctrl) {
-        fdctrl_init_isa(isa_bus, fd);
-    }
+    /* Super I/O */
+    pc_superio_init(isa_bus, create_fdctrl, no_vmport);
 }
 
 void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus)
-- 
2.16.2

      parent reply	other threads:[~2018-03-08 22:40 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08 22:39 [Qemu-devel] [PATCH 00/25] remove i386/pc dependency: generic SuperIO Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 01/25] hw/isa: Move parallel_hds_isa_init() to hw/char/parallel-isa.c Philippe Mathieu-Daudé
2018-03-09 10:28   ` Mark Cave-Ayland
2018-03-08 22:39 ` [Qemu-devel] [PATCH 02/25] hw/dma/i8257: Rename DMA_init() to i8257_dma_init() Philippe Mathieu-Daudé
2018-03-09 10:32   ` Mark Cave-Ayland
2018-03-09 10:43     ` Philippe Mathieu-Daudé
2018-03-09 12:19       ` Mark Cave-Ayland
2018-03-09 20:51         ` Artyom Tarasenko
2018-03-10  9:33           ` Mark Cave-Ayland
2018-03-08 22:39 ` [Qemu-devel] [PATCH 03/25] hw/input/i8042: Extract declarations from i386/pc.h into input/i8042.h Philippe Mathieu-Daudé
2018-03-09 10:33   ` Mark Cave-Ayland
2018-03-08 22:39 ` [Qemu-devel] [PATCH 04/25] MAINTAINERS: Fix the PC87312 include path Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 05/25] hw/isa/pc87312: Rename the device type as TYPE_PC87312_SUPERIO Philippe Mathieu-Daudé
2018-03-09 10:33   ` Mark Cave-Ayland
2018-03-08 22:39 ` [Qemu-devel] [PATCH 06/25] hw/isa/pc87312: Use uint16_t for the ISA I/O base address Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 07/25] hw/isa/pc87312: Use 'unsigned int' for the irq value Philippe Mathieu-Daudé
2018-03-09 10:35   ` Mark Cave-Ayland
2018-03-08 22:39 ` [Qemu-devel] [PATCH 08/25] hw/isa/superio: Add a Super I/O template based on the PC87312 device Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 09/25] hw/isa/pc87312: Inherit from the abstract TYPE_ISA_SUPERIO Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 10/25] hw/isa/superio: Factor out the parallel code from pc87312.c Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 11/25] hw/isa/superio: Factor out the serial " Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 12/25] hw/isa/superio: Factor out the floppy disc controller " Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 13/25] hw/isa/superio: Add a keyboard/mouse controller (8042) Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 14/25] hw/isa/superio: Factor out the IDE code from pc87312.c Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 15/25] hw/mips/malta: Code movement Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 16/25] hw/isa/superio: Factor out the FDC37M817 Super I/O from mips_malta.c Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 17/25] hw/mips/mips_fulong2e: Factor out vt82c686b_southbridge_init() Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 18/25] hw/isa/vt82c686: Rename vt82c686b_init() -> vt82c686b_isa_init() Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 19/25] hw/isa/vt82c686: Add the TYPE_VT82C686B_SUPERIO Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 20/25] MAINTAINERS: Add entries for the VT82C686B Super I/O Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 21/25] MAINTAINERS: Split the Alpha TCG/machine section Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 22/25] hw/isa/superio: Add the SMC FDC37C669 Super I/O Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 23/25] hw/alpha/dp264: Add the ISA DMA controller Philippe Mathieu-Daudé
2018-03-08 22:39 ` [Qemu-devel] [PATCH 24/25] hw/alpha/dp264: Use the TYPE_SMC37C669_SUPERIO Philippe Mathieu-Daudé
2018-03-08 22:39 ` Philippe Mathieu-Daudé [this message]

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=20180308223946.26784-26-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=aik@ozlabs.ru \
    --cc=atar4qemu@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=ehabkost@redhat.com \
    --cc=gxt@mprc.pku.edu.cn \
    --cc=hpoussin@reactos.org \
    --cc=marcel@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    --cc=yongbok.kim@mips.com \
    /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).