mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
feat: table: add TABLE_SIZE
This commit is contained in:
parent
e46ca5a288
commit
f0891ff87d
@ -11,6 +11,7 @@ pub struct Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert_eq_size!(Table, [u8; PAGE_SIZE]);
|
assert_eq_size!(Table, [u8; PAGE_SIZE]);
|
||||||
|
const_assert_eq!(core::mem::size_of::<Table>(), Table::TABLE_SIZE);
|
||||||
|
|
||||||
impl Table {
|
impl Table {
|
||||||
fn lookup_mut_internal(&mut self, vaddr: VirtAddr) -> (&mut Entry, TableLevel) {
|
fn lookup_mut_internal(&mut self, vaddr: VirtAddr) -> (&mut Entry, TableLevel) {
|
||||||
@ -46,6 +47,7 @@ impl TableOps for Table {
|
|||||||
|
|
||||||
#[cfg(feature = "riscv.pagetable.sv39")]
|
#[cfg(feature = "riscv.pagetable.sv39")]
|
||||||
const MAX_PAGE_SIZE: TableLevel = TableLevel::Level2;
|
const MAX_PAGE_SIZE: TableLevel = TableLevel::Level2;
|
||||||
|
const TABLE_SIZE: usize = PAGE_SIZE;
|
||||||
|
|
||||||
unsafe fn new(location: VirtAddr) -> &'static mut Self {
|
unsafe fn new(location: VirtAddr) -> &'static mut Self {
|
||||||
assert!(location.is_aligned(PAGE_SIZE));
|
assert!(location.is_aligned(PAGE_SIZE));
|
||||||
|
@ -44,6 +44,7 @@ pub type PageResult<T = ()> = Result<T, PageError>;
|
|||||||
pub trait TableOps: Debug {
|
pub trait TableOps: Debug {
|
||||||
type Entry: EntryOps;
|
type Entry: EntryOps;
|
||||||
const MAX_PAGE_SIZE: TableLevel;
|
const MAX_PAGE_SIZE: TableLevel;
|
||||||
|
const TABLE_SIZE: usize;
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// `location` must be a page-aligned virtual address and will not be dropped.
|
/// `location` must be a page-aligned virtual address and will not be dropped.
|
||||||
|
Loading…
Reference in New Issue
Block a user