From patchwork Thu Nov 8 05:36:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 197772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 072A52C00FB for ; Thu, 8 Nov 2012 16:39:09 +1100 (EST) Received: from localhost ([::1]:52521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWKpX-0007mZ-1E for incoming@patchwork.ozlabs.org; Thu, 08 Nov 2012 00:39:07 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWKo2-0004if-PV for qemu-devel@nongnu.org; Thu, 08 Nov 2012 00:37:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TWKo1-00040R-5Q for qemu-devel@nongnu.org; Thu, 08 Nov 2012 00:37:34 -0500 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:36760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWKo0-00040J-IH for qemu-devel@nongnu.org; Thu, 08 Nov 2012 00:37:33 -0500 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Nov 2012 15:36:34 +1000 Received: from d23relay03.au.ibm.com (202.81.31.245) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 8 Nov 2012 15:36:32 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qA85bR5557999504 for ; Thu, 8 Nov 2012 16:37:27 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qA85bRhI023955 for ; Thu, 8 Nov 2012 16:37:27 +1100 Received: from localhost ([9.123.236.63]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qA85bQsr023914; Thu, 8 Nov 2012 16:37:27 +1100 From: Wanpeng Li To: Anthony Liguori Date: Thu, 8 Nov 2012 13:36:37 +0800 Message-Id: <1352352999-2561-9-git-send-email-liwanp@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.5.4 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> x-cbid: 12110805-5140-0000-0000-0000025575AC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.141 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 Subject: [Qemu-devel] [PATCH 08/10] convert VMMOUSE as piix3 proper QOM child X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org convert VMMOUSE as piix3 proper QOM child. VMMOUSE 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 | 15 ++------------- hw/piix3.c | 10 ++++++++++ hw/piix3.h | 16 ++++++++++++++++ hw/vmmouse.c | 14 -------------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 99cd314..9798c24 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -926,12 +926,10 @@ static void cpu_request_exit(void *opaque, int irq, int level) } static void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, - ISADevice **floppy, - bool no_vmport) + ISADevice **floppy) { int i; DriveInfo *fd[MAX_FD]; - ISADevice *vmmouse; qemu_irq *cpu_exit_irq; register_ioport_write(0x80, 1, 1, ioport80_write, NULL); @@ -950,15 +948,6 @@ static void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, } } - if (!no_vmport) { - vmmouse = isa_try_create(isa_bus, "vmmouse"); - } else { - vmmouse = NULL; - } - if (vmmouse) { - qdev_init_nofail(&vmmouse->qdev); - } - cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1); DMA_init(0, cpu_exit_irq); @@ -1174,7 +1163,7 @@ static void pc_init1(MemoryRegion *system_memory, } /* init basic PC hardware */ - pc_basic_device_init(isa_bus, gsi, &floppy, xen_enabled()); + pc_basic_device_init(isa_bus, gsi, &floppy); for (i = 0; i < nb_nics; i++) { NICInfo *nd = &nd_table[i]; diff --git a/hw/piix3.c b/hw/piix3.c index 27c8f50..2922fd4 100644 --- a/hw/piix3.c +++ b/hw/piix3.c @@ -271,8 +271,15 @@ static int piix3_realize(PCIDevice *dev) /* Realize the VMPORT */ if (!xen_enabled()) { + /* Realize the VMPORT */ qdev_set_parent_bus(DEVICE(&s->vmport), BUS(s->bus)); qdev_init_nofail(DEVICE(&s->vmport)); + + /* Realize the VMMOUSE */ + qdev_set_parent_bus(DEVICE(&s->vmmouse), BUS(s->bus)); + qdev_prop_set_ptr(DEVICE(&s->vmmouse), + "ps2_mouse", ISA_DEVICE(&s->i8042)); + qdev_init_nofail(DEVICE(&s->vmmouse)); } return 0; @@ -318,6 +325,9 @@ static void piix3_initfn(Object *obj) object_initialize(&s->vmport, TYPE_VMPORT); object_property_add_child(obj, "vmport", OBJECT(&s->vmport), NULL); } + + object_initialize(&s->vmmouse, TYPE_VMMOUSE); + object_property_add_child(obj, "vmmouse", OBJECT(&s->vmmouse), NULL); } static void piix3_class_init(ObjectClass *klass, void *data) diff --git a/hw/piix3.h b/hw/piix3.h index 477e39e..29ae820 100644 --- a/hw/piix3.h +++ b/hw/piix3.h @@ -36,6 +36,7 @@ #include "i8254_internal.h" #include "pcspk.h" #include "ps2.h" +#include "console.h" #define PIIX_NUM_PIC_IRQS 16 /* i8259 * 2 */ #define PIIX_NUM_PIRQS 4ULL /* PIRQ[A-D] */ @@ -57,6 +58,20 @@ typedef struct KVMPITState { #define TYPE_VMPORT "vmport" #define VMPORT_ENTRIES 0x2c +#define TYPE_VMMOUSE "vmmouse" +#define VMMOUSE_QUEUE_SIZE 1024 + +typedef struct _VMMouseState { + ISADevice dev; + uint32_t queue[VMMOUSE_QUEUE_SIZE]; + int32_t queue_size; + uint16_t nb_queue; + uint16_t status; + uint8_t absolute; + QEMUPutMouseEntry *entry; + void *ps2_mouse; +} VMMouseState; + typedef struct _VMPortState { ISADevice dev; MemoryRegion io; @@ -121,6 +136,7 @@ typedef struct PIIX3State { KVMPITState kvm_pit; } pit; VMPortState vmport; + VMMouseState vmmouse; #endif PCSpkState pcspk; Port92State port92; diff --git a/hw/vmmouse.c b/hw/vmmouse.c index 6338efa..022e493 100644 --- a/hw/vmmouse.c +++ b/hw/vmmouse.c @@ -41,8 +41,6 @@ #define VMMOUSE_REQUEST_RELATIVE 0x4c455252 #define VMMOUSE_REQUEST_ABSOLUTE 0x53424152 -#define VMMOUSE_QUEUE_SIZE 1024 - #define VMMOUSE_VERSION 0x3442554a #ifdef DEBUG_VMMOUSE @@ -51,18 +49,6 @@ #define DPRINTF(fmt, ...) do { } while (0) #endif -typedef struct _VMMouseState -{ - ISADevice dev; - uint32_t queue[VMMOUSE_QUEUE_SIZE]; - int32_t queue_size; - uint16_t nb_queue; - uint16_t status; - uint8_t absolute; - QEMUPutMouseEntry *entry; - void *ps2_mouse; -} VMMouseState; - static uint32_t vmmouse_get_status(VMMouseState *s) { DPRINTF("vmmouse_get_status()\n");