svm_halt.c svm_pause.c svm_wbinvd.c \
vmm_config.c vmm_hashtable.c \
vmm_string.c vmm_emulator.c vmm_queue.c\
+ vmm_host_events.c \
$(DECODER_SRCS)
# vmx.c vmcs_gen.c vmcs.c
#include <palacios/vmm_dev_mgr.h>
#include <palacios/vmm_time.h>
#include <palacios/vmm_emulator.h>
+#include <palacios/vmm_host_events.h>
typedef ullong_t v3_reg_t;
struct vmm_dev_mgr dev_mgr;
+ struct v3_host_events host_event_hooks;
+
vm_cpu_mode_t cpu_mode;
vm_mem_mode_t mem_mode;
void Init_V3(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
int v3_deliver_irq(struct guest_info * vm, struct v3_interrupt * intr);
-
+int v3_deliver_keyboard_evt(struct guest_info * vm);
#endif
--- /dev/null
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National
+ * Science Foundation and the Department of Energy.
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico. You can find out more at
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
+ * All rights reserved.
+ *
+ * Author: Jack Lange <jarusl@cs.northwestern.edu>
+ *
+ * This is free software. You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#ifndef __VMM_HOST_EVENTS_H__
+#define __VMM_HOST_EVENTS_H__
+
+
+struct v3_keyboard_event {
+ unsigned char status;
+ unsigned char scan_code;
+};
+
+struct v3_mouse_event {
+ unsigned char data[3];
+};
+
+
+struct v3_timer_event {
+
+};
+
+#ifdef __V3VEE__
+
+#include <palacios/vmm_list.h>
+
+
+typedef enum {HOST_KEYBOARD_EVT,
+ HOST_MOUSE_EVT,
+ HOST_TIMER_EVT} v3_host_evt_type_t;
+
+
+union v3_host_event_handler {
+ int (*keyboard_handler)(struct guest_info * info, struct v3_keyboard_event * evt, void * priv_data);
+ int (*mouse_handler)(struct guest_info * info, struct v3_mouse_event * evt, void * priv_data);
+ int (*timer_handler)(struct guest_info * info, struct v3_timer_event * evt, void * priv_data);
+};
+
+
+struct v3_host_event_hook {
+ union v3_host_event_handler cb;
+ void * private_data;
+ struct list_head link;
+};
+
+
+
+struct v3_host_events {
+ struct list_head keyboard_events;
+ struct list_head mouse_events;
+ struct list_head timer_events;
+};
+
+
+
+int v3_init_host_events(struct guest_info * info);
+
+#define V3_HOST_EVENT_HANDLER(cb) ((union v3_host_event_callback)cb)
+
+int v3_hook_host_event(struct guest_info * info,
+ v3_host_evt_type_t event_type,
+ union v3_host_event_handler cb,
+ void * private_data);
+
+#endif // ! __V3VEE__
+
+int v3_deliver_keyboard_event(struct guest_info * info, struct v3_keyboard_event * evt);
+int v3_deliver_mouse_event(struct guest_info * info, struct v3_mouse_event * evt);
+int v3_deliver_timer_event(struct guest_info * info, struct v3_timer_event * evt);
+
+
+
+#endif
return thekeyboard;
}
-int keyboard_interrupt(uint_t irq, struct vm_device * dev);
+
+int keyboard_interrupt(uint_t irq, struct vm_device * dev) {
+ PrintDebug("keyboard: interrupt 0x%x\n", irq);
+
+ dev->vm->vm_ops.raise_irq(dev->vm, irq);
+
+ return 0;
+
+}
void deliver_key_to_vmm(uchar_t status, uchar_t scancode)
{
}
-int keyboard_interrupt(uint_t irq, struct vm_device * dev)
-{
- PrintDebug("keyboard: interrupt 0x%x\n", irq);
-
- dev->vm->vm_ops.raise_irq(dev->vm, irq);
- return 0;
-
-}
int keyboard_init_device(struct vm_device * dev)
struct dev_io_hook * dev_mgr_find_io_hook(struct vmm_dev_mgr * mgr, ushort_t port) {
- struct dev_io_hook * tmp;
+ struct dev_io_hook * tmp = NULL;
list_for_each_entry(tmp, &(mgr->io_hooks), mgr_list) {
if (tmp->port == port) {
}
struct dev_io_hook * dev_find_io_hook(struct vm_device * dev, ushort_t port) {
- struct dev_io_hook * tmp;
+ struct dev_io_hook * tmp = NULL;
list_for_each_entry(tmp, &(dev->io_hooks), dev_list) {
if (tmp->port == port) {
--- /dev/null
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National
+ * Science Foundation and the Department of Energy.
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico. You can find out more at
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
+ * All rights reserved.
+ *
+ * Author: Jack Lange <jarusl@cs.northwestern.edu>
+ *
+ * This is free software. You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#include <palacios/vmm.h>
+#include <palacios/vmm_host_events.h>
+
+
+int v3_init_host_events(struct guest_info * info) {
+ struct v3_host_events * host_evts = &(info->host_event_hooks);
+
+ INIT_LIST_HEAD(&(host_evts->keyboard_events));
+ INIT_LIST_HEAD(&(host_evts->mouse_events));
+ INIT_LIST_HEAD(&(host_evts->timer_events));
+
+ return 0;
+}
+
+
+int v3_hook_host_event(struct guest_info * info,
+ v3_host_evt_type_t event_type,
+ union v3_host_event_handler cb,
+ void * private_data) {
+
+ struct v3_host_events * host_evts = &(info->host_event_hooks);
+ struct v3_host_event_hook * hook = NULL;
+
+ hook = (struct v3_host_event_hook *)V3_Malloc(sizeof(struct v3_host_event_hook));
+ if (hook == NULL) {
+ PrintError("Could not allocate event hook\n");
+ return -1;
+ }
+
+ hook->cb = cb;
+ hook->private_data = private_data;
+
+ switch (event_type) {
+ case HOST_KEYBOARD_EVT:
+ list_add(&(hook->link), &(host_evts->keyboard_events));
+ break;
+ case HOST_MOUSE_EVT:
+ list_add(&(hook->link), &(host_evts->mouse_events));
+ break;
+ case HOST_TIMER_EVT:
+ list_add(&(hook->link), &(host_evts->timer_events));
+ break;
+ }
+
+ return 0;
+}
+
+
+int v3_deliver_keyboard_event(struct guest_info * info,
+ struct v3_keyboard_event * evt) {
+ struct v3_host_events * host_evts = &(info->host_event_hooks);
+ struct v3_host_event_hook * hook = NULL;
+
+ list_for_each_entry(hook, &(host_evts->keyboard_events), link) {
+ if (hook->cb.keyboard_handler(info, evt, hook->private_data) == -1) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+int v3_deliver_mouse_event(struct guest_info * info,
+ struct v3_mouse_event * evt) {
+ struct v3_host_events * host_evts = &(info->host_event_hooks);
+ struct v3_host_event_hook * hook = NULL;
+
+ list_for_each_entry(hook, &(host_evts->mouse_events), link) {
+ if (hook->cb.mouse_handler(info, evt, hook->private_data) == -1) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+int v3_deliver_timer_event(struct guest_info * info,
+ struct v3_timer_event * evt) {
+ struct v3_host_events * host_evts = &(info->host_event_hooks);
+ struct v3_host_event_hook * hook = NULL;
+
+ list_for_each_entry(hook, &(host_evts->timer_events), link) {
+ if (hook->cb.timer_handler(info, evt, hook->private_data) == -1) {
+ return -1;
+ }
+ }
+
+ return 0;
+}