# Makefile for GeekOS kernel, userspace, and tools
# Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
-# $Revision: 1.25 $
+# $Revision: 1.26 $
# This is free software. You are permitted to use,
# redistribute, and modify it as specified in the file "COPYING".
VMM_C_SRCS := vm_guest.c \
svm.c svm_handler.c vmm.c vmm_util.c svm_ctrl_regs.c \
vmcb.c vmm_mem.c vmm_paging.c vmm_io.c vmm_debug.c svm_io.c \
- vmm_intr.c \
+ vmm_intr.c vmm_irq.c\
vmm_shadow_paging.c vm_guest_mem.c \
vm_dev.c vmm_dev_mgr.c \
#\
VMM_OBJS := $(VMM_C_OBJS) $(VMM_ASM_OBJS)
-DEVICE_C_SRCS := nvram.c
+DEVICE_C_SRCS := nvram.c timer.c
DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o)
../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \
../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
- ../include/geekos/debug.h ../include/geekos/serial.h \
- ../include/geekos/irq.h ../include/geekos/int.h \
- ../include/geekos/string.h ../include/geekos/../libc/string.h \
- ../include/geekos/io.h ../include/geekos/vm.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h ../include/geekos/debug.h \
+ ../include/geekos/serial.h ../include/geekos/irq.h \
+ ../include/geekos/int.h ../include/geekos/string.h \
+ ../include/geekos/../libc/string.h ../include/geekos/io.h \
+ ../include/geekos/vm.h ../include/devices/nvram.h \
+ ../include/palacios/vm_dev.h
geekos/main.o: ../src/geekos/main.c ../include/geekos/bootinfo.h \
../include/geekos/string.h ../include/geekos/../libc/string.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
../include/palacios/vmm_string.h \
- /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
+ ../include/palacios/vmm_irq.h
palacios/svm.o: ../src/palacios/svm.c ../include/palacios/svm.h \
../include/palacios/vmm_util.h ../include/palacios/vmm_types.h \
../include/geekos/ktypes.h \
../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
- ../include/palacios/vmcb.h ../include/palacios/svm_handler.h \
- ../include/palacios/vmm_debug.h ../include/palacios/vm_guest_mem.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h ../include/palacios/vmcb.h \
+ ../include/palacios/svm_handler.h ../include/palacios/vmm_debug.h \
+ ../include/palacios/vm_guest_mem.h
palacios/svm_handler.o: ../src/palacios/svm_handler.c \
../include/palacios/svm_handler.h ../include/palacios/svm.h \
../include/palacios/vmm_util.h ../include/palacios/vmm_types.h \
../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
- ../include/palacios/vmcb.h ../include/palacios/vm_guest_mem.h \
- ../include/palacios/vmm_emulate.h ../include/palacios/svm_ctrl_regs.h \
- ../include/palacios/svm_io.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h ../include/palacios/vmcb.h \
+ ../include/palacios/vm_guest_mem.h ../include/palacios/vmm_emulate.h \
+ ../include/palacios/svm_ctrl_regs.h ../include/palacios/svm_io.h
palacios/vmm.o: ../src/palacios/vmm.c ../include/palacios/vmm.h \
../include/palacios/vmm_string.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \
../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
- ../include/palacios/svm.h ../include/palacios/vmcb.h \
- ../include/palacios/vmx.h ../include/palacios/vmcs.h \
- ../include/palacios/vmcs_gen.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h ../include/palacios/svm.h \
+ ../include/palacios/vmcb.h ../include/palacios/vmx.h \
+ ../include/palacios/vmcs.h ../include/palacios/vmcs_gen.h
palacios/vmm_util.o: ../src/palacios/vmm_util.c ../include/palacios/vmm_util.h \
../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h
palacios/svm_ctrl_regs.o: ../src/palacios/svm_ctrl_regs.c \
../include/palacios/svm_ctrl_regs.h ../include/palacios/vm_guest.h \
../include/palacios/vmm_mem.h ../include/palacios/vmm_types.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
../include/palacios/vmm_string.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
- ../include/palacios/vmm.h ../include/palacios/vmcb.h \
- ../include/palacios/vmm_emulate.h ../include/palacios/vm_guest_mem.h \
- ../include/palacios/vmm_ctrl_regs.h
+ ../include/palacios/vmm_irq.h ../include/palacios/vmm.h \
+ ../include/palacios/vmcb.h ../include/palacios/vmm_emulate.h \
+ ../include/palacios/vm_guest_mem.h ../include/palacios/vmm_ctrl_regs.h
palacios/vmcb.o: ../src/palacios/vmcb.c ../include/palacios/vmcb.h \
../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h
palacios/vmm_mem.o: ../src/palacios/vmm_mem.c ../include/palacios/vmm_mem.h \
../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \
../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h
palacios/vmm_paging.o: ../src/palacios/vmm_paging.c \
../include/palacios/vmm_paging.h ../include/palacios/vmm_types.h \
../include/geekos/ktypes.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \
../include/palacios/vmm_shadow_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
- ../include/palacios/vm_guest_mem.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h ../include/palacios/vm_guest_mem.h
palacios/vmm_io.o: ../src/palacios/vmm_io.c ../include/palacios/vmm_io.h \
../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
../include/palacios/vmm.h ../include/palacios/vmm_mem.h \
../include/palacios/vm_guest.h ../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h
palacios/vmm_debug.o: ../src/palacios/vmm_debug.c ../include/palacios/vmm_debug.h \
../include/palacios/vmm.h ../include/palacios/vmm_string.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \
../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_irq.h
palacios/svm_io.o: ../src/palacios/svm_io.c ../include/palacios/svm_io.h \
../include/palacios/vm_guest.h ../include/palacios/vmm_mem.h \
../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
../include/palacios/vmm_string.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
- ../include/palacios/vmcb.h ../include/palacios/vmm.h \
- ../include/palacios/vmm_ctrl_regs.h ../include/palacios/vmm_emulate.h \
- ../include/palacios/vm_guest_mem.h
+ ../include/palacios/vmm_irq.h ../include/palacios/vmcb.h \
+ ../include/palacios/vmm.h ../include/palacios/vmm_ctrl_regs.h \
+ ../include/palacios/vmm_emulate.h ../include/palacios/vm_guest_mem.h
palacios/vmm_intr.o: ../src/palacios/vmm_intr.c ../include/palacios/vmm_intr.h \
../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
- ../include/palacios/vmm_string.h \
- /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h
+ ../include/palacios/vmm_list.h ../include/palacios/vmm_string.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
+ ../include/palacios/vmm_irq.h
+palacios/vmm_irq.o: ../src/palacios/vmm_irq.c ../include/palacios/vmm_irq.h \
+ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
+ ../include/palacios/vmm.h ../include/palacios/vmm_string.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
+ ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \
+ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
+ ../include/palacios/vmm_shadow_paging.h \
+ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h
palacios/vmm_shadow_paging.o: ../src/palacios/vmm_shadow_paging.c \
../include/palacios/vmm_shadow_paging.h ../include/palacios/vmm_util.h \
../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
../include/palacios/vm_guest.h ../include/palacios/vmm_io.h \
../include/palacios/vmm_intr.h ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_list.h ../include/palacios/vmm_irq.h \
../include/palacios/vm_guest_mem.h
palacios/vm_guest_mem.o: ../src/palacios/vm_guest_mem.c \
../include/palacios/vm_guest_mem.h ../include/palacios/vm_guest.h \
../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
../include/palacios/vmm_shadow_paging.h \
../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
- ../include/palacios/vmm_dev_mgr.h \
- ../include/palacios/vmm_device_types.h ../include/palacios/vmm_list.h \
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm_list.h \
../include/palacios/vmm_string.h \
/home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
- ../include/palacios/vmm.h
+ ../include/palacios/vmm_irq.h ../include/palacios/vmm.h
+palacios/vm_dev.o: ../src/palacios/vm_dev.c ../include/palacios/vm_dev.h \
+ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
+ ../include/palacios/vmm_list.h ../include/palacios/vmm_string.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm.h \
+ ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \
+ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
+ ../include/palacios/vmm_shadow_paging.h \
+ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
+ ../include/palacios/vmm_irq.h
+palacios/vmm_dev_mgr.o: ../src/palacios/vmm_dev_mgr.c ../include/palacios/vm_dev.h \
+ ../include/palacios/vmm_types.h ../include/geekos/ktypes.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
+ ../include/palacios/vmm_list.h ../include/palacios/vmm_string.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vm_guest.h \
+ ../include/palacios/vmm_mem.h ../include/palacios/vmm_io.h \
+ ../include/palacios/vmm_util.h ../include/palacios/vmm_shadow_paging.h \
+ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
+ ../include/palacios/vmm_irq.h ../include/palacios/vmm.h
+devices/nvram.o: ../src/devices/nvram.c ../include/devices/nvram.h \
+ ../include/palacios/vm_dev.h ../include/palacios/vmm_types.h \
+ ../include/geekos/ktypes.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stdbool.h \
+ ../include/palacios/vmm_list.h ../include/palacios/vmm_string.h \
+ /home/jarusl/vmm-dev/devtools/i386/lib/gcc/i386-elf/3.4.6/include/stddef.h \
+ ../include/palacios/vmm_dev_mgr.h ../include/palacios/vmm.h \
+ ../include/palacios/vmm_mem.h ../include/palacios/vm_guest.h \
+ ../include/palacios/vmm_io.h ../include/palacios/vmm_util.h \
+ ../include/palacios/vmm_shadow_paging.h \
+ ../include/palacios/vmm_paging.h ../include/palacios/vmm_intr.h \
+ ../include/palacios/vmm_irq.h
-struct vm_device * nvram_create();
+struct vm_device *create_nvram();
#endif
int handle_shadow_paging(struct guest_info * info);
+int handle_svm_intr(struct guest_info * info);
+
int handle_svm_exit(struct guest_info * info);
#endif
struct guest_info * vm;
- struct vm_device *next, *prev;
+ struct list_head dev_link;
- struct dev_io_hook_list io_hooks;
- struct dev_mem_hook_list mem_hooks;
+ uint_t num_io_hooks;
+ struct list_head io_hooks;
+ uint_t num_mem_hooks;
+ struct list_head mem_hooks;
+ uint_t num_irq_hooks;
+ struct list_head irq_hooks;
+
};
void * end);
-
+int dev_hook_irq(struct vm_device * dev,
+ uint_t irq,
+ int (*handler)(uint_t irq, struct vm_device * dev));
+int dev_unhook_irq(struct vm_device * dev, uint_t irq);
#endif
#include <palacios/vmm_shadow_paging.h>
#include <palacios/vmm_intr.h>
#include <palacios/vmm_dev_mgr.h>
+#include <palacios/vmm_irq.h>
typedef ullong_t gpr_t;
// This structure is how we get interrupts for the guest
struct vm_intr intr_state;
+
+ struct vmm_irq_map irq_map;
vmm_io_map_t io_map;
// device_map
#define _VMM_DEV_MGR
#include <palacios/vmm_types.h>
-#include <palacios/vmm_device_types.h>
#include <palacios/vmm_list.h>
#include <palacios/vmm_string.h>
-
struct vm_device;
struct guest_info;
-struct vm_dev_list {
- struct vm_device * head;
- uint_t num_devs;
-};
-
-
-struct dev_io_hook_list {
- struct dev_io_hook * head;
- uint_t num_hooks;
-};
-
-
-struct dev_mem_hook_list {
- struct dev_mem_hook * head;
- uint_t num_hooks;
-};
+struct vmm_dev_mgr {
+ uint_t num_devs;
+ struct list_head dev_list;
+ uint_t num_io_hooks;
+ struct list_head io_hooks;
+
+ uint_t num_mem_hooks;
+ struct list_head mem_hooks;
-struct vmm_dev_mgr {
- struct vm_dev_list dev_list;
- struct dev_io_hook_list io_hooks;
- struct dev_mem_hook_list mem_hooks;
+ uint_t num_irq_hooks;
+ struct list_head irq_hooks;
};
struct vm_device * dev;
// Do not touch anything below this
- struct dev_io_hook *dev_next, *dev_prev;
- struct dev_io_hook *mgr_next, *mgr_prev;
+ /*
+ struct dev_io_hook *dev_next, *dev_prev;
+ struct dev_io_hook *mgr_next, *mgr_prev;
+ */
+ struct list_head dev_list;
+ struct list_head mgr_list;
};
struct dev_mem_hook {
- void *addr_start;
- void *addr_end;
+ void *addr_start;
+ void *addr_end;
+
+ struct vm_device * dev;
// Do not touch anything below this
- struct dev_mem_hook *dev_next, *dev_prev;
- struct dev_mem_hook *mgr_next, *mgr_prev;
+ struct list_head dev_list;
+ struct list_head mgr_list;
};
+struct dev_irq_hook {
+ uint_t irq;
+ int (*handler)(uint_t irq, struct vm_device * dev);
+
+ struct vm_device * dev;
+
+ struct list_head dev_list;
+ struct list_head mgr_list;
+};
// Registration of devices
int dev_mgr_remove_device(struct vmm_dev_mgr * mgr, struct vm_device * dev);
+/*
+ int dev_mgr_add_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook);
+ int dev_mgr_remove_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook);
+ int dev_add_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook);
+ int dev_remove_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook);
+ struct dev_io_hook * dev_find_io_hook(struct vm_device * dev, ushort_t port);
+ struct dev_io_hook * dev_mgr_find_io_hook(struct vmm_dev_mgr * mgr, ushort_t port)
+*/
+
void PrintDebugDevMgr(struct vmm_dev_mgr * mgr);
void PrintDebugDev(struct vm_device * dev);
void PrintDebugDevIO(struct vm_device * dev);
+++ /dev/null
-#ifndef _vmm_device_types
-#define _vmm_device_types
-
-
-
-enum vmm_device_type {
- VMM_DEVICE_PIC,
- VMM_DEVICE_APIC,
- VMM_DEVICE_NVRAM
-};
-
-#endif
-#ifndef __VMM_INTR_H
-#define __VMM_INTR_H
+#ifndef __VMM_INTR_H_
+#define __VMM_INTR_H_
+#include <palacios/vmm_intr.h>
#include <palacios/vmm_types.h>
#define DE_EXCEPTION 0x00
uint_t get_intr_number(struct vm_intr * intr);
intr_types_t get_intr_type(struct vm_intr * intr);
-
#endif
#undef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
+
static inline void prefetch(const void *x) {;}
/*
-struct vm_device *nvram_create() {
+struct vm_device *create_nvram() {
struct nvram_internal * nvram_state = os_hooks->malloc(sizeof(struct nvram_internal));
struct vm_device *device = create_device("NVRAM", &dev_ops, nvram_state);
#include <geekos/screen.h>
#include <palacios/vmm_dev_mgr.h>
#include <devices/nvram.h>
+#include <devices/timer.h>
#define SPEAKER_PORT 0x61
vm_info.cpu_mode = REAL;
+ init_irq_map(&(vm_info.irq_map));
init_vmm_io_map(&(vm_info.io_map));
init_interrupt_state(&(vm_info.intr_state));
+ dev_mgr_init(&(vm_info.dev_mgr));
if (0) {
hook_io_port(&(vm_info.io_map), 0x403, &IO_Read, &IO_Write_to_Serial, NULL);
{
- struct vm_device * nvram = nvram_create();
+ struct vm_device * nvram = create_nvram();
+ struct vm_device * timer = create_timer();
+
attach_device(&(vm_info), nvram);
+ //attach_device(&(vm_info), timer);
PrintDebugDevMgr(&(vm_info.dev_mgr));
+
+
}
+ PrintDebug("foo\n");
+
vm_info.rip = 0xfff0;
vm_info.vm_regs.rsp = 0x0;
(vmm_ops).start_guest(&vm_info);
return 0;
-
}
ctrl_area->instrs.IOIO_PROT = 1;
}
- //ctrl_area->instrs.instrs.INTR = 1;
+ if (vm_info.irq_map.num_hooks > 0) {
+ PrintDebug("Exiting on interrupts\n");
+ ctrl_area->guest_ctrl.V_INTR_MASKING = 1;
+ ctrl_area->instrs.INTR = 1;
+ }
if (vm_info.page_mode == SHADOW_PAGING) {
(info->page_mode == SHADOW_PAGING)) {
handle_shadow_paging(info);
*/
+
+ } else if (exit_code == VMEXIT_INTR) {
+ handle_svm_intr(info);
} else {
addr_t rip_addr = get_addr_linear(info, guest_state->rip, guest_state->cs.selector);
char buf[15];
+int handle_svm_intr(struct guest_info * info) {
+ vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data));
+ // vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
+
+ //struct Interrupt_Info * int_info = &(guest_ctrl->exit_int_info);
+
+ //struct vmm_irq_hook * get_irq_hook(&(info->irq_map), int_info->vector);
+
+ PrintDebug("SVM Returned: Exit Code: %x\n",guest_ctrl->exit_code);
+ PrintDebug("V_INTR_VECTOR: 0x%x\n", guest_ctrl->guest_ctrl.V_INTR_VECTOR);
+
+
+
+
+ while(1);
+
+
+
+
+
+
+
+
+
+ return 0;
+}
dev->vm = NULL;
dev->private_data = NULL;
- dev->next = NULL;
- dev->prev = NULL;
- dev->io_hooks.head = NULL;
- dev->mem_hooks.head = NULL;
- dev->io_hooks.num_hooks = 0;
- dev->mem_hooks.num_hooks = 0;
+
+ INIT_LIST_HEAD(&(dev->io_hooks));
+ dev->num_io_hooks = 0;
+
+ INIT_LIST_HEAD(&(dev->mem_hooks));
+ dev->num_mem_hooks = 0;
+
+ INIT_LIST_HEAD(&(dev->irq_hooks));
+ dev->num_irq_hooks = 0;
+
return dev;
}
void free_device(struct vm_device * dev) {
VMMFree(dev);
}
+
#include <palacios/vmm_dev_mgr.h>
#include <palacios/vm_guest.h>
#include <palacios/vmm.h>
-
+#include <palacios/vmm_irq.h>
extern struct vmm_os_hooks *os_hooks;
#endif
int dev_mgr_init(struct vmm_dev_mgr * mgr) {
- mgr->dev_list.head = NULL;
- mgr->dev_list.num_devs = 0;
+
+ INIT_LIST_HEAD(&(mgr->dev_list));
+ mgr->num_devs = 0;
+
+ INIT_LIST_HEAD(&(mgr->io_hooks));
+ mgr->num_io_hooks = 0;
return 0;
}
-int dev_mgr_deinit(struct vmm_dev_mgr * mgr)
-{
- struct vm_device * dev = mgr->dev_list.head;
+int dev_mgr_deinit(struct vmm_dev_mgr * mgr) {
+ struct vm_device * dev;
- while (dev) {
+ list_for_each_entry(dev, &(mgr->dev_list), dev_link) {
unattach_device(dev);
free_device(dev);
- dev = dev->next;
}
+
return 0;
}
int dev_mgr_add_device(struct vmm_dev_mgr * mgr, struct vm_device * dev) {
- dev->next = mgr->dev_list.head;
- dev->prev = 0;
- if (dev->next) {
- dev->next->prev = dev;
- }
- mgr->dev_list.head = dev;
-
- mgr->dev_list.num_devs++;
+ list_add(&(dev->dev_link), &(mgr->dev_list));
+ mgr->num_devs++;
return 0;
}
int dev_mgr_remove_device(struct vmm_dev_mgr * mgr, struct vm_device * dev) {
- if (mgr->dev_list.head == dev) {
- mgr->dev_list.head = dev->next;
- } else {
- dev->prev->next = dev->next;
- }
- if (dev->next) {
- dev->next->prev = dev->prev;
- }
-
- mgr->dev_list.num_devs--;
+ list_del(&(dev->dev_link));
+ mgr->num_devs--;
return 0;
}
-int dev_mgr_add_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook) {
- hook->mgr_next = mgr->io_hooks.head;
- hook->mgr_prev = NULL;
- if (hook->mgr_next) {
- hook->mgr_next->mgr_prev = hook;
- }
- mgr->io_hooks.head = hook;
-
- mgr->io_hooks.num_hooks++;
+/* IO HOOKS */
+int dev_mgr_add_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook) {
+ list_add(&(hook->mgr_list), &(mgr->io_hooks));
+ mgr->num_io_hooks++;
return 0;
}
int dev_mgr_remove_io_hook(struct vmm_dev_mgr * mgr, struct dev_io_hook * hook) {
- if (mgr->io_hooks.head == hook) {
- mgr->io_hooks.head = hook->mgr_next;
- } else {
- hook->mgr_prev->mgr_next = hook->mgr_next;
- }
-
- if (hook->mgr_next) {
- hook->mgr_next->mgr_prev = hook->mgr_prev;
- }
-
- mgr->io_hooks.num_hooks--;
+ list_del(&(hook->mgr_list));
+ mgr->num_io_hooks--;
return 0;
}
int dev_add_io_hook(struct vm_device * dev, struct dev_io_hook * hook) {
- hook->dev_next = dev->io_hooks.head;
- hook->dev_prev = NULL;
- if (hook->dev_next) {
- hook->dev_next->dev_prev = hook;
- }
- dev->io_hooks.head = hook;
-
- dev->io_hooks.num_hooks++;
-
+ list_add(&(hook->dev_list), &(dev->io_hooks));
+ dev->num_io_hooks++;
return 0;
}
int dev_remove_io_hook(struct vm_device * dev, struct dev_io_hook * hook) {
- if (dev->io_hooks.head == hook) {
- dev->io_hooks.head = hook->dev_next;
- } else {
- hook->dev_prev->dev_next = hook->dev_next;
- }
-
- if (hook->dev_next) {
- hook->dev_next->dev_prev = hook->dev_prev;
- }
-
- dev->io_hooks.num_hooks--;
+ list_del(&(hook->dev_list));
+ dev->num_io_hooks--;
return 0;
}
+
+
+
struct dev_io_hook * dev_mgr_find_io_hook(struct vmm_dev_mgr * mgr, ushort_t port) {
- struct dev_io_hook * tmp = mgr->io_hooks.head;
+ struct dev_io_hook * tmp;
- while (tmp) {
+ list_for_each_entry(tmp, &(mgr->io_hooks), mgr_list) {
if (tmp->port == port) {
- break;
+ return tmp;
}
- tmp = tmp->mgr_next;
}
-
- return tmp;
+ return NULL;
}
struct dev_io_hook * dev_find_io_hook(struct vm_device * dev, ushort_t port) {
- struct dev_io_hook * tmp = dev->io_hooks.head;
+ struct dev_io_hook * tmp;
- while (tmp) {
+ list_for_each_entry(tmp, &(dev->io_hooks), dev_list) {
if (tmp->port == port) {
- break;
+ return tmp;
}
- tmp = tmp->dev_next;
}
-
- return tmp;
-}
-
-
-
-
-int attach_device(struct guest_info * vm, struct vm_device * dev) {
- struct vmm_dev_mgr *mgr= &(vm->dev_mgr);
-
- dev->vm = vm;
- dev_mgr_add_device(mgr, dev);
- dev->ops->init(dev);
-
- return 0;
+ return NULL;
}
-int unattach_device(struct vm_device * dev) {
- struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr);
-
- dev->ops->deinit(dev);
- dev_mgr_remove_device(mgr, dev);
- dev->vm = NULL;
-
- return 0;
-}
+
+/* IRQ HOOKS */
+
+int dev_mgr_add_irq_hook(struct vmm_dev_mgr * mgr, struct dev_irq_hook * hook) {
+ list_add(&(hook->mgr_list), &(mgr->irq_hooks));
+ mgr->num_irq_hooks++;
+ return 0;
+}
+
+
+int dev_mgr_remove_irq_hook(struct vmm_dev_mgr * mgr, struct dev_irq_hook * hook) {
+ list_del(&(hook->mgr_list));
+ mgr->num_irq_hooks--;
+
+ return 0;
+}
+
+
+int dev_add_irq_hook(struct vm_device * dev, struct dev_irq_hook * hook) {
+ list_add(&(hook->dev_list), &(dev->irq_hooks));
+ dev->num_irq_hooks++;
+ return 0;
+}
+
+
+int dev_remove_irq_hook(struct vm_device * dev, struct dev_irq_hook * hook) {
+ list_del(&(hook->dev_list));
+ dev->num_irq_hooks--;
+
+ return 0;
+}
+
+
+
+
+
+struct dev_irq_hook * dev_mgr_find_irq_hook(struct vmm_dev_mgr * mgr, uint_t irq) {
+ struct dev_irq_hook * tmp;
+
+ list_for_each_entry(tmp, &(mgr->irq_hooks), mgr_list) {
+ if (tmp->irq == irq) {
+ return tmp;
+ }
+ }
+ return NULL;
+}
+
+struct dev_irq_hook * dev_find_irq_hook(struct vm_device * dev, uint_t irq) {
+ struct dev_irq_hook * tmp;
+
+ list_for_each_entry(tmp, &(dev->irq_hooks), dev_list) {
+ if (tmp->irq == irq) {
+ return tmp;
+ }
+ }
+ return NULL;
+}
+
+
+
+
+int dev_hook_irq(struct vm_device *dev,
+ uint_t irq,
+ int (*handler)(uint_t irq, struct vm_device * dev)) {
+
+ struct dev_irq_hook *hook = os_hooks->malloc(sizeof(struct dev_irq_hook));
+
+ if (!hook) {
+ return -1;
+ }
+
+
+ if (hook_irq(&(dev->vm->irq_map), irq,
+ (int (*)(uint_t, void *))handler,
+ (void *)dev) == 0) {
+
+ hook->dev = dev;
+ hook->irq = irq;
+ hook->handler = handler;
+
+ dev_mgr_add_irq_hook(&(dev->vm->dev_mgr), hook);
+ dev_add_irq_hook(dev, hook);
+ } else {
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int dev_unhook_irq(struct vm_device * dev,
+ uint_t irq) {
+
+ struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr);
+ struct dev_irq_hook * hook = dev_mgr_find_irq_hook(mgr, irq);
+
+ if (!hook) {
+ return -1;
+ }
+
+ dev_mgr_remove_irq_hook(mgr, hook);
+ dev_remove_irq_hook(dev, hook);
+
+ return unhook_irq(&(dev->vm->irq_map), irq);
+}
+
+
+
+
+
+
+
+
+int attach_device(struct guest_info * vm, struct vm_device * dev) {
+ struct vmm_dev_mgr *mgr= &(vm->dev_mgr);
+
+ dev->vm = vm;
+ dev_mgr_add_device(mgr, dev);
+ dev->ops->init(dev);
+
+ return 0;
+}
+
+int unattach_device(struct vm_device * dev) {
+ struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr);
+
+ dev->ops->deinit(dev);
+ dev_mgr_remove_device(mgr, dev);
+ dev->vm = NULL;
+
+ return 0;
+}
+
+
+
+
+
int dev_mgr_hook_mem(struct guest_info *vm,
struct vm_device *device,
void *start,
void *end)
{
- struct dev_mem_hook *hook = os_hooks->malloc(sizeof(struct dev_mem_hook));
+ struct dev_mem_hook *hook;
+ VMMMalloc(struct dev_mem_hook *, hook,sizeof(struct dev_mem_hook));
if (!hook) {
return -1;
}
-int dev_mgr_unhook_mem(struct guest_info *vm,
- struct vm_device *device,
- void *start,
- void *end)
-{
- struct dev_mem_hook *hook = device->mem_hooks.head;
-
- while (hook) {
- if (((hook->addr_start) == start) && (hook->addr_end == end)) {
- break;
- }
- }
-
+int dev_mgr_unhook_mem(struct vm_device *dev,
+ addr_t start,
+ addr_t end) {
+ /*
+ struct vmm_dev_mgr * mgr = &(dev->vm->dev_mgr);
+ struct dev_mem_hook *hook = dev_mgr_find_mem_hook(mgr, start, end);
+
if (!hook) {
// Very bad - unhooking something that doesn't exist!
return -1;
}
-
+ */
/* not implemented yet
return unhook_mem_port(vm->mem_map,
void PrintDebugDevMgr(struct vmm_dev_mgr * mgr) {
- struct vm_device * dev = mgr->dev_list.head;
+ struct vm_device * dev;
+ PrintDebug("%d devices registered with manager\n", mgr->num_devs);
- while (dev) {
+ list_for_each_entry(dev, &(mgr->dev_list), dev_link) {
PrintDebugDev(dev);
- dev = dev->next;
+ PrintDebug("next..\n");
}
return;
}
void PrintDebugDevIO(struct vm_device * dev) {
- struct dev_io_hook * hook = dev->io_hooks.head;
-
- PrintDebug("IO Hooks (%d) for Device: %s\n", dev->io_hooks.num_hooks, dev->name);
-
- while (hook) {
+ struct dev_io_hook * hook;
+
+ PrintDebug("IO Hooks(%d) for Device: %s\n", dev->num_io_hooks, dev->name);
+
+ list_for_each_entry(hook, &(dev->io_hooks), dev_list) {
PrintDebug("\tPort: 0x%x (read=0x%x), (write=0x%x)\n", hook->port, hook->read, hook->write);
- hook = hook->dev_next;
}
return;
#include <palacios/vmm_intr.h>
+
+
#include <palacios/vm_guest.h>