Skip to content

Commit

Permalink
vmmouse: replace DPRINTF with tracing
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
  • Loading branch information
elmarco committed Sep 12, 2023
1 parent d824da9 commit 885f380
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
10 changes: 10 additions & 0 deletions hw/i386/trace-events
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,13 @@ x86_pic_interrupt(int irqn, int level) "PIC interrupt #%d level:%d"
# port92.c
port92_read(uint8_t val) "port92: read 0x%02x"
port92_write(uint8_t val) "port92: write 0x%02x"

# vmmouse.c
vmmouse_get_status(void) ""
vmmouse_mouse_event(int x, int y, int dz, int buttons_state) "event: x=%d y=%d dz=%d state=%d"
vmmouse_init(void) ""
vmmouse_read_id(void) ""
vmmouse_request_relative(void) ""
vmmouse_request_absolute(void) ""
vmmouse_disable(void) ""
vmmouse_data(uint32_t size) "data: size=%" PRIu32
29 changes: 14 additions & 15 deletions hw/i386/vmmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "cpu.h"
#include "qom/object.h"

#include "trace.h"

/* debug only vmmouse */
//#define DEBUG_VMMOUSE

Expand All @@ -50,12 +52,6 @@
#define VMMOUSE_RIGHT_BUTTON 0x10
#define VMMOUSE_MIDDLE_BUTTON 0x08

#ifdef DEBUG_VMMOUSE
#define DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__)
#else
#define DPRINTF(fmt, ...) do { } while (0)
#endif

#define TYPE_VMMOUSE "vmmouse"
OBJECT_DECLARE_SIMPLE_TYPE(VMMouseState, VMMOUSE)

Expand Down Expand Up @@ -93,7 +89,8 @@ static void vmmouse_set_data(const uint32_t *data)

static uint32_t vmmouse_get_status(VMMouseState *s)
{
DPRINTF("vmmouse_get_status()\n");
trace_vmmouse_get_status();

return (s->status << 16) | s->nb_queue;
}

Expand All @@ -105,8 +102,7 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_
if (s->nb_queue > (VMMOUSE_QUEUE_SIZE - 4))
return;

DPRINTF("vmmouse_mouse_event(%d, %d, %d, %d)\n",
x, y, dz, buttons_state);
trace_vmmouse_mouse_event(x, y, dz, buttons_state);

if ((buttons_state & MOUSE_EVENT_LBUTTON))
buttons |= VMMOUSE_LEFT_BUTTON;
Expand Down Expand Up @@ -160,7 +156,7 @@ static void vmmouse_update_handler(VMMouseState *s, int absolute)

static void vmmouse_read_id(VMMouseState *s)
{
DPRINTF("vmmouse_read_id()\n");
trace_vmmouse_read_id();

if (s->nb_queue == VMMOUSE_QUEUE_SIZE)
return;
Expand All @@ -172,19 +168,22 @@ static void vmmouse_read_id(VMMouseState *s)

static void vmmouse_request_relative(VMMouseState *s)
{
DPRINTF("vmmouse_request_relative()\n");
trace_vmmouse_request_relative();

vmmouse_update_handler(s, 0);
}

static void vmmouse_request_absolute(VMMouseState *s)
{
DPRINTF("vmmouse_request_absolute()\n");
trace_vmmouse_request_absolute();

vmmouse_update_handler(s, 1);
}

static void vmmouse_disable(VMMouseState *s)
{
DPRINTF("vmmouse_disable()\n");
trace_vmmouse_disable();

s->status = 0xffff;
vmmouse_remove_handler(s);
}
Expand All @@ -193,7 +192,7 @@ static void vmmouse_data(VMMouseState *s, uint32_t *data, uint32_t size)
{
int i;

DPRINTF("vmmouse_data(%d)\n", size);
trace_vmmouse_data(size);

if (size == 0 || size > 6 || size > s->nb_queue) {
printf("vmmouse: driver requested too much data %d\n", size);
Expand Down Expand Up @@ -293,7 +292,7 @@ static void vmmouse_realizefn(DeviceState *dev, Error **errp)
{
VMMouseState *s = VMMOUSE(dev);

DPRINTF("vmmouse_init\n");
trace_vmmouse_init();

if (!s->i8042) {
error_setg(errp, "'i8042' link is not set");
Expand Down

0 comments on commit 885f380

Please sign in to comment.