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.


BIOS now runs, but dies because it has no devices....
[palacios.git] / palacios / include / palacios / vmm_mem.h
1 #ifndef __VMM_MEM_H
2 #define __VMM_MEM_H
3
4
5 #include <palacios/vmm_types.h>
6
7
8 typedef ulong_t addr_t;
9
10 struct guest_info;
11
12
13 /*
14
15         Guest                  Shadow                 Host
16   Virtual   Physical    Virtual     Physical   Virtual     Physical
17                OK                      OK
18                OK                      NOK
19                NOK                     OK
20                NOK                     NOK
21
22 */
23
24 // These are the types of physical memory address regions
25 // from the perspective of the guest
26 typedef enum guest_region_type { 
27   GUEST_REGION_NOTHING, 
28   GUEST_REGION_PHYSICAL_MEMORY, 
29   GUEST_REGION_MEMORY_MAPPED_DEVICE} guest_region_type_t;
30
31 // These are the types of physical memory address regions
32 // from the perspective of the HOST
33 typedef enum host_region_type { 
34   HOST_REGION_INVALID,                    // This region is INVALID (this is a return type, to denote errors)
35   HOST_REGION_NOTHING,                    // This region is mapped as not present (always generate page faults)
36   HOST_REGION_PHYSICAL_MEMORY,            // Region is a section of host memory
37   HOST_REGION_MEMORY_MAPPED_DEVICE,       // Region is allocated for DMA
38   HOST_REGION_UNALLOCATED,                // Region is mapped on demand
39   HOST_REGION_REMOTE,                     // Region is located on a remote machine
40   HOST_REGION_SWAPPED,                    // Region is swapped
41 } host_region_type_t;
42
43
44
45 typedef struct shadow_region {
46   guest_region_type_t     guest_type;
47   addr_t                  guest_start; 
48   addr_t                  guest_end; 
49
50   host_region_type_t      host_type;
51   union host_addr_t {
52     struct physical_addr { 
53        addr_t                  host_start; 
54     }                     phys_addr;
55     // Other addresses, like on disk, etc, would go here
56   }                       host_addr;
57   struct shadow_region *next, *prev;
58 } shadow_region_t;
59
60
61
62 struct shadow_map {
63   uint_t num_regions;
64
65   shadow_region_t * head;
66 };
67
68
69 void init_shadow_region(shadow_region_t * entry,
70                            addr_t               guest_addr_start,
71                            addr_t               guest_addr_end,
72                            guest_region_type_t  guest_region_type,
73                            host_region_type_t   host_region_type);
74
75 /*
76 void init_shadow_region_physical(shadow_region_t * entry,
77                                     addr_t               guest_addr_start,
78                                     addr_t               guest_addr_end,
79                                     guest_region_type_t  guest_region_type,
80                                     addr_t               host_addr_start,
81                                     host_region_type_t   host_region_type);
82 */
83
84 int add_shadow_region_passthrough(struct guest_info * guest_info, 
85                                   addr_t guest_addr_start,
86                                   addr_t guest_addr_end,
87                                   addr_t host_addr_start);
88
89 void init_shadow_map(struct shadow_map * map);
90 void free_shadow_map(struct shadow_map * map);
91
92 shadow_region_t * get_shadow_region_by_addr(struct shadow_map * map, addr_t guest_addr);
93
94 shadow_region_t * get_shadow_region_by_index(struct shadow_map * map, uint_t index);
95
96 host_region_type_t lookup_shadow_map_addr(struct shadow_map * map, addr_t guest_addr, addr_t * host_addr);
97
98
99 // Semantics:
100 // Adding a region that overlaps with an existing region results is undefined
101 // and will probably fail
102 int add_shadow_region(struct shadow_map * map, shadow_region_t * entry);
103
104 // Semantics:
105 // Deletions result in splitting
106 int delete_shadow_region(struct shadow_map * map,
107                              addr_t guest_start, 
108                              addr_t guest_end);
109
110
111 void print_shadow_map(struct shadow_map * map);
112
113
114
115
116 #endif