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.


*** empty log message ***
[palacios.git] / palacios / src / palacios / vmm_mem.c
index cf18c10..dfbe0e8 100644 (file)
@@ -2,7 +2,7 @@
 #include <palacios/vmm.h>
 #include <palacios/vmm_util.h>
 
-extern struct vmm_os_hooks * os_hooks;
+
 
 
 void init_shadow_region(shadow_region_t * entry,
@@ -23,7 +23,7 @@ int add_shadow_region_passthrough( struct guest_info *  guest_info,
                                   addr_t               guest_addr_end,
                                   addr_t               host_addr_start)
 {
-  shadow_region_t * entry = os_hooks->malloc(sizeof(shadow_region_t));
+  shadow_region_t * entry = (shadow_region_t *)V3_Malloc(sizeof(shadow_region_t));
 
   init_shadow_region(entry, guest_addr_start, guest_addr_end, 
                     GUEST_REGION_PHYSICAL_MEMORY, HOST_REGION_PHYSICAL_MEMORY);
@@ -49,10 +49,10 @@ void free_shadow_map(struct shadow_map * map) {
   while(cursor) {
     tmp = cursor;
     cursor = cursor->next;
-    VMMFree(tmp);
+    V3_Free(tmp);
   }
 
-  VMMFree(map);
+  V3_Free(map);
 }
 
 
@@ -155,6 +155,26 @@ shadow_region_t * get_shadow_region_by_addr(struct shadow_map * map,
 }
 
 
+host_region_type_t get_shadow_addr_type(struct guest_info * info, addr_t guest_addr) {
+  shadow_region_t * reg = get_shadow_region_by_addr(&(info->mem_map), guest_addr);
+
+  if (!reg) {
+    return HOST_REGION_INVALID;
+  } else {
+    return reg->host_type;
+  }
+}
+
+addr_t get_shadow_addr(struct guest_info * info, addr_t guest_addr) {
+  shadow_region_t * reg = get_shadow_region_by_addr(&(info->mem_map), guest_addr);
+
+  if (!reg) {
+    return 0;
+  } else {
+    return (guest_addr - reg->guest_start) + reg->host_addr.phys_addr.host_start;
+  }
+}
+
 
 host_region_type_t lookup_shadow_map_addr(struct shadow_map * map, addr_t guest_addr, addr_t * host_addr) {
   shadow_region_t * reg = get_shadow_region_by_addr(map, guest_addr);