Marc Jones (marc.jones@se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7657
-gerrit
commit a10ae8bbfad9ca33ee4e3e60433f93806954fa3b Author: Gabe Black gabeblack@google.com Date: Mon Dec 16 04:07:50 2013 -0800
libpayload: ARM: Keep track of the CPSR when exceptions happen.
Use the SPSR to extract and inject CPSR values when an exception happens and pass that information to exception hooks.
The register structure GDB expects when using its remote protocol has a spot for the CPSR.
BUG=None TEST=Built and booted on link, nyan. BRANCH=None
Original-Change-Id: Id950fb09d72fb0f81e4eef2489c0849ce5dd8aca Original-Signed-off-by: Gabe Black gabeblack@google.com Original-Reviewed-on: https://chromium-review.googlesource.com/180253 Original-Reviewed-by: Gabe Black gabeblack@chromium.org Original-Tested-by: Gabe Black gabeblack@chromium.org Original-Commit-Queue: Gabe Black gabeblack@chromium.org (cherry picked from commit 8e7014f24a580f84c91fa7b0369dfa922918adcc) Signed-off-by: Marc Jones marc.jones@se-eng.com
Change-Id: I49357fb6a65edeff7a9a48d54254308a6b0efdb7 --- payloads/libpayload/arch/arm/exception.c | 7 ++++--- payloads/libpayload/arch/arm/exception_asm.S | 4 ++++ payloads/libpayload/include/arm/arch/exception.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/payloads/libpayload/arch/arm/exception.c b/payloads/libpayload/arch/arm/exception.c index f0ce0ea..45b77a7 100644 --- a/payloads/libpayload/arch/arm/exception.c +++ b/payloads/libpayload/arch/arm/exception.c @@ -66,7 +66,7 @@ static void dump_stack(uintptr_t addr, size_t bytes) } }
-static void print_regs(uint32_t *regs) +static void print_regs(struct exception_state *state) { int i;
@@ -81,8 +81,9 @@ static void print_regs(uint32_t *regs) printf("IP"); else printf("R%d", i); - printf(" = 0x%08x\n", regs[i]); + printf(" = 0x%08x\n", state->regs[i]); } + printf("CPSR = 0x%08x\n", state->cpsr); }
void exception_dispatch(struct exception_state *state, int idx); @@ -102,7 +103,7 @@ void exception_dispatch(struct exception_state *state, int idx) else printf("exception _not_used.\n"); } - print_regs(state->regs); + print_regs(state); dump_stack(state->regs[13], 512); halt(); } diff --git a/payloads/libpayload/arch/arm/exception_asm.S b/payloads/libpayload/arch/arm/exception_asm.S index 6a28c5c..974d172 100644 --- a/payloads/libpayload/arch/arm/exception_asm.S +++ b/payloads/libpayload/arch/arm/exception_asm.S @@ -74,9 +74,13 @@ exception_common: stmfd sp, { sp, lr }^ sub sp, sp, $8 push { r0 - r12 } + mrs r0, SPSR + push { r0 } mov r0, sp ldr r1, exception_idx blx exception_dispatch + pop { r0 } + msr SPSR_cxsf, r0 pop { r0 - r12 } add sp, sp, $8 ldmfd sp!, { pc }^ diff --git a/payloads/libpayload/include/arm/arch/exception.h b/payloads/libpayload/include/arm/arch/exception.h index 13fda57..c6864a5 100644 --- a/payloads/libpayload/include/arm/arch/exception.h +++ b/payloads/libpayload/include/arm/arch/exception.h @@ -36,6 +36,7 @@ void set_vbar(uint32_t vbar);
struct exception_state { + uint32_t cpsr; uint32_t regs[16]; } __attribute__((packed));