diff --git a/src/arch/x86_64/rmm.rs b/src/arch/x86_64/rmm.rs index 380505e8e5d98d9a7f5f9fb90d92558e4b03b2f1..7827a7e8520feb7a43030cd9ff169819adaac21a 100644 --- a/src/arch/x86_64/rmm.rs +++ b/src/arch/x86_64/rmm.rs @@ -17,6 +17,7 @@ use rmm::{ PageFlags, PageMapper, PhysicalAddress, + TableKind, VirtualAddress, }; use spin::Mutex; @@ -100,6 +101,7 @@ unsafe fn inner<A: Arch>( { let mut mapper = PageMapper::<A, _>::create( + TableKind::Kernel, &mut bump_allocator ).expect("failed to create Mapper"); @@ -298,7 +300,7 @@ impl KernelMapper { } } pub fn lock_manually(current_processor: usize) -> Self { - unsafe { Self::lock_for_manual_mapper(current_processor, PageMapper::new(RmmA::table(), FRAME_ALLOCATOR)) } + unsafe { Self::lock_for_manual_mapper(current_processor, PageMapper::current(TableKind::Kernel, FRAME_ALLOCATOR)) } } pub fn lock() -> Self { Self::lock_manually(crate::cpu_id()) diff --git a/src/arch/x86_64/start.rs b/src/arch/x86_64/start.rs index 08a6c919c2e78f97f3ffb2cd39c30d375f403383..24235cfca142668e52fd5443c715f3529f3b86fe 100644 --- a/src/arch/x86_64/start.rs +++ b/src/arch/x86_64/start.rs @@ -18,7 +18,7 @@ use crate::gdt; use crate::idt; use crate::interrupt; use crate::log::{self, info}; -use crate::paging::{self, KernelMapper}; +use crate::paging::{self, KernelMapper, TableKind}; /// Test of zero values in BSS. static BSS_TEST_ZERO: usize = 0; @@ -234,7 +234,7 @@ pub unsafe extern fn kstart_ap(args_ptr: *const KernelArgsAp) -> ! { use crate::paging::{PageMapper, PhysicalAddress}; use crate::rmm::FRAME_ALLOCATOR; - let mut mapper = KernelMapper::lock_for_manual_mapper(cpu_id, PageMapper::new(PhysicalAddress::new(bsp_table), FRAME_ALLOCATOR)); + let mut mapper = KernelMapper::lock_for_manual_mapper(cpu_id, PageMapper::new(TableKind::Kernel, PhysicalAddress::new(bsp_table), FRAME_ALLOCATOR)); paging::init_ap(cpu_id, &mut mapper) }; diff --git a/src/context/arch/x86_64.rs b/src/context/arch/x86_64.rs index 97d14a94e26da910af22ed3614d231529ee06840..9b3f366c778bf989e0a57122fccd02c552878301 100644 --- a/src/context/arch/x86_64.rs +++ b/src/context/arch/x86_64.rs @@ -3,7 +3,7 @@ use core::sync::atomic::AtomicBool; use alloc::sync::Arc; -use crate::paging::{RmmA, RmmArch}; +use crate::paging::{RmmA, RmmArch, TableKind}; use crate::syscall::FloatRegisters; use memoffset::offset_of; @@ -175,7 +175,7 @@ pub unsafe fn switch_to(prev: &mut super::Context, next: &mut super::Context) { next_space.read().table.utable.make_current(); } None => { - RmmA::set_table(empty_cr3()); + RmmA::set_table(TableKind::User, empty_cr3()); } } switch_to_inner(&mut prev.arch, &mut next.arch) diff --git a/src/debugger.rs b/src/debugger.rs index 8309ee6e48ed3b0fb63d9c8582c9a93fc5eaaf24..c141ffa7e29db955ef6546935f51f452d8339517 100644 --- a/src/debugger.rs +++ b/src/debugger.rs @@ -1,4 +1,4 @@ -use crate::paging::{RmmA, RmmArch}; +use crate::paging::{RmmA, RmmArch, TableKind}; #[cfg(not(target_arch = "x86_64"))] pub unsafe fn debugger(target_id: Option<crate::context::ContextId>) { @@ -12,7 +12,7 @@ pub unsafe fn debugger(target_id: Option<crate::context::ContextId>) { println!("DEBUGGER START"); println!(); - let old_table = RmmA::table(); + let old_table = RmmA::table(TableKind::User); for (id, context_lock) in crate::context::contexts().iter() { if target_id.map_or(false, |target_id| *id != target_id) { continue; } @@ -21,7 +21,7 @@ pub unsafe fn debugger(target_id: Option<crate::context::ContextId>) { // Switch to context page table to ensure syscall debug and stack dump will work if let Some(ref space) = context.addr_space { - RmmA::set_table(space.read().table.utable.table().phys()); + RmmA::set_table(TableKind::User, space.read().table.utable.table().phys()); check_consistency(&mut space.write()); } @@ -71,7 +71,7 @@ pub unsafe fn debugger(target_id: Option<crate::context::ContextId>) { } // Switch to original page table - RmmA::set_table(old_table); + RmmA::set_table(TableKind::User, old_table); println!(); } diff --git a/src/syscall/mod.rs b/src/syscall/mod.rs index 57dde0e7f5977048d81edbcccf98bd07c1d89072..e36bfd4f7f93ed2eb6a0dd1bbf379b26a553556a 100644 --- a/src/syscall/mod.rs +++ b/src/syscall/mod.rs @@ -170,12 +170,12 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, stack } } - /*let debug = { + let debug = { let contexts = crate::context::contexts(); if let Some(context_lock) = contexts.current() { let context = context_lock.read(); let name = context.name.read(); - if name.contains("redoxfs") { + if name.contains("bootstrap") { if a == SYS_CLOCK_GETTIME || a == SYS_YIELD { false } else if (a == SYS_WRITE || a == SYS_FSYNC) && (b == 1 || b == 2) { @@ -199,7 +199,7 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, stack } println!("{}", debug::format_call(a, b, c, d, e, f)); - }*/ + } // The next lines set the current syscall in the context struct, then once the inner() function // completes, we set the current syscall to none. @@ -224,7 +224,7 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, stack } } - /*if debug { + if debug { let contexts = crate::context::contexts(); if let Some(context_lock) = contexts.current() { let context = context_lock.read(); @@ -241,7 +241,7 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, stack println!("Err({} ({:#X}))", err, err.errno); } } - }*/ + } // errormux turns Result<usize> into -errno Error::mux(result)