This commit is contained in:
pjht 2025-03-08 10:52:57 -06:00
parent 5f7c6f4183
commit c265e452c5
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A
3 changed files with 15 additions and 16 deletions

View File

@ -60,8 +60,10 @@ pub struct InvalidIrq;
pub fn init() {
IDT.load();
unsafe { PICS.lock().initialize() };
unsafe { PICS.lock().write_masks(0, 0) };
unsafe {
PICS.lock().initialize();
PICS.lock().write_masks(0, 0);
};
x86_64::instructions::interrupts::enable();
}
@ -554,9 +556,7 @@ extern "C" fn syscall_handler() {
clippy::unwrap_used,
reason = "Syscalls cannot be called during early boot, the only time when there is no current PID"
)]
REGISTERD_PIDS
.write()
.insert(regs.rcx, TASKING.current_tid().unwrap().pid());
REGISTERD_PIDS.write().insert(regs.rcx, TASKING.current_tid().unwrap().pid());
}
10 => {
let pid = REGISTERD_PIDS.read().get(&regs.rcx).copied();
@ -838,8 +838,8 @@ extern "C" fn syscall_handler() {
}
_ => (),
};
unsafe { SYSCALL_REGS = regs };
unsafe {
SYSCALL_REGS = regs;
asm!(
"mov rbx, [rip+SYSCALL_REGS+8]",
"mov rdi, [rip+SYSCALL_REGS+40]",

View File

@ -314,5 +314,7 @@ pub fn main() {
let init_pid = TASKING
.new_process(ptr::with_exposed_provenance(usize(init.ehdr.e_entry)), init_addr_space)
.expect("Failed to create init process");
TASKING.wake(Tid::main_thread(init_pid), SleepReason::NewProcess).expect("Failed to wake new init process");
TASKING
.wake(Tid::main_thread(init_pid), SleepReason::NewProcess)
.expect("Failed to wake new init process");
}

View File

@ -153,17 +153,11 @@ pub struct Tid {
impl Tid {
pub fn from_pid_tid(pid: Pid, tid: usize) -> Self {
Self {
pid,
tid,
}
Self { pid, tid }
}
pub fn main_thread(pid: Pid) -> Self {
Self {
pid,
tid: 0
}
Self { pid, tid: 0 }
}
pub fn pid(&self) -> Pid {
@ -339,7 +333,10 @@ impl Tasking {
buffer.extend_from_slice(&0u64.to_le_bytes());
buffer.extend_from_slice(&8u16.to_le_bytes());
buffer.extend_from_slice(&6u16.to_le_bytes());
buffer.extend_from_slice(unsigned_varint::encode::u64(u64(pid.as_usize()), &mut varint_buf));
buffer.extend_from_slice(unsigned_varint::encode::u64(
u64(pid.as_usize()),
&mut varint_buf,
));
if let Some(current_tid) = *(self.current_tid.read()) {
buffer.push(1);
buffer.extend_from_slice(unsigned_varint::encode::u64(