Patchwork [08/10] x86: make vmmouse optional

login
register
mail settings
Submitter Blue Swirl
Date Feb. 3, 2011, 9:02 p.m.
Message ID <AANLkTikXgkkTGWWmm0i=vxW6wNv5+7Qmhhms9qcAOb_E@mail.gmail.com>
Download mbox | patch
Permalink /patch/81765/
State New
Headers show

Comments

Blue Swirl - Feb. 3, 2011, 9:02 p.m.
Compile vmmouse in hwlib. Ignore failure if vmmouse device can't be
created.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 Makefile.objs                      |    1 +
 Makefile.target                    |    2 +-
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 hw/pc.c                            |    6 ++++--
 hw/pc.h                            |    2 ++
 hw/vmmouse.c                       |   24 ------------------------
 hw/vmport.c                        |   19 +++++++++++++++++++
 8 files changed, 29 insertions(+), 27 deletions(-)

     VMPortState *s = DO_UPCAST(VMPortState, dev, dev);

Patch

diff --git a/Makefile.objs b/Makefile.objs
index f1c7bfe..1853f9a 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -257,6 +257,7 @@  hw-obj-$(CONFIG_VGA_PCI) += vga-pci.o
 hw-obj-$(CONFIG_VGA_ISA) += vga-isa.o
 hw-obj-$(CONFIG_VGA_ISA_MM) += vga-isa-mm.o
 hw-obj-$(CONFIG_VMWARE_VGA) += vmware_vga.o
+hw-obj-$(CONFIG_VMMOUSE) += vmmouse.o

 hw-obj-$(CONFIG_RC4030) += rc4030.o
 hw-obj-$(CONFIG_DP8393X) += dp8393x.o
diff --git a/Makefile.target b/Makefile.target
index b0ba95f..ab2df93 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -215,7 +215,7 @@  obj-$(CONFIG_KVM) += ivshmem.o
 obj-i386-y += vga.o
 obj-i386-y += mc146818rtc.o i8259.o pc.o
 obj-i386-y += cirrus_vga.o apic.o ioapic.o piix_pci.o
-obj-i386-y += vmmouse.o vmport.o hpet.o applesmc.o
+obj-i386-y += vmport.o hpet.o applesmc.o
 obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
 obj-i386-y += debugcon.o multiboot.o
 obj-i386-y += pc_piix.o
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 323fafb..9246293 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -4,6 +4,7 @@  include pci.mak
 CONFIG_VGA_PCI=y
 CONFIG_VGA_ISA=y
 CONFIG_VMWARE_VGA=y
+CONFIG_VMMOUSE=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/default-configs/x86_64-softmmu.mak
b/default-configs/x86_64-softmmu.mak
index eff26d2..daf8c48 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -4,6 +4,7 @@  include pci.mak
 CONFIG_VGA_PCI=y
 CONFIG_VGA_ISA=y
 CONFIG_VMWARE_VGA=y
+CONFIG_VMMMOUSE=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/hw/pc.c b/hw/pc.c
index f66ac5d..9f5fc17 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1133,8 +1133,10 @@  void pc_basic_device_init(qemu_irq *isa_irq,
     a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
     i8042 = isa_create_simple("i8042");
     i8042_setup_a20_line(i8042, &a20_line[0]);
-    vmmouse = isa_create("vmmouse");
-    qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
+    vmmouse = isa_try_create("vmmouse");
+    if (vmmouse) {
+        qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
+    }
     port92 = isa_create_simple("port92");
     port92_init(port92, &a20_line[1]);

diff --git a/hw/pc.h b/hw/pc.h
index ae83934..9424b93 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -66,6 +66,8 @@  void hpet_pit_enable(void);

 /* vmport.c */
 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);

 /* pckbd.c */

diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index 3b39144..11b125c 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -178,30 +178,6 @@  static void vmmouse_data(VMMouseState *s,
uint32_t *data, uint32_t size)
         memmove(s->queue, &s->queue[size], sizeof(s->queue[0]) * s->nb_queue);
 }

-static void vmmouse_get_data(uint32_t *data)
-{
-    CPUState *env = cpu_single_env;
-
-    data[0] = env->regs[R_EAX]; data[1] = env->regs[R_EBX];
-    data[2] = env->regs[R_ECX]; data[3] = env->regs[R_EDX];
-    data[4] = env->regs[R_ESI]; data[5] = env->regs[R_EDI];
-
-    DPRINTF("get_data = {%x, %x, %x, %x, %x, %x}\n",
-            data[0], data[1], data[2], data[3], data[4], data[5]);
-}
-
-static void vmmouse_set_data(const uint32_t *data)
-{
-    CPUState *env = cpu_single_env;
-
-    DPRINTF("set_data = {%x, %x, %x, %x, %x, %x}\n",
-            data[0], data[1], data[2], data[3], data[4], data[5]);
-
-    env->regs[R_EAX] = data[0]; env->regs[R_EBX] = data[1];
-    env->regs[R_ECX] = data[2]; env->regs[R_EDX] = data[3];
-    env->regs[R_ESI] = data[4]; env->regs[R_EDI] = data[5];
-}
-
 static uint32_t vmmouse_ioport_read(void *opaque, uint32_t addr)
 {
     VMMouseState *s = opaque;
diff --git a/hw/vmport.c b/hw/vmport.c
index 4432be0..292d78f 100644
--- a/hw/vmport.c
+++ b/hw/vmport.c
@@ -102,6 +102,25 @@  static uint32_t vmport_cmd_ram_size(void *opaque,
uint32_t addr)
     return ram_size;
 }

+/* vmmouse helpers */
+void vmmouse_get_data(uint32_t *data)
+{
+    CPUState *env = cpu_single_env;
+
+    data[0] = env->regs[R_EAX]; data[1] = env->regs[R_EBX];
+    data[2] = env->regs[R_ECX]; data[3] = env->regs[R_EDX];
+    data[4] = env->regs[R_ESI]; data[5] = env->regs[R_EDI];
+}
+
+void vmmouse_set_data(const uint32_t *data)
+{
+    CPUState *env = cpu_single_env;
+
+    env->regs[R_EAX] = data[0]; env->regs[R_EBX] = data[1];
+    env->regs[R_ECX] = data[2]; env->regs[R_EDX] = data[3];
+    env->regs[R_ESI] = data[4]; env->regs[R_EDI] = data[5];
+}
+
 static int vmport_initfn(ISADevice *dev)
 {