diff --git a/src/interrupts.rs b/src/interrupts.rs index cc8604b..e07a604 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -14,13 +14,14 @@ use hashbrown::HashMap; use pic8259::ChainedPics; use saturating_cast::SaturatingCast; use spin::{Lazy, Mutex, RwLock}; -use tap::Tap; use x86_64::{ registers::control::Cr2, set_general_handler, structures::{ idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode}, - paging::{mapper::TranslateResult, Page, PageTableFlags, PageTableIndex, PhysFrame, Translate}, + paging::{ + mapper::TranslateResult, Page, PageTableFlags, PageTableIndex, PhysFrame, Translate, + }, }, PhysAddr, PrivilegeLevel, VirtAddr, }; @@ -331,7 +332,7 @@ extern "C" fn syscall_handler() { retval = failed.into(); } 7 => { - if let Some(mut buffer) = get_buffer(regs.rdx) { + if let Some(buffer) = get_buffer(regs.rdx) { let len = usize(regs.rdi); assert!(len <= buffer.len()); TASKING.address_spaces_mut(|x| { diff --git a/src/tasking.rs b/src/tasking.rs index 0c692f6..1066d7e 100644 --- a/src/tasking.rs +++ b/src/tasking.rs @@ -8,7 +8,6 @@ use core::{ arch::asm, ffi::CStr, ptr::{addr_of, addr_of_mut}, - sync::atomic::{AtomicUsize, Ordering}, }; use crossbeam_queue::SegQueue; use humansize::{SizeFormatter, BINARY}; diff --git a/src/virtual_memory.rs b/src/virtual_memory.rs index 6351ca9..014e5e6 100644 --- a/src/virtual_memory.rs +++ b/src/virtual_memory.rs @@ -222,17 +222,16 @@ pub static ACTIVE_SPACE: Lazy = Lazy::new(|| { ASpaceMutex::new(new_space) }); -fn alloc_pt() -> Result<(*mut PageTable, PhysAddr), PagingError> { - let frame = PHYSICAL_MEMORY.lock().allocate_frame().ok_or(MapToError::FrameAllocationFailed)?; - Ok((frame.as_virt_ptr(), frame.start_address())) -} - impl AddressSpace { pub fn new() -> Result { // SAFETY: We copy the kernel space mappings to the newly allocated table before we make a reference to it, so // the reference cannot point to uninitialized data. let new_table = unsafe { - let new_table = alloc_pt()?.0; + let new_table = PHYSICAL_MEMORY + .lock() + .allocate_frame() + .ok_or(MapToError::FrameAllocationFailed)? + .as_virt_ptr::(); new_table.copy_from(KERNEL_SPACE.lock().mapper.level_4_table(), 1); &mut *new_table };