From: Wanpeng Li <liwanp@linux.vnet.ibm.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Ram Pai <pair@us.ibm.com>, "Michael S. Tsirkin" <mst@redhat.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
qemu-devel@nongnu.org, Liu Ping Fan <kernelfans@gmail.com>,
Blue Swirl <blauwirbel@gmail.com>,
Stefan Weil <weil@mail.berlios.de>, Avi Kivity <avi@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <liwanp@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 05/10] convert PORT92 as piix3 proper QOM child
Date: Thu, 8 Nov 2012 13:36:34 +0800 [thread overview]
Message-ID: <1352352999-2561-6-git-send-email-liwanp@linux.vnet.ibm.com> (raw)
In-Reply-To: <1352352999-2561-1-git-send-email-liwanp@linux.vnet.ibm.com>
convert PORT92 as piix3 proper QOM child.
PORT92 creation for the PIIX3 is done by calling object_init() with
qdev_init() being called for each child device in the PIIX3 ::init
function.
Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
hw/pc.c | 25 ++++---------------------
hw/pc.h | 3 +++
hw/piix3.c | 10 ++++++++++
hw/piix3.h | 11 +++++++++++
4 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 80b437f..94fdea9 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -421,14 +421,6 @@ static void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
qemu_register_reset(pc_cmos_init_late, &arg);
}
-/* port 92 stuff: could be split off */
-typedef struct Port92State {
- ISADevice dev;
- MemoryRegion io;
- uint8_t outport;
- qemu_irq *a20_out;
-} Port92State;
-
static void port92_write(void *opaque, hwaddr addr, uint64_t val,
unsigned size)
{
@@ -453,13 +445,6 @@ static uint64_t port92_read(void *opaque, hwaddr addr,
return ret;
}
-static void port92_init(ISADevice *dev, qemu_irq *a20_out)
-{
- Port92State *s = DO_UPCAST(Port92State, dev, dev);
-
- s->a20_out = a20_out;
-}
-
static const VMStateDescription vmstate_port92_isa = {
.name = "port92",
.version_id = 1,
@@ -510,7 +495,7 @@ static void port92_class_initfn(ObjectClass *klass, void *data)
}
static TypeInfo port92_info = {
- .name = "port92",
+ .name = TYPE_PORT92,
.parent = TYPE_ISA_DEVICE,
.instance_size = sizeof(Port92State),
.class_init = port92_class_initfn,
@@ -523,7 +508,7 @@ static void port92_register_types(void)
type_init(port92_register_types)
-static void handle_a20_line_change(void *opaque, int irq, int level)
+void handle_a20_line_change(void *opaque, int irq, int level)
{
CPUX86State *cpu = opaque;
@@ -947,7 +932,7 @@ static void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
int i;
DriveInfo *fd[MAX_FD];
qemu_irq *a20_line;
- ISADevice *i8042, *port92, *vmmouse;
+ ISADevice *i8042, *vmmouse;
qemu_irq *cpu_exit_irq;
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
@@ -966,7 +951,7 @@ static void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
}
}
- a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
+ a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 1);
i8042 = isa_create_simple(isa_bus, "i8042");
i8042_setup_a20_line(i8042, &a20_line[0]);
if (!no_vmport) {
@@ -979,8 +964,6 @@ static void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
qdev_init_nofail(&vmmouse->qdev);
}
- port92 = isa_create_simple(isa_bus, "port92");
- port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(0, cpu_exit_irq);
diff --git a/hw/pc.h b/hw/pc.h
index d4b149e..17d48a0 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -9,6 +9,7 @@
#include "net.h"
#include "memory.h"
#include "ioapic.h"
+#include "piix3.h"
#include "i440fx.h"
/* PC-style peripherals (also used by other machines). */
@@ -144,4 +145,6 @@ void pc_system_firmware_init(MemoryRegion *rom_memory);
int e820_add_entry(uint64_t, uint64_t, uint32_t);
+void handle_a20_line_change(void *opaque, int irq, int level);
+
#endif
diff --git a/hw/piix3.c b/hw/piix3.c
index 35a0de9..675212e 100644
--- a/hw/piix3.c
+++ b/hw/piix3.c
@@ -196,6 +196,7 @@ static int piix3_realize(PCIDevice *dev)
qemu_irq rtc_irq;
int pit_isa_irq = 0;
qemu_irq pit_alt_irq = NULL;
+ qemu_irq *a20_line;
/* Initialize ISA Bus */
s->bus = isa_bus_new(DEVICE(dev), pci_address_space_io(dev));
@@ -256,6 +257,12 @@ static int piix3_realize(PCIDevice *dev)
qdev_prop_set_ptr(DEVICE(&s->pcspk), "pit", ISA_DEVICE(&s->pit));
qdev_init_nofail(DEVICE(&s->pcspk));
+ /* Realize the PORT92 */
+ qdev_set_parent_bus(DEVICE(&s->port92), BUS(s->bus));
+ qdev_init_nofail(DEVICE(&s->port92));
+ a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 1);
+ s->port92.a20_out = &a20_line[0];
+
return 0;
}
@@ -288,6 +295,9 @@ static void piix3_initfn(Object *obj)
object_initialize(&s->pcspk, TYPE_PCSPK);
object_property_add_child(obj, "pcspk", OBJECT(&s->pcspk), NULL);
+
+ object_initialize(&s->port92, TYPE_PORT92);
+ object_property_add_child(obj, "port92", OBJECT(&s->port92), NULL);
}
static void piix3_class_init(ObjectClass *klass, void *data)
diff --git a/hw/piix3.h b/hw/piix3.h
index 32f7a95..4e5ee20 100644
--- a/hw/piix3.h
+++ b/hw/piix3.h
@@ -51,6 +51,16 @@ typedef struct KVMPITState {
int64_t kernel_clock_offset;
} KVMPITState;
+#define TYPE_PORT92 "port92"
+
+/* port 92 stuff: could be split off */
+typedef struct Port92State {
+ ISADevice dev;
+ MemoryRegion io;
+ uint8_t outport;
+ qemu_irq *a20_out;
+} Port92State;
+
typedef struct PIIX3State {
PCIDevice dev;
@@ -79,6 +89,7 @@ typedef struct PIIX3State {
} pit;
#endif
PCSpkState pcspk;
+ Port92State port92;
qemu_irq *pic;
--
1.7.7.6
next prev parent reply other threads:[~2012-11-08 5:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-08 5:36 [Qemu-devel] [PATCH 00/10] piix3: create all child devices as proper QOM children Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 01/10] convert RTC as piix3 proper QOM child Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 02/10] convert HPET " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 03/10] convert PIT " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 04/10] convert PCSPK " Wanpeng Li
2012-11-08 5:36 ` Wanpeng Li [this message]
2012-11-08 5:36 ` [Qemu-devel] [PATCH 06/10] convert i8042 " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 07/10] convert VMPORT " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 08/10] convert VMMOUSE " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 09/10] convert IDE " Wanpeng Li
2012-11-08 5:36 ` [Qemu-devel] [PATCH 10/10] convert IOAPIC " Wanpeng Li
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=1352352999-2561-6-git-send-email-liwanp@linux.vnet.ibm.com \
--to=liwanp@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=kernelfans@gmail.com \
--cc=mst@redhat.com \
--cc=pair@us.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/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).