[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] Merge vmmouse and vmport
From: |
Blue Swirl |
Subject: |
[Qemu-devel] [PATCH] Merge vmmouse and vmport |
Date: |
Fri, 18 Feb 2011 22:45:35 +0200 |
Fix also a typo in default-configs/x86_64-softmmu.
Signed-off-by: Blue Swirl <address@hidden>
---
Makefile.objs | 1 -
Makefile.target | 3 +-
default-configs/x86_64-softmmu.mak | 2 +-
hw/pc.c | 1 -
hw/pc.h | 9 --
hw/vmmouse.c | 129 ++++++++++++++++++++++++++++---
hw/vmport.c | 149 ------------------------------------
7 files changed, 120 insertions(+), 174 deletions(-)
delete mode 100644 hw/vmport.c
diff --git a/Makefile.objs b/Makefile.objs
index b21f9d3..a6f8b31 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -259,7 +259,6 @@ 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 5a0fd40..5f8cf27 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -215,7 +215,8 @@ 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 += vmport.o applesmc.o
+obj-i386-y += applesmc.o
+obj-i386-$(CONFIG_VMMOUSE) += vmmouse.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 kvmclock.o
diff --git a/default-configs/x86_64-softmmu.mak
b/default-configs/x86_64-softmmu.mak
index 1cc1b61..9192d47 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -4,7 +4,7 @@ include pci.mak
CONFIG_VGA_PCI=y
CONFIG_VGA_ISA=y
CONFIG_VMWARE_VGA=y
-CONFIG_VMMMOUSE=y
+CONFIG_VMMOUSE=y
CONFIG_SERIAL=y
CONFIG_PARALLEL=y
CONFIG_I8254=y
diff --git a/hw/pc.c b/hw/pc.c
index 56bf1d6..fe0afb9 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1136,7 +1136,6 @@ 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]);
- vmport_init();
vmmouse = isa_try_create("vmmouse");
if (vmmouse) {
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
diff --git a/hw/pc.h b/hw/pc.h
index d5d2f42..4537c9c 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -64,15 +64,6 @@ int pit_get_out(PITState *pit, int channel, int64_t
current_time);
void hpet_pit_disable(void);
void hpet_pit_enable(void);
-/* vmport.c */
-static inline void vmport_init(void)
-{
- isa_create_simple("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);
-
/* pckbd.c */
void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base);
diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index ab8dbd6..19a4dfc 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -2,6 +2,7 @@
* QEMU VMMouse emulation
*
* Copyright (C) 2007 Anthony Liguori <address@hidden>
+ * Copyright (C) 2007 HervĂŠ Poussineau
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the
"Software"), to deal
@@ -26,10 +27,21 @@
#include "ps2.h"
#include "pc.h"
#include "qdev.h"
+#include "isa.h"
+#include "sysemu.h"
+#include "kvm.h"
/* debug only vmmouse */
//#define DEBUG_VMMOUSE
+//#define VMPORT_DEBUG
+
+#ifdef DEBUG_VMMOUSE
+#define DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...) do { } while (0)
+#endif
+
/* VMMouse Commands */
#define VMMOUSE_GETVERSION 10
#define VMMOUSE_DATA 39
@@ -45,11 +57,12 @@
#define VMMOUSE_VERSION 0x3442554a
-#ifdef DEBUG_VMMOUSE
-#define DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__)
-#else
-#define DPRINTF(fmt, ...) do { } while (0)
-#endif
+/* VMPort Commands */
+#define VMPORT_CMD_GETVERSION 0x0a
+#define VMPORT_CMD_GETRAMSIZE 0x14
+
+#define VMPORT_ENTRIES 0x2c
+#define VMPORT_MAGIC 0x564D5868
typedef struct _VMMouseState
{
@@ -63,6 +76,71 @@ typedef struct _VMMouseState
void *ps2_mouse;
} VMMouseState;
+typedef struct VMPortState {
+ ISADevice dev;
+ IOPortReadFunc *func[VMPORT_ENTRIES];
+ void *opaque[VMPORT_ENTRIES];
+ VMMouseState mouse;
+} VMPortState;
+
+static void vmport_register(VMPortState *s, unsigned char command,
+ IOPortReadFunc *func)
+{
+ assert(command < VMPORT_ENTRIES);
+
+ s->func[command] = func;
+}
+
+static uint32_t vmport_ioport_read(void *opaque, uint32_t addr)
+{
+ VMPortState *s = opaque;
+ CPUState *env = cpu_single_env;
+ unsigned char command;
+ uint32_t eax;
+
+ cpu_synchronize_state(env);
+
+ eax = env->regs[R_EAX];
+ if (eax != VMPORT_MAGIC) {
+ return eax;
+ }
+
+ command = env->regs[R_ECX];
+ if (command >= VMPORT_ENTRIES) {
+ return eax;
+ }
+
+ if (!s->func[command]) {
+#ifdef VMPORT_DEBUG
+ fprintf(stderr, "vmport: unknown command %x\n", command);
+#endif
+ return eax;
+ }
+
+ return s->func[command](s, addr);
+}
+
+static void vmport_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+{
+ CPUState *env = cpu_single_env;
+
+ env->regs[R_EAX] = vmport_ioport_read(opaque, addr);
+}
+
+static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)
+{
+ CPUState *env = cpu_single_env;
+ env->regs[R_EBX] = VMPORT_MAGIC;
+ return 6;
+}
+
+static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
+{
+ CPUState *env = cpu_single_env;
+ env->regs[R_EBX] = 0x1177;
+ return ram_size;
+}
+
static uint32_t vmmouse_get_status(VMMouseState *s)
{
DPRINTF("vmmouse_get_status()\n");
@@ -178,9 +256,28 @@ 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];
+}
+
+static 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 uint32_t vmmouse_ioport_read(void *opaque, uint32_t addr)
{
- VMMouseState *s = opaque;
+ VMPortState *d = opaque;
+ VMMouseState *s = &d->mouse;
uint32_t data[6];
uint16_t command;
@@ -258,14 +355,22 @@ static void vmmouse_reset(DeviceState *d)
static int vmmouse_initfn(ISADevice *dev)
{
- VMMouseState *s = DO_UPCAST(VMMouseState, dev, dev);
+ VMPortState *s = DO_UPCAST(VMPortState, dev, dev);
DPRINTF("vmmouse_init\n");
-
- vmport_register(VMMOUSE_STATUS, vmmouse_ioport_read, s);
- vmport_register(VMMOUSE_COMMAND, vmmouse_ioport_read, s);
- vmport_register(VMMOUSE_DATA, vmmouse_ioport_read, s);
- vmstate_register(NULL, 0, &vmstate_vmmouse, s);
+ register_ioport_read(0x5658, 1, 4, vmport_ioport_read, s);
+ register_ioport_write(0x5658, 1, 4, vmport_ioport_write, s);
+ isa_init_ioport(dev, 0x5658);
+
+ /* Register some generic port commands */
+ vmport_register(s, VMPORT_CMD_GETVERSION, vmport_cmd_get_version);
+ vmport_register(s, VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size);
+
+ /* VMMouse */
+ vmport_register(s, VMMOUSE_STATUS, vmmouse_ioport_read);
+ vmport_register(s, VMMOUSE_COMMAND, vmmouse_ioport_read);
+ vmport_register(s, VMMOUSE_DATA, vmmouse_ioport_read);
+ vmstate_register(NULL, 0, &vmstate_vmmouse, &s->mouse);
return 0;
}
diff --git a/hw/vmport.c b/hw/vmport.c
deleted file mode 100644
index 19010e4..0000000
--- a/hw/vmport.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * QEMU VMPort emulation
- *
- * Copyright (C) 2007 Hervé Poussineau
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the
"Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-#include "hw.h"
-#include "isa.h"
-#include "pc.h"
-#include "sysemu.h"
-#include "kvm.h"
-#include "qdev.h"
-
-//#define VMPORT_DEBUG
-
-#define VMPORT_CMD_GETVERSION 0x0a
-#define VMPORT_CMD_GETRAMSIZE 0x14
-
-#define VMPORT_ENTRIES 0x2c
-#define VMPORT_MAGIC 0x564D5868
-
-typedef struct _VMPortState
-{
- ISADevice dev;
- IOPortReadFunc *func[VMPORT_ENTRIES];
- void *opaque[VMPORT_ENTRIES];
-} VMPortState;
-
-static VMPortState *port_state;
-
-void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque)
-{
- if (command >= VMPORT_ENTRIES)
- return;
-
- port_state->func[command] = func;
- port_state->opaque[command] = opaque;
-}
-
-static uint32_t vmport_ioport_read(void *opaque, uint32_t addr)
-{
- VMPortState *s = opaque;
- CPUState *env = cpu_single_env;
- unsigned char command;
- uint32_t eax;
-
- cpu_synchronize_state(env);
-
- eax = env->regs[R_EAX];
- if (eax != VMPORT_MAGIC)
- return eax;
-
- command = env->regs[R_ECX];
- if (command >= VMPORT_ENTRIES)
- return eax;
- if (!s->func[command])
- {
-#ifdef VMPORT_DEBUG
- fprintf(stderr, "vmport: unknown command %x\n", command);
-#endif
- return eax;
- }
-
- return s->func[command](s->opaque[command], addr);
-}
-
-static void vmport_ioport_write(void *opaque, uint32_t addr, uint32_t val)
-{
- CPUState *env = cpu_single_env;
-
- env->regs[R_EAX] = vmport_ioport_read(opaque, addr);
-}
-
-static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)
-{
- CPUState *env = cpu_single_env;
- env->regs[R_EBX] = VMPORT_MAGIC;
- return 6;
-}
-
-static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr)
-{
- CPUState *env = cpu_single_env;
- env->regs[R_EBX] = 0x1177;
- 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)
-{
- VMPortState *s = DO_UPCAST(VMPortState, dev, dev);
-
- register_ioport_read(0x5658, 1, 4, vmport_ioport_read, s);
- register_ioport_write(0x5658, 1, 4, vmport_ioport_write, s);
- isa_init_ioport(dev, 0x5658);
- port_state = s;
- /* Register some generic port commands */
- vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL);
- vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL);
- return 0;
-}
-
-static ISADeviceInfo vmport_info = {
- .qdev.name = "vmport",
- .qdev.size = sizeof(VMPortState),
- .qdev.no_user = 1,
- .init = vmport_initfn,
-};
-
-static void vmport_dev_register(void)
-{
- isa_qdev_register(&vmport_info);
-}
-device_init(vmport_dev_register)
--
1.6.2.4
0001-Merge-vmmouse-and-vmport.patch
Description: application/mbox
- [Qemu-devel] [PATCH] Merge vmmouse and vmport,
Blue Swirl <=