5 #include <geekos/ktypes.h>
6 #include <geekos/string.h>
8 #include <geekos/vmm_mem.h>
9 //#include <geekos/vmm_paging.h>
11 #include <geekos/vm_guest.h>
13 /* utility definitions */
14 #define PrintDebug(fmt, args...) \
16 extern struct vmm_os_hooks * os_hooks; \
17 if ((os_hooks) && (os_hooks)->print_debug) { \
18 (os_hooks)->print_debug((fmt), ##args); \
24 #define PrintInfo(fmt, args...) \
26 extern struct vmm_os_hooks * os_hooks; \
27 if ((os_hooks) && (os_hooks)->print_info) { \
28 (os_hooks)->print_info((fmt), ##args); \
33 #define PrintTrace(fmt, args...) \
35 extern struct vmm_os_hooks * os_hooks; \
36 if ((os_hooks) && (os_hooks)->print_trace) { \
37 (os_hooks)->print_trace((fmt), ##args); \
44 /* This clearly won't work, we need some way to get a return value out of it */
45 #define VMMMalloc(size) \
47 extern struct vmm_os_hooks * os_hooks; \
48 if ((os_hooks) && (os_hooks)->malloc) { \
49 (os_hooks)->malloc(size); \
54 // We need to check the hook structure at runtime to ensure its SAFE
55 #define VMMFree(addr) \
57 extern struct vmm_os_hooks * os_hooks; \
58 if ((os_hooks) && (os_hooks)->free) { \
59 (os_hooks)->free(addr); \
67 #define VMM_INVALID_CPU 0
76 /* We need a memory map and an IO device map */
78 /* This will contain function pointers that provide OS services */
80 void (*print_info)(const char * format, ...);
81 void (*print_debug)(const char * format, ...);
82 void (*print_trace)(const char * format, ...);
84 void *(*allocate_pages)(int numPages);
85 void (*free_page)(void * page);
87 void *(*malloc)(uint_t size);
88 void (*free)(void * addr);
90 void *(*paddr_to_vaddr)(void *addr);
91 void *(*vaddr_to_paddr)(void *addr);
94 void (*start_kernel_thread)(); // include pointer to function
100 /* This will contain Function pointers that control the VMs */
101 struct vmm_ctrl_ops {
102 int (*init_guest)(struct guest_info* info);
103 int (*start_guest)(struct guest_info * info);
104 // int (*stop_vm)(uint_t vm_id);
113 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);