mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Add RecursivePageTable as an owner for the P4 table
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
pub use self::entry::*;
|
pub use self::entry::*;
|
||||||
use memory::{PAGE_SIZE, Frame, FrameAllocator};
|
use memory::{PAGE_SIZE, Frame, FrameAllocator};
|
||||||
|
use self::table::{Table, Level4};
|
||||||
|
use core::ptr::Unique;
|
||||||
|
|
||||||
mod entry;
|
mod entry;
|
||||||
mod table;
|
mod table;
|
||||||
@@ -39,6 +41,24 @@ impl Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct RecursivePageTable {
|
||||||
|
p4: Unique<Table<Level4>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RecursivePageTable {
|
||||||
|
pub unsafe fn new() -> RecursivePageTable {
|
||||||
|
RecursivePageTable { p4: Unique::new(table::P4) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn p4(&self) -> &Table<Level4> {
|
||||||
|
unsafe { self.p4.get() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn p4_mut(&mut self) -> &mut Table<Level4> {
|
||||||
|
unsafe { self.p4.get_mut() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub unsafe fn translate(virtual_address: VirtualAddress) -> Option<PhysicalAddress> {
|
pub unsafe fn translate(virtual_address: VirtualAddress) -> Option<PhysicalAddress> {
|
||||||
let offset = virtual_address % PAGE_SIZE;
|
let offset = virtual_address % PAGE_SIZE;
|
||||||
translate_page(Page::containing_address(virtual_address))
|
translate_page(Page::containing_address(virtual_address))
|
||||||
|
|||||||
Reference in New Issue
Block a user