Move Frame::start_address to memory/mod.rs and use it in identity_map()

This commit is contained in:
Philipp Oppermann
2015-12-07 10:56:26 +01:00
parent 6ed376112d
commit b314d4827f
4 changed files with 12 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
pub use self::area_frame_allocator::AreaFrameAllocator;
use self::paging::PhysicalAddress;
pub mod paging;
mod area_frame_allocator;
@@ -14,6 +15,10 @@ impl Frame {
fn containing_address(address: usize) -> Frame {
Frame { number: address / PAGE_SIZE }
}
fn start_address(&self) -> PhysicalAddress {
self.number * PAGE_SIZE
}
}
pub trait FrameAllocator {

View File

@@ -44,9 +44,3 @@ bitflags! {
const NO_EXECUTE = 1 << 63,
}
}
impl Frame {
fn start_address(&self) -> PhysicalAddress {
self.number << 12
}
}

View File

@@ -150,7 +150,7 @@ impl RecursivePageTable {
pub fn identity_map<A>(&mut self, frame: Frame, flags: EntryFlags, allocator: &mut A)
where A: FrameAllocator
{
let page = Page { number: frame.number };
let page = Page::containing_address(frame.start_address());
self.map_to(&page, frame, flags, allocator)
}