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.


Additional features for vmm_bitmap
Mark Cartwright [Thu, 19 Jul 2012 21:24:19 +0000 (16:24 -0500)]
palacios/include/palacios/vmm_bitmap.h
palacios/src/palacios/vmm_bitmap.c

index 4842585..29cabb7 100644 (file)
@@ -41,7 +41,8 @@ int v3_bitmap_set(struct v3_bitmap * bitmap, int index);
 int v3_bitmap_clear(struct v3_bitmap * bitmap, int index);
 int v3_bitmap_check(struct v3_bitmap * bitmap, int index);
 
-
+int v3_bitmap_count(struct v3_bitmap * bitmap);
+int v3_bitmap_copy(struct v3_bitmap * dst, struct v3_bitmap * src);
 
 #endif
 
index 0f26473..14b042d 100644 (file)
@@ -99,3 +99,36 @@ int v3_bitmap_check(struct v3_bitmap * bitmap, int index) {
     return ((bitmap->bits[major] & (0x1 << minor)) != 0);
 }
 
+
+int v3_bitmap_count(struct v3_bitmap * bitmap) {
+
+    int cnt = 0;
+    int i;
+    uint8_t x;
+    uint8_t * bytes = bitmap->bits;
+    int num_bytes = (bitmap->num_bits / 8) + ((bitmap->num_bits % 8) > 0);
+
+    for (i=0; i < num_bytes; i++) {
+        x = bytes[i];
+        while (x) { 
+           cnt += (x & 0x1);
+           x>>=1;
+       }
+    }     
+    
+    return cnt;
+}
+
+int v3_bitmap_copy(struct v3_bitmap * dst, struct v3_bitmap * src) {
+    
+    if (src->num_bits != dst->num_bits) {
+        PrintError("src and dst must be the same size.\n");
+       return -1;    
+    }
+    
+    int num_bytes = (src->num_bits / 8) + ((src->num_bits % 8)!=0);
+    
+    memcpy(dst->bits,src->bits,num_bytes);
+    
+    return 0;
+}