feat: table: add TABLE_SIZE

This commit is contained in:
Paul Pan 2024-05-06 01:01:58 +08:00
parent e46ca5a288
commit f0891ff87d
2 changed files with 3 additions and 0 deletions

View File

@ -11,6 +11,7 @@ pub struct Table {
}
assert_eq_size!(Table, [u8; PAGE_SIZE]);
const_assert_eq!(core::mem::size_of::<Table>(), Table::TABLE_SIZE);
impl Table {
fn lookup_mut_internal(&mut self, vaddr: VirtAddr) -> (&mut Entry, TableLevel) {
@ -46,6 +47,7 @@ impl TableOps for Table {
#[cfg(feature = "riscv.pagetable.sv39")]
const MAX_PAGE_SIZE: TableLevel = TableLevel::Level2;
const TABLE_SIZE: usize = PAGE_SIZE;
unsafe fn new(location: VirtAddr) -> &'static mut Self {
assert!(location.is_aligned(PAGE_SIZE));

View File

@ -44,6 +44,7 @@ pub type PageResult<T = ()> = Result<T, PageError>;
pub trait TableOps: Debug {
type Entry: EntryOps;
const MAX_PAGE_SIZE: TableLevel;
const TABLE_SIZE: usize;
/// # Safety
/// `location` must be a page-aligned virtual address and will not be dropped.