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 #include <palacios/vmm.h>
21 #include <palacios/vmm_host_events.h>
24 int v3_init_host_events(struct guest_info * info) {
25 struct v3_host_events * host_evts = &(info->host_event_hooks);
27 INIT_LIST_HEAD(&(host_evts->keyboard_events));
28 INIT_LIST_HEAD(&(host_evts->mouse_events));
29 INIT_LIST_HEAD(&(host_evts->timer_events));
35 int v3_hook_host_event(struct guest_info * info,
36 v3_host_evt_type_t event_type,
37 union v3_host_event_handler cb,
38 void * private_data) {
40 struct v3_host_events * host_evts = &(info->host_event_hooks);
41 struct v3_host_event_hook * hook = NULL;
43 hook = (struct v3_host_event_hook *)V3_Malloc(sizeof(struct v3_host_event_hook));
45 PrintError("Could not allocate event hook\n");
50 hook->private_data = private_data;
53 case HOST_KEYBOARD_EVT:
54 list_add(&(hook->link), &(host_evts->keyboard_events));
57 list_add(&(hook->link), &(host_evts->mouse_events));
60 list_add(&(hook->link), &(host_evts->timer_events));
68 int v3_deliver_keyboard_event(struct guest_info * info,
69 struct v3_keyboard_event * evt) {
70 struct v3_host_events * host_evts = &(info->host_event_hooks);
71 struct v3_host_event_hook * hook = NULL;
73 list_for_each_entry(hook, &(host_evts->keyboard_events), link) {
74 if (hook->cb.keyboard_handler(info, evt, hook->private_data) == -1) {
83 int v3_deliver_mouse_event(struct guest_info * info,
84 struct v3_mouse_event * evt) {
85 struct v3_host_events * host_evts = &(info->host_event_hooks);
86 struct v3_host_event_hook * hook = NULL;
88 list_for_each_entry(hook, &(host_evts->mouse_events), link) {
89 if (hook->cb.mouse_handler(info, evt, hook->private_data) == -1) {
98 int v3_deliver_timer_event(struct guest_info * info,
99 struct v3_timer_event * evt) {
100 struct v3_host_events * host_evts = &(info->host_event_hooks);
101 struct v3_host_event_hook * hook = NULL;
103 list_for_each_entry(hook, &(host_evts->timer_events), link) {
104 if (hook->cb.timer_handler(info, evt, hook->private_data) == -1) {