Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


*** empty log message ***
[palacios.git] / palacios / include / palacios / vmm.h
1 #ifndef __VMM_H
2 #define __VMM_H
3
4
5 //#include <palacios/vmm_types.h>
6 #include <palacios/vmm_string.h>
7
8 #include <palacios/vmm_mem.h>
9 //#include <palacios/vmm_paging.h>
10
11 #include <palacios/vm_guest.h>
12
13 /* utility definitions */
14 #define PrintDebug(fmt, args...)                        \
15   do {                                                  \
16     extern struct vmm_os_hooks * os_hooks;              \
17     if ((os_hooks) && (os_hooks)->print_debug) {        \
18       (os_hooks)->print_debug((fmt), ##args);           \
19     }                                                   \
20   } while (0)                                           \
21
22
23
24 #define PrintInfo(fmt, args...)                         \
25   do {                                                  \
26     extern struct vmm_os_hooks * os_hooks;              \
27     if ((os_hooks) && (os_hooks)->print_info) {         \
28       (os_hooks)->print_info((fmt), ##args);            \
29     }                                                   \
30   } while (0)                                           \
31
32
33 #define PrintTrace(fmt, args...)                        \
34   do {                                                  \
35     extern struct vmm_os_hooks * os_hooks;              \
36     if ((os_hooks) && (os_hooks)->print_trace) {        \
37       (os_hooks)->print_trace((fmt), ##args);           \
38     }                                                   \
39   } while (0)                                           \
40
41
42
43
44 /* This clearly won't work, we need some way to get a return value out of it */
45 #define VMMMalloc(type, var, size)                      \
46   do {                                                  \
47     extern struct vmm_os_hooks * os_hooks;              \
48     if ((os_hooks) && (os_hooks)->malloc) {             \
49       var = (type)(os_hooks)->malloc(size);             \
50     }                                                   \
51   } while (0)                                           \
52
53
54 // We need to check the hook structure at runtime to ensure its SAFE
55 #define VMMFree(addr)                                   \
56   do {                                                  \
57     extern struct vmm_os_hooks * os_hooks;              \
58     if ((os_hooks) && (os_hooks)->free) {               \
59       (os_hooks)->free(addr);                           \
60     }                                                   \
61   } while (0)                                           \
62
63
64 /* ** */
65
66 #define V3_ASSERT(x)                                                    \
67   do {                                                                  \
68     if (!(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));                \
72       while(1);                                                         \
73     }                                                                   \
74   } while(0)                                                            \
75     
76
77 #define VMM_INVALID_CPU 0
78 #define VMM_VMX_CPU 1
79 #define VMM_SVM_CPU 2
80
81
82
83 /* This will contain function pointers that provide OS services */
84 struct vmm_os_hooks {
85   void (*print_info)(const char * format, ...);
86   void (*print_debug)(const char * format, ...);
87   void (*print_trace)(const char * format, ...);
88   
89   void *(*allocate_pages)(int numPages);
90   void (*free_page)(void * page);
91
92   void *(*malloc)(unsigned int size);
93   void (*free)(void * addr);
94
95   void *(*paddr_to_vaddr)(void *addr);
96   void *(*vaddr_to_paddr)(void *addr);
97
98   int (*hook_interrupt)(struct guest_info * info, int irq);
99   int (*ack_irq)(int irq);
100
101   // Do we need this here?
102   void (*snprintf)(char * dst, char * format, int len, ...);
103
104   void (*start_kernel_thread)(); // include pointer to function
105 };
106
107
108
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);
114
115
116
117 };
118
119
120
121
122 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
123
124
125
126
127
128 #endif