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.


lot of changes
[palacios.git] / palacios / include / palacios / vmm.h
1 #ifndef __VMM_H
2 #define __VMM_H
3
4
5 #include <palacios/vm_guest.h>
6 #include <palacios/vmm_mem.h>
7
8 #ifdef __V3VEE__
9
10 //#include <palacios/vmm_types.h>
11 #include <palacios/vmm_string.h>
12
13
14 //#include <palacios/vmm_paging.h>
15
16 /* utility definitions */
17 #define PrintDebug(fmt, args...)                        \
18   do {                                                  \
19     extern struct vmm_os_hooks * os_hooks;              \
20     if ((os_hooks) && (os_hooks)->print_debug) {        \
21       (os_hooks)->print_debug((fmt), ##args);           \
22     }                                                   \
23   } while (0)                                           \
24
25
26
27 #define PrintInfo(fmt, args...)                         \
28   do {                                                  \
29     extern struct vmm_os_hooks * os_hooks;              \
30     if ((os_hooks) && (os_hooks)->print_info) {         \
31       (os_hooks)->print_info((fmt), ##args);            \
32     }                                                   \
33   } while (0)                                           \
34
35
36 #define PrintTrace(fmt, args...)                        \
37   do {                                                  \
38     extern struct vmm_os_hooks * os_hooks;              \
39     if ((os_hooks) && (os_hooks)->print_trace) {        \
40       (os_hooks)->print_trace((fmt), ##args);           \
41     }                                                   \
42   } while (0)                                           \
43
44
45
46 #define V3_AllocPages(ptr, num_pages)                   \
47   do {                                                  \
48     extern struct vmm_os_hooks * os_hooks;              \
49     ptr = 0;                                            \
50     if ((os_hooks) && (os_hooks)->allocate_pages) {     \
51       ptr = (os_hooks)->allocate_pages(num_pages);      \
52     }                                                   \
53   } while (0)                                           \
54
55
56 /*
57 #define V3_Malloc(type, var, size)                      \
58   do {                                                  \
59     extern struct vmm_os_hooks * os_hooks;              \
60     var = 0;                                            \
61     if ((os_hooks) && (os_hooks)->malloc) {             \
62       var = (type)(os_hooks)->malloc(size);             \
63     }                                                   \
64   } while (0)                                           \
65 */
66
67 #define V3_Malloc(size) ({                      \
68       extern struct vmm_os_hooks * os_hooks;    \
69       void * var = 0;                           \
70       if ((os_hooks) && (os_hooks)->malloc) {   \
71         var = (os_hooks)->malloc(size);         \
72       }                                         \
73       var;                                      \
74     })
75
76 // We need to check the hook structure at runtime to ensure its SAFE
77 #define V3_Free(addr)                                   \
78   do {                                                  \
79     extern struct vmm_os_hooks * os_hooks;              \
80     if ((os_hooks) && (os_hooks)->free) {               \
81       (os_hooks)->free(addr);                           \
82     }                                                   \
83   } while (0)                                           \
84
85 #define V3_CPU_KHZ(khz)                                 \
86   do {                                                  \
87     extern struct vmm_os_hooks * os_hooks;              \
88     if ((os_hooks) && (os_hooks)->get_cpu_khz) {        \
89       khz = (os_hooks)->get_cpu_khz();                  \
90     }                                                   \
91   } while (0)                                           \
92
93
94 /* ** */
95
96 #define V3_ASSERT(x)                                                    \
97   do {                                                                  \
98     if (!(x)) {                                                         \
99       PrintDebug("Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \
100                  __func__, #x, __FILE__, __LINE__,                      \
101                  (ulong_t) __builtin_return_address(0));                \
102       while(1);                                                         \
103     }                                                                   \
104   } while(0)                                                            \
105     
106
107 #define VMM_INVALID_CPU 0
108 #define VMM_VMX_CPU 1
109 #define VMM_SVM_CPU 2
110
111 #endif //!__V3VEE__
112
113
114 /* This will contain function pointers that provide OS services */
115 struct vmm_os_hooks {
116   void (*print_info)(const char * format, ...);
117   void (*print_debug)(const char * format, ...);
118   void (*print_trace)(const char * format, ...);
119   
120   void *(*allocate_pages)(int numPages);
121   void (*free_page)(void * page);
122
123   void *(*malloc)(unsigned int size);
124   void (*free)(void * addr);
125
126   void *(*paddr_to_vaddr)(void *addr);
127   void *(*vaddr_to_paddr)(void *addr);
128
129   int (*hook_interrupt)(struct guest_info * info, int irq);
130   int (*ack_irq)(int irq);
131
132
133   unsigned int (*get_cpu_khz)();
134
135   // Do we need this here?
136   //  void (*snprintf)(char * dst, char * format, int len, ...);
137
138
139
140   void (*start_kernel_thread)(); // include pointer to function
141 };
142
143
144
145 /* This will contain Function pointers that control the VMs */
146 struct vmm_ctrl_ops {
147   int (*init_guest)(struct guest_info* info);
148   int (*start_guest)(struct guest_info * info);
149   //  int (*stop_vm)(uint_t vm_id);
150
151
152
153 };
154
155
156
157
158 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
159
160
161
162
163
164 #endif