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 / arch / x86_64 / mm / phys_addr.c
diff --git a/kitten/arch/x86_64/mm/phys_addr.c b/kitten/arch/x86_64/mm/phys_addr.c
new file mode 100644 (file)
index 0000000..90e6097
--- /dev/null
@@ -0,0 +1,21 @@
+#include <arch/page.h>
+
+extern unsigned long phys_base;
+
+/**
+ * This converts a kernel virtual address to a physical address.
+ *
+ * NOTE: This function only works for kernel virtual addresses in the kernel's
+ *       identity mapping of all of physical memory. It will not work for the
+ *       fixmap, vmalloc() areas, or any other type of virtual address.
+ */
+unsigned long
+__phys_addr(unsigned long virt_addr)
+{
+       /* Handle kernel symbols */
+       if (virt_addr >= __START_KERNEL_map)
+               return virt_addr - __START_KERNEL_map + phys_base;
+       /* Handle kernel data */
+       return virt_addr - PAGE_OFFSET;
+}
+