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.


code restructuring
[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(size)                                 \
46   do {                                                  \
47     extern struct vmm_os_hooks * os_hooks;              \
48     if ((os_hooks) && (os_hooks)->malloc) {             \
49       (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
67 #define VMM_INVALID_CPU 0
68 #define VMM_VMX_CPU 1
69 #define VMM_SVM_CPU 2
70
71
72
73
74
75
76 /* We need a memory map and an IO device map */
77
78 /* This will contain function pointers that provide OS services */
79 struct vmm_os_hooks {
80   void (*print_info)(const char * format, ...);
81   void (*print_debug)(const char * format, ...);
82   void (*print_trace)(const char * format, ...);
83   
84   void *(*allocate_pages)(int numPages);
85   void (*free_page)(void * page);
86
87   void *(*malloc)(unsigned int size);
88   void (*free)(void * addr);
89
90   void *(*paddr_to_vaddr)(void *addr);
91   void *(*vaddr_to_paddr)(void *addr);
92
93
94   void (*start_kernel_thread)(); // include pointer to function
95 };
96
97
98
99
100 /* This will contain Function pointers that control the VMs */
101 struct vmm_ctrl_ops {
102   int (*init_guest)(struct guest_info* info);
103   int (*start_guest)(struct guest_info * info);
104   //  int (*stop_vm)(uint_t vm_id);
105 };
106
107
108
109
110
111
112
113 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
114
115
116
117
118
119 #endif