From 148d5066290b556f51b521d7dbfa974e75cb2616 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 13 Apr 2017 18:28:32 +0200 Subject: [PATCH] Use bitflags to create an EntryFlags type --- src/memory/paging/entry.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/memory/paging/entry.rs b/src/memory/paging/entry.rs index 6470195..0f44031 100644 --- a/src/memory/paging/entry.rs +++ b/src/memory/paging/entry.rs @@ -10,4 +10,23 @@ impl Entry { pub fn set_unused(&mut self) { self.0 = 0; } + + pub fn flags(&self) -> EntryFlags { + EntryFlags::from_bits_truncate(self.0) + } +} + +bitflags! { + pub flags EntryFlags: u64 { + const PRESENT = 1 << 0, + const WRITABLE = 1 << 1, + const USER_ACCESSIBLE = 1 << 2, + const WRITE_THROUGH = 1 << 3, + const NO_CACHE = 1 << 4, + const ACCESSED = 1 << 5, + const DIRTY = 1 << 6, + const HUGE_PAGE = 1 << 7, + const GLOBAL = 1 << 8, + const NO_EXECUTE = 1 << 63, + } }