diff --git a/page_table_multiarch/src/bits64.rs b/page_table_multiarch/src/bits64.rs index 1ec49fd..f515073 100644 --- a/page_table_multiarch/src/bits64.rs +++ b/page_table_multiarch/src/bits64.rs @@ -42,6 +42,13 @@ impl PageTable64 Self { + Self { + root_paddr, + _phantom: PhantomData, + } + } + /// Returns the physical address of the root page table. pub const fn root_paddr(&self) -> PhysAddr { self.root_paddr @@ -524,6 +531,8 @@ impl PageTable64 Drop for PageTable64 { fn drop(&mut self) { + warn!("Dropping page table @ {:#x}", self.root_paddr()); + // don't free the entries in last level, they are not array. let _ = self.walk( usize::MAX, diff --git a/page_table_multiarch/src/lib.rs b/page_table_multiarch/src/lib.rs index a9911e7..5ea3cce 100644 --- a/page_table_multiarch/src/lib.rs +++ b/page_table_multiarch/src/lib.rs @@ -83,8 +83,22 @@ pub trait PagingMetaData: Sync + Send { pub trait PagingHandler: Sized { /// Request to allocate a 4K-sized physical frame. fn alloc_frame() -> Option; + + /// Request to allocate a number of contiguous 4K-sized physical frames. + /// `align_pow2` must be a power of 2, and the returned region bound will be + /// aligned to it. + fn alloc_frames(count: usize, align_pow2: usize) -> Option; + /// Request to free a allocated physical frame. fn dealloc_frame(paddr: PhysAddr); + + /// Request to free a number of contiguous physical frames. + fn dealloc_frames(paddr: PhysAddr, count: usize) { + for i in 0..count { + Self::dealloc_frame(paddr.add(i * PageSize::Size4K as usize)); + } + } + /// Returns a virtual address that maps to the given physical address. /// /// Used to access the physical memory directly in page table implementation.