X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fgeekos%2Fvmm_mem.h;h=2eb815746cb379f5da7940aa7ac13d67e036dd3c;hb=7acd54f8c3b30d118d56186a9c6506f21f85096d;hp=00ea157ed47de8ca033fc6ea2bc3bf2591bf1c4e;hpb=271ad3fd89672d441db3c5ffa673ee649e4ce532;p=palacios.git diff --git a/palacios/include/geekos/vmm_mem.h b/palacios/include/geekos/vmm_mem.h index 00ea157..2eb8157 100644 --- a/palacios/include/geekos/vmm_mem.h +++ b/palacios/include/geekos/vmm_mem.h @@ -20,24 +20,25 @@ typedef ulong_t addr_t; // These are the types of physical memory address regions // from the perspective of the guest typedef enum guest_region_type { - GUEST_REGION_PHYSICAL_MEMORY, GUEST_REGION_NOTHING, + GUEST_REGION_PHYSICAL_MEMORY, GUEST_REGION_MEMORY_MAPPED_DEVICE} guest_region_type_t; // These are the types of physical memory address regions // from the perspective of the HOST typedef enum host_region_type { - HOST_REGION_PHYSICAL_MEMORY, - HOST_REGION_UNALLOCATED, - HOST_REGION_NOTHING, - HOST_REGION_MEMORY_MAPPED_DEVICE, - HOST_REGION_REMOTE, - HOST_REGION_SWAPPED, + HOST_REGION_INVALID, // This region is INVALID (this is a return type, to denote errors) + HOST_REGION_NOTHING, // This region is mapped as not present (always generate page faults) + HOST_REGION_PHYSICAL_MEMORY, // Region is a section of host memory + HOST_REGION_MEMORY_MAPPED_DEVICE, // Region is allocated for DMA + HOST_REGION_UNALLOCATED, // Region is mapped on demand + HOST_REGION_REMOTE, // Region is located on a remote machine + HOST_REGION_SWAPPED, // Region is swapped } host_region_type_t; -typedef struct shadow_map_entry { +typedef struct shadow_region { guest_region_type_t guest_type; addr_t guest_start; addr_t guest_end; @@ -46,56 +47,58 @@ typedef struct shadow_map_entry { union host_addr_t { struct physical_addr { addr_t host_start; - addr_t host_end; } phys_addr; // Other addresses, like on disk, etc, would go here } host_addr; - struct shadow_map_entry *next, *prev; -} shadow_map_entry_t; + struct shadow_region *next, *prev; +} shadow_region_t; typedef struct shadow_map { uint_t num_regions; - shadow_map_entry_t * head; + shadow_region_t * head; } shadow_map_t; -void init_shadow_map_entry(shadow_map_entry_t *entry, - addr_t guest_addr_start, - addr_t guest_addr_end, - guest_region_type_t guest_region_type, - host_region_type_t host_region_type); +void init_shadow_region(shadow_region_t * entry, + addr_t guest_addr_start, + addr_t guest_addr_end, + guest_region_type_t guest_region_type, + host_region_type_t host_region_type); -void init_shadow_map_entry_physical(shadow_map_entry_t *entry, - addr_t guest_addr_start, - addr_t guest_addr_end, - guest_region_type_t guest_region_type, - addr_t host_addr_start, - addr_t host_addr_end, - host_region_type_t host_region_type); +void init_shadow_region_physical(shadow_region_t * entry, + addr_t guest_addr_start, + addr_t guest_addr_end, + guest_region_type_t guest_region_type, + addr_t host_addr_start, + host_region_type_t host_region_type); -void init_shadow_map(shadow_map_t *map); -void free_shadow_map(shadow_map_t *map); +void init_shadow_map(shadow_map_t * map); +void free_shadow_map(shadow_map_t * map); + +shadow_region_t * get_shadow_region_by_addr(shadow_map_t * map, addr_t guest_addr); -shadow_map_entry_t * get_shadow_map_region_by_addr(shadow_map_t *map, addr_t guest_addr); +shadow_region_t * get_shadow_region_by_index(shadow_map_t * map, uint_t index); -shadow_map_entry_t * get_shadow_map_region_by_index(shadow_map_t * map, uint_t index); +/* +int guest_paddr_to_host_paddr(shadow_region_t * entry, + addr_t guest_addr, + addr_t * host_addr); +*/ -int map_guest_physical_to_host_physical(shadow_map_entry_t *entry, - addr_t guest_addr, - addr_t *host_addr); +host_region_type_t lookup_shadow_map_addr(shadow_map_t * map, addr_t guest_addr, addr_t * host_addr); // Semantics: // Adding a region that overlaps with an existing region results is undefined // and will probably fail -int add_shadow_map_region(shadow_map_t * map, shadow_map_entry_t *entry); +int add_shadow_region(shadow_map_t * map, shadow_region_t * entry); // Semantics: // Deletions result in splitting -int delete_shadow_map_region(shadow_map_t *map, +int delete_shadow_region(shadow_map_t * map, addr_t guest_start, addr_t guest_end); @@ -105,5 +108,4 @@ void print_shadow_map(shadow_map_t * map); - #endif