X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/32b9a6d76790c73d3d2d36d9081a2581cc65d184..28c176b668c841a3b7fb093faccf0efa39257603:/lunaix-os/arch/x86/includes/sys/mm/memory.h?ds=sidebyside 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 index 0000000..cf9f91d --- /dev/null +++ b/lunaix-os/arch/x86/includes/sys/mm/memory.h @@ -0,0 +1,27 @@ +#ifndef __LUNAIX_ARCH_MEMORY_H +#define __LUNAIX_ARCH_MEMORY_H + +#include +#include + +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 */