31 lines
899 B
C
31 lines
899 B
C
#include <exception_handler.h>
|
|
#include <log.h>
|
|
#include <synchronize.h>
|
|
|
|
static const char *names[] = {"Unexpected exception", "Synchronous exception",
|
|
"System error"};
|
|
|
|
void gilbraltar_exception_handler(uint64_t exn, struct frame *frame) {
|
|
enable_fiqs();
|
|
|
|
uint64_t sp = frame->sp_el0;
|
|
|
|
if ((frame->spsr_el1 & 0xf) == 0x05)
|
|
sp = frame->sp_el1;
|
|
|
|
uint64_t ec = (frame->esr_el1 >> 26) & 0x3f;
|
|
uint64_t iss = frame->esr_el1 & 0x1ffffff;
|
|
uint64_t far = 0;
|
|
|
|
if ((0x20 <= ec && ec <= 0x25) || (0x34 <= ec && ec <= 0x35))
|
|
far = frame->far_el1;
|
|
|
|
gilbraltar_log(ERROR,
|
|
"%s (pc: 0x%lx, ec: 0x%lx, iss: 0x%lx, far: 0x%lx, sp: 0x%lx, "
|
|
"lr: 0x%lx, spsr: 0x%lx)\r\n",
|
|
names[exn], frame->elr_el1, ec, iss, far, sp, frame->x30,
|
|
frame->spsr_el1);
|
|
|
|
while (1)
|
|
__asm__ __volatile("wfi");
|
|
}
|