Use TableKind everywhere
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -311,7 +313,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())
|
||||
|
||||
@@ -199,9 +199,9 @@ pub unsafe extern fn kstart_ap(args_ptr: *const KernelArgsAp) -> ! {
|
||||
pub unsafe extern "C" fn usermode(_ip: usize, _sp: usize, _arg: usize, _is_singlestep: usize) -> ! {
|
||||
core::arch::asm!(
|
||||
"
|
||||
msr spsr_el1, xzr // spsr
|
||||
msr elr_el1, x0 // ip
|
||||
msr sp_el0, x1 // sp
|
||||
msr spsr_el1, xzr // spsr
|
||||
msr elr_el1, x0 // ip
|
||||
msr sp_el0, x1 // sp
|
||||
mov x0, x2 // arg
|
||||
eret
|
||||
",
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::arch::paging::PAGE_SIZE;
|
||||
use crate::context::file::FileDescriptor;
|
||||
use crate::memory::{Enomem, Frame};
|
||||
use crate::paging::mapper::{Flusher, InactiveFlusher, PageFlushAll};
|
||||
use crate::paging::{KernelMapper, Page, PageFlags, PageIter, PageMapper, RmmA, round_up_pages, VirtualAddress};
|
||||
use crate::paging::{KernelMapper, Page, PageFlags, PageIter, PageMapper, RmmA, round_up_pages, TableKind, VirtualAddress};
|
||||
|
||||
pub const MMAP_MIN_DEFAULT: usize = PAGE_SIZE;
|
||||
|
||||
@@ -891,7 +891,7 @@ impl Drop for Table {
|
||||
// before it waits for interrupts. Or maybe not, depends on what future benchmarks will
|
||||
// indicate.
|
||||
unsafe {
|
||||
RmmA::set_table(super::empty_cr3());
|
||||
RmmA::set_table(TableKind::User, super::empty_cr3());
|
||||
}
|
||||
}
|
||||
crate::memory::deallocate_frames(Frame::containing_address(self.utable.table().phys()), 1);
|
||||
@@ -901,7 +901,7 @@ impl Drop for Table {
|
||||
/// Allocates a new identically mapped ktable and empty utable
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub fn setup_new_utable() -> Result<Table> {
|
||||
let mut utable = unsafe { PageMapper::create(crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? };
|
||||
let mut utable = unsafe { PageMapper::create(TableKind::User, crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? };
|
||||
|
||||
{
|
||||
let active_ktable = KernelMapper::lock();
|
||||
@@ -927,7 +927,7 @@ pub fn setup_new_utable() -> Result<Table> {
|
||||
/// Allocates a new identically mapped ktable and empty utable (same memory on x86)
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub fn setup_new_utable() -> Result<Table> {
|
||||
let mut utable = unsafe { PageMapper::create(crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? };
|
||||
let mut utable = unsafe { PageMapper::create(TableKind::User, crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? };
|
||||
|
||||
{
|
||||
let active_ktable = KernelMapper::lock();
|
||||
@@ -953,7 +953,7 @@ pub fn setup_new_utable() -> Result<Table> {
|
||||
/// Allocates a new identically mapped ktable and empty utable (same memory on x86_64).
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn setup_new_utable() -> Result<Table> {
|
||||
let utable = unsafe { PageMapper::create(crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? };
|
||||
let utable = unsafe { PageMapper::create(TableKind::User, crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? };
|
||||
|
||||
{
|
||||
let active_ktable = KernelMapper::lock();
|
||||
|
||||
@@ -7,7 +7,7 @@ use alloc::sync::Arc;
|
||||
|
||||
use spin::{RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
use crate::paging::{RmmA, RmmArch};
|
||||
use crate::paging::{RmmA, RmmArch, TableKind};
|
||||
use crate::syscall::error::{Error, ESRCH, Result};
|
||||
|
||||
pub use self::context::{Context, ContextId, ContextSnapshot, Status, WaitpidKey};
|
||||
@@ -68,7 +68,7 @@ pub fn init() {
|
||||
let context_lock = contexts.new_context().expect("could not initialize first context");
|
||||
let mut context = context_lock.write();
|
||||
|
||||
self::arch::EMPTY_CR3.call_once(|| unsafe { RmmA::table() });
|
||||
self::arch::EMPTY_CR3.call_once(|| unsafe { RmmA::table(TableKind::User) });
|
||||
|
||||
context.status = Status::Runnable;
|
||||
context.running = true;
|
||||
|
||||
Reference in New Issue
Block a user