diff --git a/src/hulk/pagetable.d b/src/hulk/pagetable.d index 12fd31f..5fa26db 100644 --- a/src/hulk/pagetable.d +++ b/src/hulk/pagetable.d @@ -22,7 +22,7 @@ enum ulong PT_NO_EXECUTE = 0x8000_0000_0000_0000u; struct PageTableEntry { /** The raw page table entry is a 64-bit ulong. */ - private ulong entry; + public ulong entry; alias entry this; /** @@ -102,6 +102,22 @@ struct PageTableEntry return (entry & PT_NO_EXECUTE) != 0u; } + /** + * Return whether the page is dirty. + */ + public @property bool dirty() const + { + return (entry & PT_DIRTY) != 0u; + } + + /** + * Return whether the page is accessed. + */ + public @property bool accessed() const + { + return (entry & PT_ACCESSED) != 0u; + } + /** * Follow the page table entry to the next page table it points to. */ @@ -146,5 +162,18 @@ struct PageTable { return (cast(ulong)address >> (39u - (9u * level))) & 0x1FFu; } + + /** + * Access a page table entry by linear index. + * + * @param index + * Page table index (0-511). + * + * @return PageTableEntry at the given index. + */ + public PageTableEntry opIndex(size_t index) + { + return entries[index]; + } } static assert(PageTable.sizeof == 4096u);