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