mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
feat: vspace: table: allow to get table vaddr
This commit is contained in:
parent
03aa0edcc8
commit
42a7ea89c5
@ -11,6 +11,10 @@ impl<'a, T: TableLevel> TableOps<'a, T> for Table<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vaddr(&self) -> VirtAddr {
|
||||||
|
VirtAddr::from(self.entries.as_ptr())
|
||||||
|
}
|
||||||
|
|
||||||
fn map(&mut self, from: VirtAddr, to: PhysAddr, attr: MapAttr) -> PageResult {
|
fn map(&mut self, from: VirtAddr, to: PhysAddr, attr: MapAttr) -> PageResult {
|
||||||
if !from.is_aligned(T::LEVEL_SIZE) || !to.is_aligned(PAGE_SIZE) {
|
if !from.is_aligned(T::LEVEL_SIZE) || !to.is_aligned(PAGE_SIZE) {
|
||||||
return Err(PageError::NotAligned);
|
return Err(PageError::NotAligned);
|
||||||
|
@ -5,6 +5,7 @@ pub trait TableOps<'a, T: TableLevel> {
|
|||||||
/// # 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.
|
||||||
unsafe fn new(location: VirtAddr) -> Self;
|
unsafe fn new(location: VirtAddr) -> Self;
|
||||||
|
fn vaddr(&self) -> VirtAddr;
|
||||||
|
|
||||||
// following methods only works at current level
|
// following methods only works at current level
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user