kernel: services: use exception stack for kernel interrupts

When the kernel is processing an interrupt, use the exception stack.
This ensures that the kernel interrupt handler can switch processes
without having its stack go away.

This is used for debug information.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-05-10 14:15:47 +08:00
parent ce66a6bde2
commit 5b92dd9874

View file

@ -527,7 +527,11 @@ impl SystemServices {
// function returns, it will jump to the RETURN_FROM_ISR address,
// causing an instruction fault and exiting the interrupt.
ArchProcess::with_current_mut(|arch_process| {
let sp = arch_process.current_thread().stack_pointer();
let sp = if pid.get() == 1 {
arch::mem::EXCEPTION_STACK_TOP
} else {
arch_process.current_thread().stack_pointer()
};
// Activate the current context
arch_process.set_thread(arch::process::IRQ_TID).unwrap();