diff --git a/Cargo.lock b/Cargo.lock index be857a5..d214aea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -273,7 +273,7 @@ dependencies = [ [[package]] name = "unwinding" -version = "0.1.4" +version = "0.1.5" dependencies = [ "gimli", ] diff --git a/initrd.tar b/initrd.tar index c477ed5..da4394a 100644 Binary files a/initrd.tar and b/initrd.tar differ diff --git a/src/interrupts.rs b/src/interrupts.rs index 1dbc71a..7e1d4ed 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -232,7 +232,7 @@ extern "C" fn syscall_handler() { .map_free(regs.rdx as usize, PageTableFlags::from_bits_truncate(regs.rsi)) .map_or(0, |x| x as u64) } else if let Some(space) = - TASKING.lock().address_spaces_mut().get_mut(regs.rcx as usize) + TASKING.lock().address_spaces_mut().get_mut((regs.rcx - 1) as usize) { space .map_free(regs.rdx as usize, PageTableFlags::from_bits_truncate(regs.rsi)) @@ -251,11 +251,11 @@ extern "C" fn syscall_handler() { retval2 = initrd.len() as u64; } 4 => { - retval = - TASKING.lock().address_spaces_mut().insert(AddressSpace::new().unwrap()) as u64; + retval = (TASKING.lock().address_spaces_mut().insert(AddressSpace::new().unwrap()) + 1) + as u64; } 5 => { - TASKING.lock().address_spaces_mut().remove(regs.rcx as usize); + TASKING.lock().address_spaces_mut().remove((regs.rcx - 1) as usize); } 6 => { let page = Page::from_start_address(VirtAddr::new(regs.rdx)).unwrap(); @@ -267,7 +267,7 @@ extern "C" fn syscall_handler() { TASKING .lock() .address_spaces_mut() - .get_mut(regs.rcx as usize) + .get_mut((regs.rcx - 1) as usize) .unwrap() .map_assert_unused(page, num_pages, flags) } @@ -280,7 +280,7 @@ extern "C" fn syscall_handler() { // let aligned_address = regs.rsi & !0xFFF; // let aligned_len = len as u64 + (regs.rsi - aligned_address); let mut tasking = TASKING.lock(); - let space = tasking.address_spaces_mut().get_mut(regs.rcx as usize).unwrap(); + let space = tasking.address_spaces_mut().get_mut((regs.rcx - 1) as usize).unwrap(); // space // .map_assert_unused( // Page::from_start_address(VirtAddr::new(aligned_address)).unwrap(), @@ -295,7 +295,7 @@ extern "C" fn syscall_handler() { } } 8 => { - let space = TASKING.lock().address_spaces_mut().remove(regs.rdx as usize); + let space = TASKING.lock().address_spaces_mut().remove((regs.rdx - 1) as usize); let res = TASKING.lock().new_process(regs.rcx as *const _, space); if let Ok(pid) = res { retval = 0; diff --git a/src/tasking.rs b/src/tasking.rs index 80bfbe3..c1baafb 100644 --- a/src/tasking.rs +++ b/src/tasking.rs @@ -78,7 +78,6 @@ extern "C" fn task_force_unlock() { } #[derive(Debug)] -#[repr(C)] struct Process { kernel_stack: Box<[usize], &'static ASpaceMutex>, kernel_esp: *mut usize, diff --git a/src/virtual_memory.rs b/src/virtual_memory.rs index 17568c1..e44a694 100644 --- a/src/virtual_memory.rs +++ b/src/virtual_memory.rs @@ -225,15 +225,10 @@ impl AddressSpace { /// Runs a provided closure in an address space. /// - /// This function takes ownership of the address space and passes it back after running the - /// closure. This is necessary to prevent the closure fron having access to the address space by - /// both the local variable it was in, and the `ACTIVE_SPACE` static, which would alias mutable - /// references. - /// /// ## Examples /// ``` /// let address_space = AddressSpace::new(); - /// let address_space = address_space.run(|| {/* your closure here */}); + /// address_space.run(|| {/* your closure here */}); /// ``` #[allow(unused)] pub fn run(&mut self, func: F) { diff --git a/sysroot/bin/init b/sysroot/bin/init index 668010a..0b957bc 100755 Binary files a/sysroot/bin/init and b/sysroot/bin/init differ diff --git a/sysroot/bin/test_proc b/sysroot/bin/test_proc index 773034d..6552845 100755 Binary files a/sysroot/bin/test_proc and b/sysroot/bin/test_proc differ