Move proc_man exit call into kernel
This commit is contained in:
parent
fb58d2c7c4
commit
b3cc54fddf
@ -102,7 +102,7 @@ extern "x86-interrupt" fn page_fault_handler(
|
|||||||
} else {
|
} else {
|
||||||
println!("page faulted {error_code:#?} at {:#x}\n{stack_frame:#?}", faulting_addr);
|
println!("page faulted {error_code:#?} at {:#x}\n{stack_frame:#?}", faulting_addr);
|
||||||
}
|
}
|
||||||
TASKING.exit();
|
TASKING.exit(254);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[expect(clippy::needless_pass_by_value, reason = "Signature dictated by external crate")]
|
#[expect(clippy::needless_pass_by_value, reason = "Signature dictated by external crate")]
|
||||||
@ -118,7 +118,7 @@ fn exc_handler(_stack_frame: InterruptStackFrame, _index: u8, _error_code: Optio
|
|||||||
print!("Kernel init ");
|
print!("Kernel init ");
|
||||||
}
|
}
|
||||||
println!("had exception, exiting");
|
println!("had exception, exiting");
|
||||||
TASKING.exit();
|
TASKING.exit(254);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EoiGuard(u8);
|
pub struct EoiGuard(u8);
|
||||||
@ -358,7 +358,7 @@ extern "C" fn syscall_handler() {
|
|||||||
};
|
};
|
||||||
retval = rval;
|
retval = rval;
|
||||||
}
|
}
|
||||||
1 => TASKING.exit(),
|
1 => TASKING.exit(regs.rcx.wrapping_cast()),
|
||||||
2 => {
|
2 => {
|
||||||
retval = if regs.rcx == 0 {
|
retval = if regs.rcx == 0 {
|
||||||
ACTIVE_SPACE
|
ACTIVE_SPACE
|
||||||
|
@ -13,5 +13,5 @@ entry_point!(start, config = &BOOTLOADER_CONFIG);
|
|||||||
fn start(bootinfo: &'static mut BootInfo) -> ! {
|
fn start(bootinfo: &'static mut BootInfo) -> ! {
|
||||||
BOOTINFO.set(bootinfo);
|
BOOTINFO.set(bootinfo);
|
||||||
main();
|
main();
|
||||||
TASKING.exit();
|
TASKING.exit(0);
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,33 @@ impl Tasking {
|
|||||||
*self.current_pid.read()
|
*self.current_pid.read()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exit(&self) -> ! {
|
pub fn exit(&self, code: u8) -> ! {
|
||||||
|
if let Some(current_pid) = *self.current_pid.read() {
|
||||||
|
if let Some(&proc_man_pid) = REGISTERD_PIDS.read().get(&3) {
|
||||||
|
let mut len: usize;
|
||||||
|
let rounded_size = 32usize.next_multiple_of(4096);
|
||||||
|
let mut buffer = Vec::with_capacity_in(rounded_size, &*ACTIVE_SPACE);
|
||||||
|
buffer.resize(rounded_size, 0);
|
||||||
|
let mut buffer = buffer.into_boxed_slice();
|
||||||
|
buffer[0..8].copy_from_slice(&u64::MAX.to_le_bytes());
|
||||||
|
buffer[8..10].copy_from_slice(&0u16.to_le_bytes());
|
||||||
|
buffer[10] = 0;
|
||||||
|
buffer[11..19].copy_from_slice(&0u64.to_le_bytes());
|
||||||
|
buffer[19..21].copy_from_slice(&8u16.to_le_bytes());
|
||||||
|
buffer[21..23].copy_from_slice(&4u16.to_le_bytes());
|
||||||
|
len = 23;
|
||||||
|
len += unsigned_varint::encode::u64(
|
||||||
|
u64(current_pid),
|
||||||
|
(&mut buffer[len..len + 10]).try_into().unwrap(),
|
||||||
|
)
|
||||||
|
.len();
|
||||||
|
buffer[len] = code;
|
||||||
|
len += 1;
|
||||||
|
send_ipc_to(usize(proc_man_pid), buffer, len);
|
||||||
|
} else {
|
||||||
|
println!("[TASKING] No process manager when PID {} exited with code {code}", current_pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
loop {
|
loop {
|
||||||
let next_process_pid = self.ready_to_run.lock().pop_front();
|
let next_process_pid = self.ready_to_run.lock().pop_front();
|
||||||
if let Some(next_process_pid) = next_process_pid {
|
if let Some(next_process_pid) = next_process_pid {
|
||||||
|
Loading…
Reference in New Issue
Block a user