From ddc707fceb1a8e6ec81943f7502d5e28c4763352 Mon Sep 17 00:00:00 2001 From: bushing Date: Sat, 28 Feb 2009 02:50:33 -0800 Subject: [PATCH] added more debugging output for undefined instruction exceptions --- boot2.c | 3 +-- exception.c | 41 +++++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/boot2.c b/boot2.c index 75860a9..a54da94 100644 --- a/boot2.c +++ b/boot2.c @@ -8,7 +8,7 @@ static u8 boot2[256 << 11] MEM2_BSS __attribute__((aligned(64))); static u8 key[32] MEM2_BSS __attribute__((aligned(64))); -static u8 ecc[64] __attribute__((aligned(64))); +static u8 ecc[128] __attribute__((aligned(64))); static u8 boot2_initialized = 0; extern void *vector; @@ -58,7 +58,6 @@ void boot2_init() { aes_set_iv(iv); aes_set_key(otp.common_key); memcpy(key, tikptr+0x1bf, 16); - gecko_puts("flushing now...\n"); dc_flushrange(key, 32); gecko_puts("dc_flush done.\n"); aes_decrypt(key, key, 1, 0); diff --git a/exception.c b/exception.c index 72c0e30..c99af18 100644 --- a/exception.c +++ b/exception.c @@ -6,7 +6,7 @@ #include "memory.h" const char *exceptions[] = { - "RESET", "UNDEFINED", "SWI", "INSTR ABORT", "DATA ABORT", "RESERVED", "IRQ", "FIQ" + "RESET", "UNDEFINED INSTR", "SWI", "INSTR ABORT", "DATA ABORT", "RESERVED", "IRQ", "FIQ", "(unknown exception type)" }; const char *aborts[] = { @@ -42,16 +42,17 @@ void exception_initialize(void) void exc_handler(u32 type, u32 spsr, u32 *regs) { + if (type > 8) type = 8; gecko_printf("\nException %d (%s):\n", type, exceptions[type]); - u32 pc; + u32 pc, fsr; switch(type) { - case 3: - case 7: + case 7: // FIQ + case 3: // INSTR ABORT pc = regs[15] - 4; break; - case 4: + case 4: // DATA ABORT pc = regs[15] - 8; break; default: @@ -66,21 +67,29 @@ void exc_handler(u32 type, u32 spsr, u32 *regs) gecko_printf("R12-R15: %08x %08x %08x %08x\n", regs[12], regs[13], regs[14], pc); gecko_printf("SPSR: %08x\n", spsr); + gecko_printf("CPSR: %08x\n", get_cpsr()); gecko_printf("CR: %08x\n", get_cr()); gecko_printf("TTBR: %08x\n", get_ttbr()); gecko_printf("DACR: %08x\n", get_dacr()); - if(type == 3 || type == 4) { - u32 fsr; - if(type == 3) - fsr = get_ifsr(); - else - fsr = get_dfsr(); - gecko_printf("Abort type: %s\n", aborts[fsr&0xf]); - if(domvalid[fsr&0xf]) - gecko_printf("Domain: %d\n", (fsr>>4)&0xf); - if(type == 4) - gecko_printf("Address: 0x%08x\n", get_far()); + switch (type) { + case 1: // undefined instruction + gecko_printf("Undefined instruction @ %08x: %08x\n", regs[14]-4, read32(regs[14]-4)); + return; + break; + case 3: // INSTR ABORT + case 4: // DATA ABORT + if(type == 3) + fsr = get_ifsr(); + else + fsr = get_dfsr(); + gecko_printf("Abort type: %s\n", aborts[fsr&0xf]); + if(domvalid[fsr&0xf]) + gecko_printf("Domain: %d\n", (fsr>>4)&0xf); + if(type == 4) + gecko_printf("Address: 0x%08x\n", get_far()); + break; + default: break; } panic(0xA3);