kernel: riscv: print processes from tid #0

Start numbering threads from index 0. This matches up with what the rest
of the system uses.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2023-01-30 21:54:08 +08:00
parent 8c82736524
commit 7f7142d948
2 changed files with 5 additions and 2 deletions

View file

@ -132,7 +132,10 @@ pub extern "C" fn trap_handler(
&& sstatus::read().spp() == sstatus::SPP::Supervisor
&& sc.bits() == 0xf
{
panic!("Ran out of kernel stack");
let pid = current_pid();
let ex = RiscvException::from_regs(sc.bits(), sepc::read(), stval::read());
print!("KERNEL({}): RISC-V fault: {} - ", pid, ex);
panic!("Maybe ran out of kernel stack?");
}
let pid = current_pid();

View file

@ -435,7 +435,7 @@ impl Process {
pub fn print_all_threads(&self) {
let process = unsafe { &mut *PROCESS };
for (tid_idx, &thread) in process.threads.iter().enumerate() {
let tid = tid_idx + 1;
let tid = tid_idx;
if thread.registers[1] != 0 {
Self::print_thread(tid, &thread);
}