5 #include <geekos/ktypes.h>
6 #include <geekos/string.h>
8 #include <geekos/vmm_mem.h>
11 /* utility definitions */
12 #define PrintDebug(fmt, args...) \
14 extern struct vmm_os_hooks * os_hooks; \
15 if ((os_hooks) && (os_hooks)->print_debug) { \
16 (os_hooks)->print_debug((fmt), ##args); \
22 #define PrintInfo(fmt, args...) \
24 extern struct vmm_os_hooks * os_hooks; \
25 if ((os_hooks) && (os_hooks)->print_info) { \
26 (os_hooks)->print_info((fmt), ##args); \
31 #define PrintTrace(fmt, args...) \
33 extern struct vmm_os_hooks * os_hooks; \
34 if ((os_hooks) && (os_hooks)->print_trace) { \
35 (os_hooks)->print_trace((fmt), ##args); \
42 /* This clearly won't work, we need some way to get a return value out of it */
43 #define VMMMalloc(size) \
45 extern struct vmm_os_hooks * os_hooks; \
46 if ((os_hooks) && (os_hooks)->malloc) { \
47 (os_hooks)->malloc(size); \
52 // We need to check the hook structure at runtime to ensure its SAFE
53 #define VMMFree(addr) \
55 extern struct vmm_os_hooks * os_hooks; \
56 if ((os_hooks) && (os_hooks)->free) { \
57 (os_hooks)->free(addr); \
65 #define VMM_INVALID_CPU 0
71 typedef struct guest_info {
75 vmm_mem_list_t mem_list;
76 vmm_mem_layout_t mem_layout;
84 /* We need a memory map and an IO device map */
86 /* This will contain function pointers that provide OS services */
88 void (*print_info)(const char * format, ...);
89 void (*print_debug)(const char * format, ...);
90 void (*print_trace)(const char * format, ...);
92 void *(*Allocate_Pages)(int numPages);
93 void (*Free_Page)(void * page);
95 void *(*malloc)(uint_t size);
96 void (*free)(void * addr);
99 void (*start_kernel_thread)(); // include pointer to function
105 /* This will contain Function pointers that control the VMs */
106 struct vmm_ctrl_ops {
107 int (*init_guest)(struct guest_info* info);
108 int (*start_guest)(struct guest_info * info);
109 // int (*stop_vm)(uint_t vm_id);
118 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);