Commit 4b847348 authored by Mateusz Zalega's avatar Mateusz Zalega
Browse files

faultscreen: coding style


Signed-off-by: Mateusz Zalega's avatarMateusz Zalega <mateusz@appliedsourcery.com>
parent 16dda79a
...@@ -12,33 +12,39 @@ ...@@ -12,33 +12,39 @@
#include "core1.h" #include "core1.h"
struct regs_t { struct regs_t {
unsigned int pc; unsigned int pc;
unsigned int sp; unsigned int sp;
unsigned int lr; unsigned int lr;
} static regs; } static regs;
#define LOAD_REGS() \ #define LOAD_REGS() \
__asm__ __volatile__( \ __asm__ __volatile__( \
"ldr %0, [sp, #24] \n" \ "ldr %0, [sp, #24] \n" \
"ldr %1, [sp, #20] \n" \ "ldr %1, [sp, #20] \n" \
"mov %2, sp \n" \ "mov %2, sp \n" \
: "=r" (regs.pc), \ : "=r"(regs.pc), "=r"(regs.lr), "=r"(regs.sp))
"=r" (regs.lr), \
"=r" (regs.sp) \ static void generic_handler(const char *reason)
) {
char lines[3][64];
static void generic_handler(const char *reason) {
char lines[3][64]; Core1_Stop();
__disable_irq();
Core1_Stop();
__disable_irq(); snprintf(lines[0], sizeof(lines[0]), "pc: 0x%08x", regs.pc);
snprintf(lines[1], sizeof(lines[1]), "sp: 0x%08x", regs.sp);
snprintf(lines[0], sizeof(lines[0]), "pc: 0x%08x", regs.pc); snprintf(lines[2], sizeof(lines[2]), "lr: 0x%08x", regs.lr);
snprintf(lines[1], sizeof(lines[1]), "sp: 0x%08x", regs.sp);
snprintf(lines[2], sizeof(lines[2]), "lr: 0x%08x", regs.lr); gfx_copy_region(
&display_screen,
gfx_copy_region(&display_screen, 0, 0, 160, 80, GFX_RLE_MONO, 0,
faultsplash_rle_len, faultsplash_rle); 0,
160,
80,
GFX_RLE_MONO,
faultsplash_rle_len,
faultsplash_rle
);
Color black = gfx_color(&display_screen, BLACK); Color black = gfx_color(&display_screen, BLACK);
Color white = gfx_color(&display_screen, WHITE); Color white = gfx_color(&display_screen, WHITE);
...@@ -50,35 +56,41 @@ static void generic_handler(const char *reason) { ...@@ -50,35 +56,41 @@ static void generic_handler(const char *reason) {
gfx_update(&display_screen); gfx_update(&display_screen);
} }
static void NMI_Handler_(void) { static void NMI_Handler_(void)
LOAD_REGS(); {
generic_handler("NMI Fault"); LOAD_REGS();
generic_handler("NMI Fault");
} }
static void HardFault_Handler_(void) { static void HardFault_Handler_(void)
LOAD_REGS(); {
generic_handler("HardFault"); LOAD_REGS();
generic_handler("HardFault");
} }
static void MemManage_Handler_(void) { static void MemManage_Handler_(void)
LOAD_REGS(); {
generic_handler("MemMgmtFault"); LOAD_REGS();
generic_handler("MemMgmtFault");
} }
static void BusFault_Handler_(void) { static void BusFault_Handler_(void)
LOAD_REGS(); {
generic_handler("BusFault"); LOAD_REGS();
generic_handler("BusFault");
} }
static void UsageFault_Handler_(void) { static void UsageFault_Handler_(void)
LOAD_REGS(); {
generic_handler("UsageFault"); LOAD_REGS();
generic_handler("UsageFault");
} }
void card10_set_fault_handlers(void) { void card10_set_fault_handlers(void)
NVIC_SetVector(NonMaskableInt_IRQn, NMI_Handler_); {
NVIC_SetVector(HardFault_IRQn, HardFault_Handler_); NVIC_SetVector(NonMaskableInt_IRQn, NMI_Handler_);
NVIC_SetVector(MemoryManagement_IRQn, MemManage_Handler_); NVIC_SetVector(HardFault_IRQn, HardFault_Handler_);
NVIC_SetVector(BusFault_IRQn, BusFault_Handler_); NVIC_SetVector(MemoryManagement_IRQn, MemManage_Handler_);
NVIC_SetVector(UsageFault_IRQn, UsageFault_Handler_); NVIC_SetVector(BusFault_IRQn, BusFault_Handler_);
NVIC_SetVector(UsageFault_IRQn, UsageFault_Handler_);
} }
#include "faultsplash.h" #include "faultsplash.h"
const unsigned char faultsplash_rle[] = { const unsigned char faultsplash_rle[] = {
0x7f, 0x50, 0x83, 0x0f, 0x82, 0x7f, 0x0d, 0x83, 0x0f, 0x82, 0x7f, 0x1d, 0x7f, 0x50, 0x83, 0x0f, 0x82, 0x7f, 0x0d, 0x83, 0x0f, 0x82, 0x7f, 0x1d,
0x82, 0x7f, 0x1f, 0x82, 0x7f, 0x1f, 0x82, 0x7f, 0x12, 0x82, 0x09, 0x82, 0x82, 0x7f, 0x1f, 0x82, 0x7f, 0x1f, 0x82, 0x7f, 0x12, 0x82, 0x09, 0x82,
0x7f, 0x14, 0x82, 0x09, 0x82, 0x7f, 0x09, 0x82, 0x11, 0x83, 0x7f, 0x0b, 0x7f, 0x14, 0x82, 0x09, 0x82, 0x7f, 0x09, 0x82, 0x11, 0x83, 0x7f, 0x0b,
0x82, 0x11, 0x83, 0x7f, 0x0f, 0x82, 0x07, 0x82, 0x7f, 0x16, 0x82, 0x07, 0x82, 0x11, 0x83, 0x7f, 0x0f, 0x82, 0x07, 0x82, 0x7f, 0x16, 0x82, 0x07,
0x82, 0x7f, 0x16, 0x82, 0x07, 0x82, 0x7f, 0x1a, 0x83, 0x7f, 0x1e, 0x83, 0x82, 0x7f, 0x16, 0x82, 0x07, 0x82, 0x7f, 0x1a, 0x83, 0x7f, 0x1e, 0x83,
0x7f, 0x0a, 0x8b, 0x17, 0x82, 0x02, 0x82, 0x02, 0x83, 0x73, 0x8c, 0x16, 0x7f, 0x0a, 0x8b, 0x17, 0x82, 0x02, 0x82, 0x02, 0x83, 0x73, 0x8c, 0x16,
0x82, 0x02, 0x82, 0x02, 0x83, 0x72, 0x81, 0x0c, 0x84, 0x07, 0x85, 0x7f, 0x82, 0x02, 0x82, 0x02, 0x83, 0x72, 0x81, 0x0c, 0x84, 0x07, 0x85, 0x7f,
0x03, 0x82, 0x0c, 0x84, 0x07, 0x86, 0x7f, 0x02, 0x82, 0x0c, 0x84, 0x07, 0x03, 0x82, 0x0c, 0x84, 0x07, 0x86, 0x7f, 0x02, 0x82, 0x0c, 0x84, 0x07,
0x86, 0x7f, 0x82, 0x12, 0x87, 0x7f, 0x06, 0x82, 0x12, 0x87, 0x7f, 0x06, 0x86, 0x7f, 0x82, 0x12, 0x87, 0x7f, 0x06, 0x82, 0x12, 0x87, 0x7f, 0x06,
0x82, 0x24, 0x82, 0x78, 0x82, 0x24, 0x82, 0x78, 0x82, 0x24, 0x82, 0x78, 0x82, 0x24, 0x82, 0x78, 0x82, 0x24, 0x82, 0x78, 0x82, 0x24, 0x82, 0x78,
0x82, 0x16, 0x83, 0x04, 0x82, 0x07, 0x82, 0x76, 0x82, 0x16, 0x83, 0x04, 0x82, 0x16, 0x83, 0x04, 0x82, 0x07, 0x82, 0x76, 0x82, 0x16, 0x83, 0x04,
0x82, 0x07, 0x82, 0x70, 0x8f, 0x0d, 0x82, 0x12, 0x82, 0x6e, 0x8f, 0x0d, 0x82, 0x07, 0x82, 0x70, 0x8f, 0x0d, 0x82, 0x12, 0x82, 0x6e, 0x8f, 0x0d,
0x82, 0x12, 0x82, 0x6e, 0x8f, 0x0b, 0x82, 0x09, 0x82, 0x0b, 0x82, 0x6c, 0x82, 0x12, 0x82, 0x6e, 0x8f, 0x0b, 0x82, 0x09, 0x82, 0x0b, 0x82, 0x6c,
0x8f, 0x0b, 0x82, 0x09, 0x82, 0x0b, 0x82, 0x6c, 0x8f, 0x0b, 0x82, 0x09, 0x8f, 0x0b, 0x82, 0x09, 0x82, 0x0b, 0x82, 0x6c, 0x8f, 0x0b, 0x82, 0x09,
0x82, 0x0b, 0x82, 0x6c, 0x8f, 0x7f, 0x12, 0x8f, 0x7f, 0x0d, 0x98, 0x12, 0x82, 0x0b, 0x82, 0x6c, 0x8f, 0x7f, 0x12, 0x8f, 0x7f, 0x0d, 0x98, 0x12,
0x82, 0x74, 0x98, 0x12, 0x82, 0x70, 0xa1, 0x7f, 0xa1, 0x7f, 0xa1, 0x7f, 0x82, 0x74, 0x98, 0x12, 0x82, 0x70, 0xa1, 0x7f, 0xa1, 0x7f, 0xa1, 0x7f,
0xa1, 0x7f, 0xa1, 0x7d, 0xa5, 0x7b, 0xa5, 0x7b, 0xa5, 0x7b, 0xa5, 0x7a, 0xa1, 0x7f, 0xa1, 0x7d, 0xa5, 0x7b, 0xa5, 0x7b, 0xa5, 0x7b, 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f, 0x12, 0x8f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x06 0x7f, 0x06
}; };
const size_t faultsplash_rle_len = 302; const size_t faultsplash_rle_len = 302;
const size_t faultsplash_width = 160; const size_t faultsplash_width = 160;
const size_t faultsplash_height = 80; const size_t faultsplash_height = 80;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment