From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44125) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWKnl-0003yR-Rq for qemu-devel@nongnu.org; Thu, 08 Nov 2012 00:37:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TWKnk-0003yM-BM for qemu-devel@nongnu.org; Thu, 08 Nov 2012 00:37:17 -0500 Received: from e28smtp03.in.ibm.com ([122.248.162.3]:40278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWKnj-0003xx-Ks for qemu-devel@nongnu.org; Thu, 08 Nov 2012 00:37:16 -0500 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Nov 2012 11:07:13 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qA85bASb42139880 for ; Thu, 8 Nov 2012 11:07:10 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qA8B72qm004360 for ; Thu, 8 Nov 2012 11:07:02 GMT From: Wanpeng Li Date: Thu, 8 Nov 2012 13:36:34 +0800 Message-Id: <1352352999-2561-6-git-send-email-liwanp@linux.vnet.ibm.com> In-Reply-To: <1352352999-2561-1-git-send-email-liwanp@linux.vnet.ibm.com> References: <1352352999-2561-1-git-send-email-liwanp@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 05/10] convert PORT92 as piix3 proper QOM child List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Ram Pai , "Michael S. Tsirkin" , Jan Kiszka , qemu-devel@nongnu.org, Liu Ping Fan , Blue Swirl , Stefan Weil , Avi Kivity , Paolo Bonzini , Wanpeng Li 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 --- 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