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.


added irq initial setup
[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
67 #define VMM_INVALID_CPU 0
68 #define VMM_VMX_CPU 1
69 #define VMM_SVM_CPU 2
70
71
72
73 /* This will contain function pointers that provide OS services */
74 struct vmm_os_hooks {
75   void (*print_info)(const char * format, ...);
76   void (*print_debug)(const char * format, ...);
77   void (*print_trace)(const char * format, ...);
78   
79   void *(*allocate_pages)(int numPages);
80   void (*free_page)(void * page);
81
82   void *(*malloc)(unsigned int size);
83   void (*free)(void * addr);
84
85   void *(*paddr_to_vaddr)(void *addr);
86   void *(*vaddr_to_paddr)(void *addr);
87
88   int (*hook_interrupt)(struct guest_info * info, int irq);
89   int (*ack_irq)(int irq);
90
91   // Do we need this here?
92   void (*snprintf)(char * dst, char * format, int len, ...);
93
94   void (*start_kernel_thread)(); // include pointer to function
95 };
96
97
98
99 /* This will contain Function pointers that control the VMs */
100 struct vmm_ctrl_ops {
101   int (*init_guest)(struct guest_info* info);
102   int (*start_guest)(struct guest_info * info);
103   //  int (*stop_vm)(uint_t vm_id);
104
105
106
107 };
108
109
110
111
112 void Init_VMM(struct vmm_os_hooks * hooks, struct vmm_ctrl_ops * vmm_ops);
113
114
115
116
117
118 #endif