From f897b6b09ea7d0f33d0806a13affd6d7c5c7d380 Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 4 Jun 2017 17:49:50 -0500 Subject: [PATCH] memory::paging: add an InactivePageTable struct --- src/arch/x86_64/memory/paging/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/arch/x86_64/memory/paging/mod.rs b/src/arch/x86_64/memory/paging/mod.rs index e44847b..d293fb4 100644 --- a/src/arch/x86_64/memory/paging/mod.rs +++ b/src/arch/x86_64/memory/paging/mod.rs @@ -90,11 +90,26 @@ impl ActivePageTable { } } +/// Owns an inactive P4 table. +pub struct InactivePageTable { + p4_frame: Frame, +} +impl InactivePageTable { + 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); + // zero the new inactive page table + table.zero(); + // set up a recursive mapping for this table + table[511].set(frame.clone(), PRESENT | WRITABLE); } + temporary_page.unmap(active_table); + InactivePageTable { p4_frame: frame } } }