aboutsummaryrefslogtreecommitdiff
path: root/hw/vmmouse.c
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2011-02-05 14:34:45 +0000
committerBlue Swirl <blauwirbel@gmail.com>2011-02-12 09:34:56 +0000
commit91c9e09147ba1f3604a3d5d29b4de7702082a33f (patch)
treee562f07f9e783b45aea32999858ac2d6ca0c3c3f /hw/vmmouse.c
parent6872ef610bad337701e0dcb0ab06558c04a0146f (diff)
downloadqemu-91c9e09147ba1f3604a3d5d29b4de7702082a33f.zip
qemu-91c9e09147ba1f3604a3d5d29b4de7702082a33f.tar.gz
qemu-91c9e09147ba1f3604a3d5d29b4de7702082a33f.tar.bz2
vmmouse: convert to qdev
Convert to qdev, also add a proper reset function. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/vmmouse.c')
-rw-r--r--hw/vmmouse.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/hw/vmmouse.c b/hw/vmmouse.c
index 2097119..3b39144 100644
--- a/hw/vmmouse.c
+++ b/hw/vmmouse.c
@@ -25,6 +25,7 @@
#include "console.h"
#include "ps2.h"
#include "pc.h"
+#include "qdev.h"
/* debug only vmmouse */
//#define DEBUG_VMMOUSE
@@ -52,6 +53,7 @@
typedef struct _VMMouseState
{
+ ISADevice dev;
uint32_t queue[VMMOUSE_QUEUE_SIZE];
int32_t queue_size;
uint16_t nb_queue;
@@ -270,22 +272,41 @@ static const VMStateDescription vmstate_vmmouse = {
}
};
-void *vmmouse_init(void *m)
+static void vmmouse_reset(DeviceState *d)
{
- VMMouseState *s = NULL;
+ VMMouseState *s = container_of(d, VMMouseState, dev.qdev);
- DPRINTF("vmmouse_init\n");
+ s->status = 0xffff;
+}
- s = qemu_mallocz(sizeof(VMMouseState));
+static int vmmouse_initfn(ISADevice *dev)
+{
+ VMMouseState *s = DO_UPCAST(VMMouseState, dev, dev);
- s->status = 0xffff;
- s->ps2_mouse = m;
- s->queue_size = VMMOUSE_QUEUE_SIZE;
+ 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);
- return s;
+ return 0;
+}
+
+static ISADeviceInfo vmmouse_info = {
+ .init = vmmouse_initfn,
+ .qdev.name = "vmmouse",
+ .qdev.size = sizeof(VMMouseState),
+ .qdev.no_user = 1,
+ .qdev.reset = vmmouse_reset,
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_PTR("ps2_mouse", VMMouseState, ps2_mouse),
+ DEFINE_PROP_END_OF_LIST(),
+ }
+};
+
+static void vmmouse_dev_register(void)
+{
+ isa_qdev_register(&vmmouse_info);
}
+device_init(vmmouse_dev_register)