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); \
66 #define V3_ASSERT(x) \
69 PrintDebug("Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \
70 __func__, #x, __FILE__, __LINE__, \
71 (ulong_t) __builtin_return_address(0)); \
77 #define VMM_INVALID_CPU 0
83 /* This will contain function pointers that provide OS services */
85 void (*print_info)(const char * format, ...);
86 void (*print_debug)(const char * format, ...);
87 void (*print_trace)(const char * format, ...);
89 void *(*allocate_pages)(int numPages);
90 void (*free_page)(void * page);
92 void *(*malloc)(unsigned int size);
93 void (*free)(void * addr);
95 void *(*paddr_to_vaddr)(void *addr);
96 void *(*vaddr_to_paddr)(void *addr);
98 int (*hook_interrupt)(struct guest_info * info, int irq);
99 int (*ack_irq)(int irq);
101 // Do we need this here?
102 void (*snprintf)(char * dst, char * format, int len, ...);
104 void (*start_kernel_thread)(); // include pointer to function
109 /* This will contain Function pointers that control the VMs */
110 struct vmm_ctrl_ops {
111 int (*init_guest)(struct guest_info* info);
112 int (*start_guest)(struct guest_info * info);
113 // int (*stop_vm)(uint_t vm_id);
122 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);