From b2e79752fd7864c58ff6f1d75eb699b4e0fdb77c Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 18 Apr 2017 11:59:03 +0200 Subject: [PATCH] Fix InactivePageTable::new function using a temporary page --- src/memory/paging/mod.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/memory/paging/mod.rs b/src/memory/paging/mod.rs index cd9d3496..2aa7e85e 100644 --- a/src/memory/paging/mod.rs +++ b/src/memory/paging/mod.rs @@ -2,6 +2,7 @@ pub use self::entry::*; use core::ptr::Unique; use memory::{PAGE_SIZE, Frame, FrameAllocator}; use self::table::{Table, Level4}; +use self::temporary_page::TemporaryPage; mod entry; mod table; @@ -163,8 +164,20 @@ pub struct InactivePageTable { } impl InactivePageTable { - pub fn new(frame: Frame) -> InactivePageTable { - // TODO zero and recursive map the frame + pub fn new(frame: Frame, + active_table: &mut ActivePageTable, + temporary_page: &mut TemporaryPage) + -> InactivePageTable { + { + let table = temporary_page.map_table_frame(frame.clone(), + active_table); + // now we are able to zero the table + table.zero(); + // set up recursive mapping for the table + table[511].set(frame.clone(), PRESENT | WRITABLE); + } + temporary_page.unmap(active_table); + InactivePageTable { p4_frame: frame } } }