From 4aa761616b38c63f0402c2a01cea26fdff6f78a7 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Mon, 8 Sep 2014 18:04:18 -0700 Subject: arm64: Make exceptions use the transition library Transition library acts as a common interface for handling exceptions. The only thing that needs to be implemented by exception.c is the exc_dispatch routine to handle the exceptions as required. BUG=chrome-os-partner:30785 BRANCH=None TEST=Compiles successfully and exceptions are tested using test_exc Change-Id: I90b4861909189adfe8449b9d4590965e6b743c00 Signed-off-by: Patrick Georgi Original-Commit-Id: b83c9404407dd4dd2dda4e4eaed0b443f0f58425 Original-Change-Id: Ibb643d7ea2f9aabbc66439549ea2168fd66ced5e Original-Signed-off-by: Furquan Shaikh Original-Reviewed-on: https://chromium-review.googlesource.com/217143 Original-Reviewed-by: Aaron Durbin Original-Tested-by: Furquan Shaikh Original-Commit-Queue: Furquan Shaikh Reviewed-on: http://review.coreboot.org/9071 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/arch/arm64/armv8/exception.c | 41 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/arch/arm64/armv8/exception.c') diff --git a/src/arch/arm64/armv8/exception.c b/src/arch/arm64/armv8/exception.c index d9a63c3a81..0aef0e5457 100644 --- a/src/arch/arm64/armv8/exception.c +++ b/src/arch/arm64/armv8/exception.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -80,24 +81,28 @@ static struct exception_handler_info exceptions[EXC_COUNT] = { [EXC_SERROR_ELX_32] = {"_serror_elx_32"}, }; -static void print_regs(struct exception_state *state) +static void print_regs(struct exc_state *exc_state) { int i; - uint64_t far_el3; - - far_el3 = raw_read_far_el3(); - - printk(BIOS_DEBUG, "ELR = 0x%016llx\n", state->elr); - printk(BIOS_DEBUG, "ESR = 0x%08llx\n", state->esr); - printk(BIOS_DEBUG, "FAR_EL3 = 0x%016llx\n", far_el3); - for (i = 0; i < 31; i++) - printk(BIOS_DEBUG, "X%02d = 0x%016llx\n", i, state->regs[i]); + struct elx_state *elx = &exc_state->elx; + struct regs *regs = &exc_state->regs; + + uint64_t elx_esr = raw_read_esr_current(); + uint64_t elx_far = raw_read_far_current(); + + printk(BIOS_DEBUG, "ELR = 0x%016llx\n", elx->elr); + printk(BIOS_DEBUG, "ESR = 0x%016llx\n", elx_esr); + printk(BIOS_DEBUG, "SPSR = 0x%08llx\n", elx->spsr); + printk(BIOS_DEBUG, "FAR = 0x%016llx\n", elx_far); + for (i = X0_INDEX; i < XMAX_INDEX; i++) + printk(BIOS_DEBUG, "X%02d = 0x%016llx\n", i, regs->x[i]); } -void exception_dispatch(struct exception_state *state, int idx) +void exc_dispatch(struct exc_state *exc_state, uint64_t idx) { if (idx >= EXC_COUNT) { - printk(BIOS_DEBUG, "Bad exception index %d.\n", idx); + printk(BIOS_DEBUG, "Bad exception index %lx.\n", + (unsigned long)idx); } else { struct exception_handler_info *info = &exceptions[idx]; @@ -106,14 +111,17 @@ void exception_dispatch(struct exception_state *state, int idx) else printk(BIOS_DEBUG, "exception _not_used.\n"); } - print_regs(state); + print_regs(exc_state); if (test_exc) { - state->elr += 4; + exc_state->elx.elr += 4; + raw_write_elr_current(exc_state->elx.elr); test_exc = 0; - printk(BIOS_DEBUG, "new ELR = 0x%016llx\n", state->elr); + printk(BIOS_DEBUG, "new ELR = 0x%016llx\n", exc_state->elx.elr); } else die("exception"); + + exc_exit(&exc_state->regs); } static uint64_t test_exception(void) @@ -129,8 +137,7 @@ static uint64_t test_exception(void) void exception_hwinit(void) { - extern void *exception_table; - set_vbar(&exception_table); + exc_set_vbar(); } void exception_init(void) -- cgit v1.2.3