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.


more shadow paging 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 // We need to check the hook structure at runtime to ensure its SAFE
68 #define V3_Free(addr)                                   \
69   do {                                                  \
70     extern struct vmm_os_hooks * os_hooks;              \
71     if ((os_hooks) && (os_hooks)->free) {               \
72       (os_hooks)->free(addr);                           \
73     }                                                   \
74   } while (0)                                           \
75
76
77 /* ** */
78
79 #define V3_ASSERT(x)                                                    \
80   do {                                                                  \
81     if (!(x)) {                                                         \
82       PrintDebug("Failed assertion in %s: %s at %s, line %d, RA=%lx\n", \
83                  __func__, #x, __FILE__, __LINE__,                      \
84                  (ulong_t) __builtin_return_address(0));                \
85       while(1);                                                         \
86     }                                                                   \
87   } while(0)                                                            \
88     
89
90 #define VMM_INVALID_CPU 0
91 #define VMM_VMX_CPU 1
92 #define VMM_SVM_CPU 2
93
94 #endif //!__V3VEE__
95
96
97 /* This will contain function pointers that provide OS services */
98 struct vmm_os_hooks {
99   void (*print_info)(const char * format, ...);
100   void (*print_debug)(const char * format, ...);
101   void (*print_trace)(const char * format, ...);
102   
103   void *(*allocate_pages)(int numPages);
104   void (*free_page)(void * page);
105
106   void *(*malloc)(unsigned int size);
107   void (*free)(void * addr);
108
109   void *(*paddr_to_vaddr)(void *addr);
110   void *(*vaddr_to_paddr)(void *addr);
111
112   int (*hook_interrupt)(struct guest_info * info, int irq);
113   int (*ack_irq)(int irq);
114
115   // Do we need this here?
116   void (*snprintf)(char * dst, char * format, int len, ...);
117
118   void (*start_kernel_thread)(); // include pointer to function
119 };
120
121
122
123 /* This will contain Function pointers that control the VMs */
124 struct vmm_ctrl_ops {
125   int (*init_guest)(struct guest_info* info);
126   int (*start_guest)(struct guest_info * info);
127   //  int (*stop_vm)(uint_t vm_id);
128
129
130
131 };
132
133
134
135
136 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
137
138
139
140
141
142 #endif