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.


Merge branch 'devel'
[palacios.git] / kitten / user / liblwk / aspace.c
diff --git a/kitten/user/liblwk/aspace.c b/kitten/user/liblwk/aspace.c
new file mode 100644 (file)
index 0000000..176dd75
--- /dev/null
@@ -0,0 +1,58 @@
+/* Copyright (c) 2008, Sandia National Laboratories */
+
+#include <lwk/liblwk.h>
+
+int
+aspace_map_region(
+       id_t         id,
+       vaddr_t      start,
+       size_t       extent,
+       vmflags_t    flags,
+       vmpagesize_t pagesz,
+       const char * name,
+       paddr_t      pmem
+)
+{
+       int status;
+
+       if ((status = aspace_add_region(id, start, extent, flags, pagesz, name)))
+               return status;
+
+       if ((status = aspace_map_pmem(id, pmem, start, extent))) {
+               aspace_del_region(id, start, extent);
+               return status;
+       }
+
+       return 0;
+}
+
+int
+aspace_map_region_anywhere(
+       id_t         id,
+       vaddr_t *    start,
+       size_t       extent,
+       vmflags_t    flags,
+       vmpagesize_t pagesz,
+       const char * name,
+       paddr_t      pmem
+)
+{
+       int status;
+
+retry:
+       if ((status = aspace_find_hole(id, 0, extent, pagesz, start)))
+               return status;
+
+       if ((status = aspace_add_region(id, *start, extent, flags, pagesz, name))) {
+               if (status == -ENOTUNIQ)
+                       goto retry; /* we lost a race with someone */
+               return status;
+       }
+
+       if ((status = aspace_map_pmem(id, pmem, *start, extent))) {
+               aspace_del_region(id, *start, extent);
+               return status;
+       }
+
+       return 0;
+}