aarch64: Basic exception handlers

This commit is contained in:
Robin Randhawa
2021-01-26 18:18:19 +00:00
parent 4a215c7c2c
commit 28dfc0f46b

View File

@@ -0,0 +1,47 @@
use crate::{
interrupt::stack_trace,
syscall,
syscall::flag::*,
with_exception_stack,
exception_stack,
};
exception_stack!(synchronous_exception_at_el1_with_sp0, |stack| {
println!("Synchronous exception at EL1 with SP0");
stack.dump();
stack_trace();
loop {}
});
exception_stack!(synchronous_exception_at_el1_with_spx, |stack| {
println!("Synchronous exception at EL1 with SPx");
stack.dump();
stack_trace();
loop {}
});
exception_stack!(synchronous_exception_at_el0, |stack| {
with_exception_stack!(|stack| {
let fp;
asm!("mov {}, fp", out(reg) fp);
let exception_code = (stack.iret.esr_el1 & (0x3f << 26)) >> 26;
if exception_code != 0b010101 {
println!("FATAL: Not an SVC induced synchronous exception");
stack.dump();
stack_trace();
loop {}
}
let scratch = &stack.scratch;
syscall::syscall(scratch.x8, scratch.x0, scratch.x1, scratch.x2, scratch.x3, scratch.x4, fp, stack)
});
});
exception_stack!(unhandled_exception, |stack| {
println!("Unhandled exception");
stack.dump();
stack_trace();
loop {}
});