Add page_address()

This commit is contained in:
Josh Holtrop 2023-09-07 12:51:41 -04:00
parent 2a832bfb8b
commit 22c9891c4f

View File

@ -183,3 +183,11 @@ struct PageTable
}
}
static assert(PageTable.sizeof == 4096u);
/**
* Get the base address of the page containing the given address.
*/
T page_address(T)(T address)
{
return cast(T)(cast(ulong)address & ~(PAGE_SIZE - 1u));
}