Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / arch / x86 / includes / sys / mm / memory.h
diff --git a/lunaix-os/arch/x86/includes/sys/mm/memory.h b/lunaix-os/arch/x86/includes/sys/mm/memory.h
new file mode 100644 (file)
index 0000000..cf9f91d
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __LUNAIX_ARCH_MEMORY_H
+#define __LUNAIX_ARCH_MEMORY_H
+
+#include <lunaix/mm/pagetable.h>
+#include <lunaix/mann_flags.h>
+
+static inline pte_attr_t
+translate_vmr_prot(unsigned int vmr_prot)
+{
+    pte_attr_t _pte_prot = _PTE_U;
+    if ((vmr_prot & PROT_READ)) {
+        _pte_prot |= _PTE_R;
+    }
+
+    if ((vmr_prot & PROT_WRITE)) {
+        _pte_prot |= _PTE_W;
+    }
+
+    if (!(vmr_prot & PROT_EXEC)) {
+        _pte_prot |= _PTE_NX;
+    }
+
+    return _pte_prot;
+}
+
+
+#endif /* __LUNAIX_ARCH_MEMORY_H */