5 #include <geekos/ktypes.h>
7 typedef ulong_t addr_t;
12 Virtual Physical Virtual Physical Virtual Physical
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_PHYSICAL_MEMORY,
25 GUEST_REGION_MEMORY_MAPPED_DEVICE} guest_region_type_t;
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_PHYSICAL_MEMORY,
31 HOST_REGION_UNALLOCATED,
33 HOST_REGION_MEMORY_MAPPED_DEVICE,
40 typedef struct shadow_map_entry {
41 guest_region_type_t guest_type;
45 host_region_type_t host_type;
47 struct physical_addr {
51 // Other addresses, like on disk, etc, would go here
53 struct shadow_map_entry *next, *prev;
58 typedef struct shadow_map {
61 shadow_map_entry_t * head;
65 void init_shadow_map_entry(shadow_map_entry_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);
71 void init_shadow_map_entry_physical(shadow_map_entry_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,
77 host_region_type_t host_region_type);
79 void init_shadow_map(shadow_map_t *map);
80 void free_shadow_map(shadow_map_t *map);
82 shadow_map_entry_t * get_shadow_map_region_by_addr(shadow_map_t *map, addr_t guest_addr);
84 shadow_map_entry_t * get_shadow_map_region_by_index(shadow_map_t * map, uint_t index);
86 int map_guest_physical_to_host_physical(shadow_map_entry_t *entry,
92 // Adding a region that overlaps with an existing region results is undefined
93 // and will probably fail
94 int add_shadow_map_region(shadow_map_t * map, shadow_map_entry_t *entry);
97 // Deletions result in splitting
98 int delete_shadow_map_region(shadow_map_t *map,
103 void print_shadow_map(shadow_map_t * map);