diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2009-01-08 10:15:32 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2009-01-08 10:15:32 +0000 |
commit | 4ed78f5c72649002d78d48d9a117826a5d9c36f9 (patch) | |
tree | 7ebe8ac19acabd74117a638da8dbb0c1cedf2600 /firmware/target/arm/system-arm.c | |
parent | 32d9752dcc73fd1aaa81d484c3d426ca7856b146 (diff) | |
download | rockbox-4ed78f5c72649002d78d48d9a117826a5d9c36f9.tar.gz rockbox-4ed78f5c72649002d78d48d9a117826a5d9c36f9.zip |
Clean up panicf and introduce system_exception_wait to do further target tasks and wait for a button when an unrecoverable error has occurred (panic, UIE, etc.). Returning from that function should reboot or don't return from it. Move UIE and __div0 for ARM to its own file.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19716 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/system-arm.c')
-rw-r--r-- | firmware/target/arm/system-arm.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/firmware/target/arm/system-arm.c b/firmware/target/arm/system-arm.c new file mode 100644 index 0000000000..5c5a18c867 --- /dev/null +++ b/firmware/target/arm/system-arm.c | |||
@@ -0,0 +1,66 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Thom Johansen | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "system.h" | ||
23 | #include <stdio.h> | ||
24 | #include "lcd.h" | ||
25 | #include "font.h" | ||
26 | |||
27 | static const char* const uiename[] = { | ||
28 | "Undefined instruction", | ||
29 | "Prefetch abort", | ||
30 | "Data abort", | ||
31 | "Divide by zero" | ||
32 | }; | ||
33 | |||
34 | /* Unexpected Interrupt or Exception handler. Currently only deals with | ||
35 | exceptions, but will deal with interrupts later. | ||
36 | */ | ||
37 | void __attribute__((noreturn)) UIE(unsigned int pc, unsigned int num) | ||
38 | { | ||
39 | char str[32]; | ||
40 | |||
41 | lcd_clear_display(); | ||
42 | #ifdef HAVE_LCD_BITMAP | ||
43 | lcd_setfont(FONT_SYSFIXED); | ||
44 | #endif | ||
45 | lcd_puts(0, 0, uiename[num]); | ||
46 | snprintf(str, sizeof(str), "at %08x" IF_COP(" (%d)"), pc | ||
47 | IF_COP(, CURRENT_CORE)); | ||
48 | lcd_puts(0, 1, str); | ||
49 | lcd_update(); | ||
50 | |||
51 | disable_interrupt(IRQ_FIQ_STATUS); | ||
52 | |||
53 | system_exception_wait(); /* If this returns, try to reboot */ | ||
54 | system_reboot(); | ||
55 | while (1); /* halt */ | ||
56 | } | ||
57 | |||
58 | /* Needs to be here or gcc won't find it */ | ||
59 | void __attribute__((naked)) __div0(void) | ||
60 | { | ||
61 | asm volatile ( | ||
62 | "ldr r0, [sp] \r\n" | ||
63 | "mov r1, #3 \r\n" | ||
64 | "b UIE \r\n" | ||
65 | ); | ||
66 | } | ||