qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 07/10] convert VMPORT as piix3 proper QOM child


From: Wanpeng Li
Subject: [Qemu-devel] [PATCH 07/10] convert VMPORT as piix3 proper QOM child
Date: Thu, 8 Nov 2012 13:36:36 +0800

convert VMPORT as piix3 proper QOM child.

VMPORT 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 <address@hidden>

---
 hw/pc.c     |    1 -
 hw/pc.h     |    5 -----
 hw/piix3.c  |   11 +++++++++++
 hw/piix3.h  |   11 +++++++++++
 hw/vmport.c |   10 +---------
 5 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index a14bf5a..99cd314 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -951,7 +951,6 @@ static void pc_basic_device_init(ISABus *isa_bus, qemu_irq 
*gsi,
     }
 
     if (!no_vmport) {
-        vmport_init(isa_bus);
         vmmouse = isa_try_create(isa_bus, "vmmouse");
     } else {
         vmmouse = NULL;
diff --git a/hw/pc.h b/hw/pc.h
index 17d48a0..5b7bc26 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -54,11 +54,6 @@ typedef struct GSIState {
     qemu_irq ioapic_irq[IOAPIC_NUM_PINS];
 } GSIState;
 
-/* vmport.c */
-static inline void vmport_init(ISABus *bus)
-{
-    isa_create_simple(bus, "vmport");
-}
 void vmport_register(unsigned char command, IOPortReadFunc *func, void 
*opaque);
 void vmmouse_get_data(uint32_t *data);
 void vmmouse_set_data(const uint32_t *data);
diff --git a/hw/piix3.c b/hw/piix3.c
index c6bf3cb..27c8f50 100644
--- a/hw/piix3.c
+++ b/hw/piix3.c
@@ -269,6 +269,12 @@ static int piix3_realize(PCIDevice *dev)
     i8042_setup_a20_line(ISA_DEVICE(&s->i8042), &a20_line[0]);
     qdev_init_nofail(DEVICE(&s->i8042));
 
+    /* Realize the VMPORT */
+    if (!xen_enabled()) {
+        qdev_set_parent_bus(DEVICE(&s->vmport), BUS(s->bus));
+        qdev_init_nofail(DEVICE(&s->vmport));
+    }
+
     return 0;
 }
 
@@ -307,6 +313,11 @@ static void piix3_initfn(Object *obj)
 
     object_initialize(&s->i8042, TYPE_I8042);
     object_property_add_child(obj, "i8042", OBJECT(&s->i8042), NULL);
+
+    if (!xen_enabled()) {
+        object_initialize(&s->vmport, TYPE_VMPORT);
+        object_property_add_child(obj, "vmport", OBJECT(&s->vmport), NULL);
+    }
 }
 
 static void piix3_class_init(ObjectClass *klass, void *data)
diff --git a/hw/piix3.h b/hw/piix3.h
index 94a0daf..477e39e 100644
--- a/hw/piix3.h
+++ b/hw/piix3.h
@@ -54,6 +54,16 @@ typedef struct KVMPITState {
 
 #define TYPE_PORT92 "port92"
 
+#define TYPE_VMPORT "vmport"
+#define VMPORT_ENTRIES 0x2c
+
+typedef struct _VMPortState {
+    ISADevice dev;
+    MemoryRegion io;
+    IOPortReadFunc *func[VMPORT_ENTRIES];
+    void *opaque[VMPORT_ENTRIES];
+} VMPortState;
+
 /* port 92 stuff: could be split off */
 typedef struct Port92State {
     ISADevice dev;
@@ -110,6 +120,7 @@ typedef struct PIIX3State {
         PITCommonState pit;
         KVMPITState kvm_pit;
     } pit;
+    VMPortState vmport;
 #endif
     PCSpkState pcspk;
     Port92State port92;
diff --git a/hw/vmport.c b/hw/vmport.c
index 3ab3a14..45daef6 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -35,14 +35,6 @@
 #define VMPORT_ENTRIES 0x2c
 #define VMPORT_MAGIC   0x564D5868
 
-typedef struct _VMPortState
-{
-    ISADevice dev;
-    MemoryRegion io;
-    IOPortReadFunc *func[VMPORT_ENTRIES];
-    void *opaque[VMPORT_ENTRIES];
-} VMPortState;
-
 static VMPortState *port_state;
 
 void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque)
@@ -156,7 +148,7 @@ static void vmport_class_initfn(ObjectClass *klass, void 
*data)
 }
 
 static TypeInfo vmport_info = {
-    .name          = "vmport",
+    .name          = TYPE_VMPORT,
     .parent        = TYPE_ISA_DEVICE,
     .instance_size = sizeof(VMPortState),
     .class_init    = vmport_class_initfn,
-- 
1.7.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]