vmmouse: convert to qdev
Convert to qdev, also add a proper reset function. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
6872ef610b
commit
91c9e09147
5
hw/pc.c
5
hw/pc.c
@ -1096,7 +1096,7 @@ void pc_basic_device_init(qemu_irq *isa_irq,
|
||||
PITState *pit;
|
||||
qemu_irq rtc_irq = NULL;
|
||||
qemu_irq *a20_line;
|
||||
ISADevice *i8042, *port92;
|
||||
ISADevice *i8042, *port92, *vmmouse;
|
||||
qemu_irq *cpu_exit_irq;
|
||||
|
||||
register_ioport_write(0x80, 1, 1, ioport80_write, NULL);
|
||||
@ -1134,7 +1134,8 @@ void pc_basic_device_init(qemu_irq *isa_irq,
|
||||
i8042 = isa_create_simple("i8042");
|
||||
i8042_setup_a20_line(i8042, &a20_line[0]);
|
||||
vmport_init();
|
||||
vmmouse_init(i8042);
|
||||
vmmouse = isa_create("vmmouse");
|
||||
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
|
||||
port92 = isa_create_simple("port92");
|
||||
port92_init(port92, &a20_line[1]);
|
||||
|
||||
|
3
hw/pc.h
3
hw/pc.h
@ -71,9 +71,6 @@ static inline void vmport_init(void)
|
||||
}
|
||||
void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque);
|
||||
|
||||
/* vmmouse.c */
|
||||
void *vmmouse_init(void *m);
|
||||
|
||||
/* pckbd.c */
|
||||
|
||||
void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base);
|
||||
|
39
hw/vmmouse.c
39
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;
|
||||
|
||||
DPRINTF("vmmouse_init\n");
|
||||
|
||||
s = qemu_mallocz(sizeof(VMMouseState));
|
||||
VMMouseState *s = container_of(d, VMMouseState, dev.qdev);
|
||||
|
||||
s->status = 0xffff;
|
||||
s->ps2_mouse = m;
|
||||
s->queue_size = VMMOUSE_QUEUE_SIZE;
|
||||
}
|
||||
|
||||
static int vmmouse_initfn(ISADevice *dev)
|
||||
{
|
||||
VMMouseState *s = DO_UPCAST(VMMouseState, 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);
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user