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.


almost done with the namespace protection via -D__V3VEE__ header wrappers
[palacios.git] / palacios / include / palacios / vm_guest.h
1 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
2 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
3
4 #ifndef __VM_GUEST_H
5 #define __VM_GUEST_H
6
7 #ifdef __V3VEE__
8
9
10 #include <palacios/vmm_mem.h>
11 #include <palacios/vmm_types.h>
12 #include <palacios/vmm_io.h>
13 #include <palacios/vmm_shadow_paging.h>
14 #include <palacios/vmm_intr.h>
15 #include <palacios/vmm_dev_mgr.h>
16 #include <palacios/vmm_time.h>
17 #include <palacios/vmm_emulator.h>
18
19 typedef ullong_t v3_reg_t;
20
21
22
23 struct v3_gprs {
24   v3_reg_t rdi;
25   v3_reg_t rsi;
26   v3_reg_t rbp;
27   v3_reg_t rsp;
28   v3_reg_t rbx;
29   v3_reg_t rdx;
30   v3_reg_t rcx;
31   v3_reg_t rax;
32 };
33
34
35 struct v3_ctrl_regs {
36   v3_reg_t cr0;
37   v3_reg_t cr2;
38   v3_reg_t cr3;
39   v3_reg_t cr4;
40   v3_reg_t cr8;
41   v3_reg_t rflags;
42   v3_reg_t efer;
43 };
44
45
46
47 struct v3_dbg_regs {
48   v3_reg_t dr0;
49   v3_reg_t dr1;
50   v3_reg_t dr2;
51   v3_reg_t dr3;
52   v3_reg_t dr6;
53   v3_reg_t dr7;
54 };
55
56 struct v3_segment {
57   ushort_t selector;
58   uint_t limit;
59   ullong_t base;
60   uint_t type           : 4;
61   uint_t system         : 1;
62   uint_t dpl            : 2;
63   uint_t present        : 1;
64   uint_t avail          : 1;
65   uint_t long_mode      : 1;
66   uint_t db             : 1;
67   uint_t granularity    : 1;
68 };
69
70
71 struct v3_segments {
72   struct v3_segment cs;
73   struct v3_segment ds;
74   struct v3_segment es;
75   struct v3_segment fs;
76   struct v3_segment gs;
77   struct v3_segment ss;
78   struct v3_segment ldtr;
79   struct v3_segment gdtr;
80   struct v3_segment idtr;
81   struct v3_segment tr;
82 };
83
84 struct shadow_page_state;
85 struct shadow_map;
86 struct vmm_io_map;
87 struct emulation_state;
88
89 /*Zheng 07/30/2008*/
90 struct vm_ctrl_ops {
91   int (*raise_irq)(struct guest_info * info, int irq);
92   int (*lower_irq)(struct guest_info * info, int irq);
93 };
94
95
96
97
98 typedef enum {SHADOW_PAGING, NESTED_PAGING} vmm_paging_mode_t;
99 typedef enum {VM_RUNNING, VM_STOPPED, VM_SUSPENDED, VM_ERROR, VM_EMULATING} vm_operating_mode_t;
100
101
102 typedef enum {REAL, /*UNREAL,*/ PROTECTED, PROTECTED_PAE, LONG, LONG_32_COMPAT, LONG_16_COMPAT} vm_cpu_mode_t;
103 typedef enum {PHYSICAL_MEM, VIRTUAL_MEM} vm_mem_mode_t;
104
105
106
107 struct guest_info {
108   ullong_t rip;
109
110   uint_t cpl;
111
112   struct shadow_map mem_map;
113
114   struct vm_time time_state;
115   
116   vmm_paging_mode_t shdw_pg_mode;
117   struct shadow_page_state shdw_pg_state;
118   addr_t direct_map_pt;
119   // nested_paging_t nested_page_state;
120
121
122   // This structure is how we get interrupts for the guest
123   struct vm_intr intr_state;
124
125   struct vmm_io_map io_map;
126   // device_map
127
128   struct vmm_dev_mgr  dev_mgr;
129
130   vm_cpu_mode_t cpu_mode;
131   vm_mem_mode_t mem_mode;
132
133
134   struct v3_gprs vm_regs;
135   struct v3_ctrl_regs ctrl_regs;
136   struct v3_dbg_regs dbg_regs;
137   struct v3_segments segments;
138
139   struct vm_ctrl_ops vm_ops;
140
141   struct emulation_state emulator;
142
143   vm_operating_mode_t run_state;
144   void * vmm_data;
145
146   /* TEMP */
147   //ullong_t exit_tsc;
148
149 };
150
151
152 vm_cpu_mode_t get_cpu_mode(struct guest_info * info);
153 vm_mem_mode_t get_mem_mode(struct guest_info * info);
154
155
156 void PrintV3Segments(struct guest_info * info);
157 void PrintV3CtrlRegs(struct guest_info * info);
158 void PrintV3GPRs(struct guest_info * info);
159
160 #endif // ! __V3VEE__
161
162
163
164 #endif