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.


WTF??????
[palacios.git] / palacios / include / geekos / vmm.h
1 #ifndef __VMM_H
2 #define __VMM_H
3
4
5 #include <geekos/ktypes.h>
6 #include <geekos/string.h>
7
8 #include <geekos/vmm_mem.h>
9 #include <geekos/vmm_paging.h>
10
11
12 /* utility definitions */
13 #define PrintDebug(fmt, args...)                        \
14   do {                                                  \
15     extern struct vmm_os_hooks * os_hooks;              \
16     if ((os_hooks) && (os_hooks)->print_debug) {        \
17       (os_hooks)->print_debug((fmt), ##args);           \
18     }                                                   \
19   } while (0)                                           \
20
21
22
23 #define PrintInfo(fmt, args...)                         \
24   do {                                                  \
25     extern struct vmm_os_hooks * os_hooks;              \
26     if ((os_hooks) && (os_hooks)->print_info) {         \
27       (os_hooks)->print_info((fmt), ##args);            \
28     }                                                   \
29   } while (0)                                           \
30
31
32 #define PrintTrace(fmt, args...)                        \
33   do {                                                  \
34     extern struct vmm_os_hooks * os_hooks;              \
35     if ((os_hooks) && (os_hooks)->print_trace) {        \
36       (os_hooks)->print_trace((fmt), ##args);           \
37     }                                                   \
38   } while (0)                                           \
39
40
41
42
43 /* This clearly won't work, we need some way to get a return value out of it */
44 #define VMMMalloc(size)                                 \
45   do {                                                  \
46     extern struct vmm_os_hooks * os_hooks;              \
47     if ((os_hooks) && (os_hooks)->malloc) {             \
48       (os_hooks)->malloc(size);                         \
49     }                                                   \
50   } while (0)                                           \
51
52
53 // We need to check the hook structure at runtime to ensure its SAFE
54 #define VMMFree(addr)                                   \
55   do {                                                  \
56     extern struct vmm_os_hooks * os_hooks;              \
57     if ((os_hooks) && (os_hooks)->free) {               \
58       (os_hooks)->free(addr);                           \
59     }                                                   \
60   } while (0)                                           \
61
62
63 /* ** */
64
65
66 #define VMM_INVALID_CPU 0
67 #define VMM_VMX_CPU 1
68 #define VMM_SVM_CPU 2
69
70
71
72 typedef struct guest_info {
73   ullong_t rip;
74   ullong_t rsp;
75
76   vmm_mem_list_t mem_list;
77   vmm_mem_layout_t mem_layout;
78   // device_map
79
80   pml4e64_t * page_tables;
81   void * vmm_data;
82 } guest_info_t;
83
84
85
86 /* We need a memory map and an IO device map */
87
88 /* This will contain function pointers that provide OS services */
89 struct vmm_os_hooks {
90   void (*print_info)(const char * format, ...);
91   void (*print_debug)(const char * format, ...);
92   void (*print_trace)(const char * format, ...);
93   
94   void *(*allocate_pages)(int numPages);
95   void (*free_page)(void * page);
96
97   void *(*malloc)(uint_t size);
98   void (*free)(void * addr);
99
100
101   void (*start_kernel_thread)(); // include pointer to function
102 };
103
104
105
106
107 /* This will contain Function pointers that control the VMs */
108 struct vmm_ctrl_ops {
109   int (*init_guest)(struct guest_info* info);
110   int (*start_guest)(struct guest_info * info);
111   //  int (*stop_vm)(uint_t vm_id);
112 };
113
114
115
116
117
118
119
120 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
121
122
123
124
125
126 #endif