PageTableEntry improvements
- fix alias this - add properties for dirty/accessed - add opIndex for direct indexing
This commit is contained in:
parent
1e1c389caf
commit
49677c8499
@ -22,7 +22,7 @@ enum ulong PT_NO_EXECUTE = 0x8000_0000_0000_0000u;
|
|||||||
struct PageTableEntry
|
struct PageTableEntry
|
||||||
{
|
{
|
||||||
/** The raw page table entry is a 64-bit ulong. */
|
/** The raw page table entry is a 64-bit ulong. */
|
||||||
private ulong entry;
|
public ulong entry;
|
||||||
alias entry this;
|
alias entry this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,6 +102,22 @@ struct PageTableEntry
|
|||||||
return (entry & PT_NO_EXECUTE) != 0u;
|
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.
|
* 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;
|
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);
|
static assert(PageTable.sizeof == 4096u);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user