5 //#include <palacios/vmm_types.h>
6 #include <palacios/vmm_string.h>
8 #include <palacios/vmm_mem.h>
9 //#include <palacios/vmm_paging.h>
11 #include <palacios/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(type, var, size) \
47 extern struct vmm_os_hooks * os_hooks; \
48 if ((os_hooks) && (os_hooks)->malloc) { \
49 var = (type)(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
73 /* This will contain function pointers that provide OS services */
75 void (*print_info)(const char * format, ...);
76 void (*print_debug)(const char * format, ...);
77 void (*print_trace)(const char * format, ...);
79 void *(*allocate_pages)(int numPages);
80 void (*free_page)(void * page);
82 void *(*malloc)(unsigned int size);
83 void (*free)(void * addr);
85 void *(*paddr_to_vaddr)(void *addr);
86 void *(*vaddr_to_paddr)(void *addr);
88 int (*hook_interrupt)(struct guest_info * info, int irq);
89 int (*ack_irq)(int irq);
91 // Do we need this here?
92 void (*snprintf)(char * dst, char * format, int len, ...);
94 void (*start_kernel_thread)(); // include pointer to function
99 /* This will contain Function pointers that control the VMs */
100 struct vmm_ctrl_ops {
101 int (*init_guest)(struct guest_info* info);
102 int (*start_guest)(struct guest_info * info);
103 // int (*stop_vm)(uint_t vm_id);
112 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);