Update to use TableKind on x86_64

This commit is contained in:
Jeremy Soller
2022-08-20 13:16:23 -06:00
parent 01df1c20da
commit fe7def2797
5 changed files with 16 additions and 14 deletions

View File

@@ -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())

View File

@@ -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)
};

View File

@@ -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)

View File

@@ -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!();
}

View File

@@ -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)