2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #ifndef __VMM_HOST_EVENTS_H__
21 #define __VMM_HOST_EVENTS_H__
24 struct v3_keyboard_event {
25 // A keyboard event is a PS/2 scancode and status reg
27 unsigned char scan_code;
30 struct v3_mouse_event {
31 // A mouse event is a PS/2 mouse packet
32 unsigned char sx; // sign bit for deltax
33 unsigned char dx; // deltax
34 unsigned char sy; // sign bit for deltay
35 unsigned char dy; // deltay
36 unsigned char buttons; // button state
39 struct v3_timer_event {
40 unsigned int period_us;
43 struct v3_serial_event {
44 unsigned char data[128];
48 struct v3_console_event {
53 struct v3_debug_event {
61 #include <palacios/vmm_list.h>
65 typedef enum { HOST_KEYBOARD_EVT,
70 HOST_DEBUG_EVT} v3_host_evt_type_t;
73 union v3_host_event_handler {
74 int (*keyboard_handler)(struct v3_vm_info * vm, struct v3_keyboard_event * evt, void * priv_data);
75 int (*mouse_handler)(struct v3_vm_info * vm, struct v3_mouse_event * evt, void * priv_data);
76 int (*timer_handler)(struct v3_vm_info * vm, struct v3_timer_event * evt, void * priv_data);
77 int (*serial_handler)(struct v3_vm_info * vm, struct v3_serial_event * evt, void * priv_data);
78 int (*console_handler)(struct v3_vm_info * vm, struct v3_console_event * evt, void * priv_data);
79 int (*debug_handler)(struct v3_vm_info * vm, struct v3_debug_event * evt, void * priv_data);
83 struct v3_host_event_hook {
84 union v3_host_event_handler cb;
86 struct list_head link;
91 struct v3_host_events {
92 struct list_head keyboard_events;
93 struct list_head mouse_events;
94 struct list_head timer_events;
95 struct list_head serial_events;
96 struct list_head console_events;
97 struct list_head debug_events;
102 int v3_init_host_events(struct v3_vm_info * vm);
103 int v3_deinit_host_events(struct v3_vm_info * vm);
105 #define V3_HOST_EVENT_HANDLER(cb) ((union v3_host_event_handler)cb)
107 int v3_hook_host_event(struct v3_vm_info * vm,
108 v3_host_evt_type_t event_type,
109 union v3_host_event_handler cb,
110 void * private_data);
112 #endif /* ! __V3VEE__ */
116 int v3_deliver_keyboard_event(struct v3_vm_info * vm, struct v3_keyboard_event * evt);
117 int v3_deliver_mouse_event(struct v3_vm_info * vm, struct v3_mouse_event * evt);
118 int v3_deliver_timer_event(struct v3_vm_info * vm, struct v3_timer_event * evt);
119 int v3_deliver_serial_event(struct v3_vm_info * vm, struct v3_serial_event * evt);
120 int v3_deliver_console_event(struct v3_vm_info * vm, struct v3_console_event * evt);
121 int v3_deliver_debug_event(struct v3_vm_info * vm, struct v3_debug_event * evt);