diff options
-rw-r--r-- | firmware/SOURCES | 1 | ||||
-rw-r--r-- | firmware/export/system.h | 3 | ||||
-rw-r--r-- | firmware/panic.c | 72 | ||||
-rw-r--r-- | firmware/system.c | 58 | ||||
-rw-r--r-- | firmware/target/arm/as3525/system-as3525.c | 5 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/system-imx31.c | 10 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/system-pnx0101.c | 5 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c | 6 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/system-s5l8700.c | 5 | ||||
-rw-r--r-- | firmware/target/arm/system-arm.c | 66 | ||||
-rw-r--r-- | firmware/target/arm/system-pp5002.c | 12 | ||||
-rw-r--r-- | firmware/target/arm/system-pp502x.c | 11 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/system-tcc77x.c | 5 | ||||
-rw-r--r-- | firmware/target/arm/tcc780x/system-tcc780x.c | 5 | ||||
-rw-r--r-- | firmware/target/coldfire/system-coldfire.c | 21 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/system-jz4740.c | 10 | ||||
-rw-r--r-- | firmware/target/sh/system-sh.c | 74 | ||||
-rw-r--r-- | uisimulator/common/stubs.c | 10 |
18 files changed, 220 insertions, 159 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index c8f824a849..f4d86bc2cd 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -326,6 +326,7 @@ target/arm/memset16-arm.S | |||
326 | #ifdef HAVE_PRIORITY_SCHEDULING | 326 | #ifdef HAVE_PRIORITY_SCHEDULING |
327 | target/arm/ffs-arm.S | 327 | target/arm/ffs-arm.S |
328 | #endif | 328 | #endif |
329 | target/arm/system-arm.c | ||
329 | #if CONFIG_I2C == I2C_PP5024 || CONFIG_I2C == I2C_PP5020 || CONFIG_I2C == I2C_PP5002 | 330 | #if CONFIG_I2C == I2C_PP5024 || CONFIG_I2C == I2C_PP5020 || CONFIG_I2C == I2C_PP5002 |
330 | target/arm/i2c-pp.c | 331 | target/arm/i2c-pp.c |
331 | #elif CONFIG_I2C == I2C_PNX0101 | 332 | #elif CONFIG_I2C == I2C_PNX0101 |
diff --git a/firmware/export/system.h b/firmware/export/system.h index b82e2b1ad0..8ebd30ac4e 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h | |||
@@ -27,6 +27,9 @@ | |||
27 | #include "kernel.h" | 27 | #include "kernel.h" |
28 | 28 | ||
29 | extern void system_reboot (void); | 29 | extern void system_reboot (void); |
30 | /* Called from any UIE handler and panicf - wait for a key and return | ||
31 | * to reboot system. */ | ||
32 | extern void system_exception_wait(void); | ||
30 | extern void system_init(void); | 33 | extern void system_init(void); |
31 | 34 | ||
32 | extern long cpu_frequency; | 35 | extern long cpu_frequency; |
diff --git a/firmware/panic.c b/firmware/panic.c index 8fcdd24188..0223dc1494 100644 --- a/firmware/panic.c +++ b/firmware/panic.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "system.h" | 32 | #include "system.h" |
33 | 33 | ||
34 | static char panic_buf[128]; | 34 | static char panic_buf[128]; |
35 | #define LINECHARS (LCD_WIDTH/SYSFONT_WIDTH) | ||
35 | 36 | ||
36 | /* | 37 | /* |
37 | * "Dude. This is pretty fucked-up, right here." | 38 | * "Dude. This is pretty fucked-up, right here." |
@@ -41,17 +42,12 @@ void panicf( const char *fmt, ...) | |||
41 | va_list ap; | 42 | va_list ap; |
42 | 43 | ||
43 | #ifndef SIMULATOR | 44 | #ifndef SIMULATOR |
44 | #if (CONFIG_LED == LED_REAL) | ||
45 | bool state = false; | ||
46 | int i = 0; | ||
47 | #endif | ||
48 | |||
49 | /* Disable interrupts */ | 45 | /* Disable interrupts */ |
50 | #ifdef CPU_ARM | 46 | #ifdef CPU_ARM |
51 | disable_fiq(); | 47 | disable_interrupt(IRQ_FIQ_STATUS); |
52 | #endif | 48 | #else |
53 | |||
54 | set_irq_level(DISABLE_INTERRUPTS); | 49 | set_irq_level(DISABLE_INTERRUPTS); |
50 | #endif | ||
55 | #endif /* SIMULATOR */ | 51 | #endif /* SIMULATOR */ |
56 | 52 | ||
57 | va_start( ap, fmt ); | 53 | va_start( ap, fmt ); |
@@ -69,12 +65,11 @@ void panicf( const char *fmt, ...) | |||
69 | { | 65 | { |
70 | /* wrap panic line */ | 66 | /* wrap panic line */ |
71 | int i, y=1, len = strlen(panic_buf); | 67 | int i, y=1, len = strlen(panic_buf); |
72 | #define STEP (LCD_WIDTH/SYSFONT_WIDTH) | 68 | for (i=0; i<len; i+=LINECHARS) { |
73 | for (i=0; i<len; i+=STEP) { | 69 | unsigned char c = panic_buf[i+LINECHARS]; |
74 | unsigned char c = panic_buf[i+STEP]; | 70 | panic_buf[i+LINECHARS] = 0; |
75 | panic_buf[i+STEP] = 0; | ||
76 | lcd_puts(0, y++, (unsigned char *)panic_buf+i); | 71 | lcd_puts(0, y++, (unsigned char *)panic_buf+i); |
77 | panic_buf[i+STEP] = c; | 72 | panic_buf[i+LINECHARS] = c; |
78 | } | 73 | } |
79 | } | 74 | } |
80 | #else | 75 | #else |
@@ -89,52 +84,7 @@ void panicf( const char *fmt, ...) | |||
89 | ide_power_enable(false); | 84 | ide_power_enable(false); |
90 | #endif | 85 | #endif |
91 | 86 | ||
92 | while (1) | 87 | system_exception_wait(); /* if this returns, try to reboot */ |
93 | { | 88 | system_reboot(); |
94 | #ifndef SIMULATOR | 89 | while (1); /* halt */ |
95 | #if (CONFIG_LED == LED_REAL) | ||
96 | if (--i <= 0) | ||
97 | { | ||
98 | state = !state; | ||
99 | led(state); | ||
100 | i = 240000; | ||
101 | } | ||
102 | #endif | ||
103 | |||
104 | /* try to restart firmware if ON is pressed */ | ||
105 | #if defined (CPU_PP) | ||
106 | /* For now, just sleep the core */ | ||
107 | sleep_core(CURRENT_CORE); | ||
108 | #define system_reboot() nop | ||
109 | #elif defined (TOSHIBA_GIGABEAT_F) | ||
110 | if ((GPGDAT & (1 << 0)) != 0) | ||
111 | #elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) | ||
112 | if ((GPIO1_READ & 0x22) == 0) /* check for ON button and !hold */ | ||
113 | #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) | ||
114 | if ((GPIO_READ & 0x0c000000) == 0x08000000) /* check for ON button and !hold */ | ||
115 | #elif defined(IAUDIO_M3) | ||
116 | if ((GPIO1_READ & 0x202) == 0x200) /* check for ON button and !hold */ | ||
117 | #elif defined(COWON_D2) | ||
118 | if (GPIOA & 0x10) /* check for power button */ | ||
119 | #elif CONFIG_CPU == SH7034 | ||
120 | #if CONFIG_KEYPAD == PLAYER_PAD | ||
121 | if (!(PADRL & 0x20)) | ||
122 | #elif CONFIG_KEYPAD == RECORDER_PAD | ||
123 | #ifdef HAVE_FMADC | ||
124 | if (!(PCDR & 0x0008)) | ||
125 | #else | ||
126 | if (!(PBDRH & 0x01)) | ||
127 | #endif | ||
128 | #elif CONFIG_KEYPAD == ONDIO_PAD | ||
129 | if (!(PCDR & 0x0008)) | ||
130 | #endif /* CONFIG_KEYPAD */ | ||
131 | #elif defined(CREATIVE_ZVx) | ||
132 | if(false) | ||
133 | #elif defined(ONDA_VX747) | ||
134 | /* check for power button without including any .h file */ | ||
135 | if( (~(*(volatile unsigned int *)(0xB0010300))) & (1 << 29) ) | ||
136 | #endif /* CPU */ | ||
137 | system_reboot(); | ||
138 | #endif /* !SIMULATOR */ | ||
139 | } | ||
140 | } | 90 | } |
diff --git a/firmware/system.c b/firmware/system.c index ada99e0b56..befc785823 100644 --- a/firmware/system.c +++ b/firmware/system.c | |||
@@ -18,16 +18,11 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include <stdio.h> | ||
22 | #include "config.h" | 21 | #include "config.h" |
23 | #include <stdbool.h> | ||
24 | #include "lcd.h" | ||
25 | #include "font.h" | ||
26 | #include "system.h" | 22 | #include "system.h" |
23 | #include <stdio.h> | ||
27 | #include "kernel.h" | 24 | #include "kernel.h" |
28 | #include "thread.h" | 25 | #include "thread.h" |
29 | #include "timer.h" | ||
30 | #include "inttypes.h" | ||
31 | #include "string.h" | 26 | #include "string.h" |
32 | 27 | ||
33 | #ifndef SIMULATOR | 28 | #ifndef SIMULATOR |
@@ -226,54 +221,3 @@ bool detect_original_firmware(void) | |||
226 | return !(detect_flashed_ramimage() || detect_flashed_romimage()); | 221 | return !(detect_flashed_ramimage() || detect_flashed_romimage()); |
227 | } | 222 | } |
228 | 223 | ||
229 | #if defined(CPU_ARM) | ||
230 | |||
231 | static const char* const uiename[] = { | ||
232 | "Undefined instruction", | ||
233 | "Prefetch abort", | ||
234 | "Data abort", | ||
235 | "Divide by zero" | ||
236 | }; | ||
237 | |||
238 | /* Unexpected Interrupt or Exception handler. Currently only deals with | ||
239 | exceptions, but will deal with interrupts later. | ||
240 | */ | ||
241 | void UIE(unsigned int pc, unsigned int num) __attribute__((noreturn)); | ||
242 | void UIE(unsigned int pc, unsigned int num) | ||
243 | { | ||
244 | char str[32]; | ||
245 | |||
246 | lcd_clear_display(); | ||
247 | #ifdef HAVE_LCD_BITMAP | ||
248 | lcd_setfont(FONT_SYSFIXED); | ||
249 | #endif | ||
250 | lcd_puts(0, 0, uiename[num]); | ||
251 | snprintf(str, sizeof(str), "at %08x" IF_COP(" (%d)"), pc | ||
252 | IF_COP(, CURRENT_CORE)); | ||
253 | lcd_puts(0, 1, str); | ||
254 | lcd_update(); | ||
255 | |||
256 | while (1) | ||
257 | { | ||
258 | /* TODO: perhaps add button handling in here when we get a polling | ||
259 | driver some day. | ||
260 | */ | ||
261 | core_idle(); | ||
262 | } | ||
263 | } | ||
264 | |||
265 | #ifndef STUB | ||
266 | /* Needs to be here or gcc won't find it */ | ||
267 | void __div0(void) __attribute__((naked)); | ||
268 | void __div0(void) | ||
269 | { | ||
270 | asm volatile ( | ||
271 | "ldr r0, [sp] \r\n" | ||
272 | "mov r1, #3 \r\n" | ||
273 | "b UIE \r\n" | ||
274 | ); | ||
275 | } | ||
276 | #endif | ||
277 | |||
278 | #endif /* CPU_ARM */ | ||
279 | |||
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index b502b22425..c8366fe2bf 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c | |||
@@ -279,6 +279,11 @@ void system_reboot(void) | |||
279 | while(1); | 279 | while(1); |
280 | } | 280 | } |
281 | 281 | ||
282 | void system_exception_wait(void) | ||
283 | { | ||
284 | while (1); | ||
285 | } | ||
286 | |||
282 | int system_memory_guard(int newmode) | 287 | int system_memory_guard(int newmode) |
283 | { | 288 | { |
284 | (void)newmode; | 289 | (void)newmode; |
diff --git a/firmware/target/arm/imx31/gigabeat-s/system-imx31.c b/firmware/target/arm/imx31/gigabeat-s/system-imx31.c index 1e084485ac..c339f4fe7c 100644 --- a/firmware/target/arm/imx31/gigabeat-s/system-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/system-imx31.c | |||
@@ -65,6 +65,16 @@ int system_memory_guard(int newmode) | |||
65 | 65 | ||
66 | void system_reboot(void) | 66 | void system_reboot(void) |
67 | { | 67 | { |
68 | /* Multi-context so no SPI available (WDT?) */ | ||
69 | while (1); | ||
70 | } | ||
71 | |||
72 | void system_exception_wait(void) | ||
73 | { | ||
74 | /* Called in many contexts so button reading may be a chore */ | ||
75 | avic_disable_int(ALL); | ||
76 | core_idle(); | ||
77 | while (1); | ||
68 | } | 78 | } |
69 | 79 | ||
70 | void system_init(void) | 80 | void system_init(void) |
diff --git a/firmware/target/arm/pnx0101/system-pnx0101.c b/firmware/target/arm/pnx0101/system-pnx0101.c index f447f5f044..63720d11be 100644 --- a/firmware/target/arm/pnx0101/system-pnx0101.c +++ b/firmware/target/arm/pnx0101/system-pnx0101.c | |||
@@ -305,6 +305,11 @@ void system_reboot(void) | |||
305 | while (1); | 305 | while (1); |
306 | } | 306 | } |
307 | 307 | ||
308 | void system_exception_wait(void) | ||
309 | { | ||
310 | while (1); | ||
311 | } | ||
312 | |||
308 | int system_memory_guard(int newmode) | 313 | int system_memory_guard(int newmode) |
309 | { | 314 | { |
310 | (void)newmode; | 315 | (void)newmode; |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c index 43e2c408a2..61b4653726 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c | |||
@@ -111,6 +111,12 @@ void system_reboot(void) | |||
111 | ; | 111 | ; |
112 | } | 112 | } |
113 | 113 | ||
114 | void system_exception_wait(void) | ||
115 | { | ||
116 | INTMSK = 0xFFFFFFFF; | ||
117 | while (GPGDAT & (1 << 0)) == 0); /* Wait for power button */ | ||
118 | } | ||
119 | |||
114 | static void set_page_tables(void) | 120 | static void set_page_tables(void) |
115 | { | 121 | { |
116 | map_section(0, 0, 0x1000, CACHE_NONE); /* map every memory region to itself */ | 122 | map_section(0, 0, 0x1000, CACHE_NONE); /* map every memory region to itself */ |
diff --git a/firmware/target/arm/s5l8700/system-s5l8700.c b/firmware/target/arm/s5l8700/system-s5l8700.c index 1370db40d7..c535a0d955 100644 --- a/firmware/target/arm/s5l8700/system-s5l8700.c +++ b/firmware/target/arm/s5l8700/system-s5l8700.c | |||
@@ -132,6 +132,11 @@ void system_reboot(void) | |||
132 | { | 132 | { |
133 | } | 133 | } |
134 | 134 | ||
135 | void system_exception_wait(void) | ||
136 | { | ||
137 | while (1); | ||
138 | } | ||
139 | |||
135 | int system_memory_guard(int newmode) | 140 | int system_memory_guard(int newmode) |
136 | { | 141 | { |
137 | (void)newmode; | 142 | (void)newmode; |
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 | } | ||
diff --git a/firmware/target/arm/system-pp5002.c b/firmware/target/arm/system-pp5002.c index b9a937c6e8..1b37d3303f 100644 --- a/firmware/target/arm/system-pp5002.c +++ b/firmware/target/arm/system-pp5002.c | |||
@@ -203,6 +203,18 @@ void system_init(void) | |||
203 | void system_reboot(void) | 203 | void system_reboot(void) |
204 | { | 204 | { |
205 | DEV_RS |= 4; | 205 | DEV_RS |= 4; |
206 | while (1); | ||
207 | } | ||
208 | |||
209 | void system_exception_wait(void) | ||
210 | { | ||
211 | /* FIXME: we just need the right buttons */ | ||
212 | CPU_INT_DIS = -1; | ||
213 | COP_INT_DIS = -1; | ||
214 | |||
215 | /* Halt */ | ||
216 | sleep_core(CURRENT_CORE); | ||
217 | while (1); | ||
206 | } | 218 | } |
207 | 219 | ||
208 | int system_memory_guard(int newmode) | 220 | int system_memory_guard(int newmode) |
diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index b1f178c8d5..277b1e9a0b 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c | |||
@@ -455,6 +455,17 @@ void system_reboot(void) | |||
455 | while (1); | 455 | while (1); |
456 | } | 456 | } |
457 | 457 | ||
458 | void system_exception_wait(void) | ||
459 | { | ||
460 | /* FIXME: we just need the right buttons */ | ||
461 | CPU_INT_DIS = -1; | ||
462 | COP_INT_DIS = -1; | ||
463 | |||
464 | /* Halt */ | ||
465 | PROC_CTL(CURRENT_CORE) = 0x40000000; | ||
466 | while (1); | ||
467 | } | ||
468 | |||
458 | int system_memory_guard(int newmode) | 469 | int system_memory_guard(int newmode) |
459 | { | 470 | { |
460 | (void)newmode; | 471 | (void)newmode; |
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c index 0896026b55..90e53afb14 100644 --- a/firmware/target/arm/tcc77x/system-tcc77x.c +++ b/firmware/target/arm/tcc77x/system-tcc77x.c | |||
@@ -58,6 +58,11 @@ void system_reboot(void) | |||
58 | { | 58 | { |
59 | } | 59 | } |
60 | 60 | ||
61 | void system_exception_wait(void) | ||
62 | { | ||
63 | while (1); | ||
64 | } | ||
65 | |||
61 | /* TODO - these should live in the target-specific directories and | 66 | /* TODO - these should live in the target-specific directories and |
62 | once we understand what all the GPIO pins do, move the init to the | 67 | once we understand what all the GPIO pins do, move the init to the |
63 | specific driver for that hardware. For now, we just perform the | 68 | specific driver for that hardware. For now, we just perform the |
diff --git a/firmware/target/arm/tcc780x/system-tcc780x.c b/firmware/target/arm/tcc780x/system-tcc780x.c index 5ecbbdac7c..bf3c64cd7a 100644 --- a/firmware/target/arm/tcc780x/system-tcc780x.c +++ b/firmware/target/arm/tcc780x/system-tcc780x.c | |||
@@ -287,6 +287,11 @@ void system_reboot(void) | |||
287 | while (1); | 287 | while (1); |
288 | } | 288 | } |
289 | 289 | ||
290 | void system_exception_wait(void) | ||
291 | { | ||
292 | while ((GPIOA & 0x10) == 0); /* check for power button */ | ||
293 | } | ||
294 | |||
290 | int system_memory_guard(int newmode) | 295 | int system_memory_guard(int newmode) |
291 | { | 296 | { |
292 | (void)newmode; | 297 | (void)newmode; |
diff --git a/firmware/target/coldfire/system-coldfire.c b/firmware/target/coldfire/system-coldfire.c index e04255746f..c4651a3c80 100644 --- a/firmware/target/coldfire/system-coldfire.c +++ b/firmware/target/coldfire/system-coldfire.c | |||
@@ -177,16 +177,11 @@ static void system_display_exception_info(unsigned long format, | |||
177 | lcd_puts(0, 1, str); | 177 | lcd_puts(0, 1, str); |
178 | lcd_update(); | 178 | lcd_update(); |
179 | 179 | ||
180 | /* set cpu frequency to 11mhz (to prevent overheating) */ | 180 | system_exception_wait(); |
181 | DCR = (DCR & ~0x01ff) | 1; | ||
182 | PLLCR = EXCP_PLLCR; | ||
183 | 181 | ||
184 | while (1) | 182 | /* Start watchdog timer with 512 cycles timeout. Don't service it. */ |
185 | { | 183 | SYPCR = 0xc0; |
186 | if ((EXCP_BUTTON_GPIO_READ & EXCP_BUTTON_MASK) == EXCP_BUTTON_VALUE) | 184 | while (1); |
187 | SYPCR = 0xc0; | ||
188 | /* Start watchdog timer with 512 cycles timeout. Don't service it. */ | ||
189 | } | ||
190 | 185 | ||
191 | /* We need a reset method that works in all cases. Calling system_reboot() | 186 | /* We need a reset method that works in all cases. Calling system_reboot() |
192 | doesn't work when we're called from the debug interrupt, because then | 187 | doesn't work when we're called from the debug interrupt, because then |
@@ -294,6 +289,14 @@ void system_reboot (void) | |||
294 | asm(" jmp (%a0)"); | 289 | asm(" jmp (%a0)"); |
295 | } | 290 | } |
296 | 291 | ||
292 | void system_exception_wait(void) | ||
293 | { | ||
294 | /* set cpu frequency to 11mhz (to prevent overheating) */ | ||
295 | DCR = (DCR & ~0x01ff) | 1; | ||
296 | PLLCR = EXCP_PLLCR; | ||
297 | while ((EXCP_BUTTON_GPIO_READ & EXCP_BUTTON_MASK) != EXCP_BUTTON_VALUE); | ||
298 | } | ||
299 | |||
297 | /* Utilise the breakpoint hardware to catch invalid memory accesses. */ | 300 | /* Utilise the breakpoint hardware to catch invalid memory accesses. */ |
298 | int system_memory_guard(int newmode) | 301 | int system_memory_guard(int newmode) |
299 | { | 302 | { |
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c index c741d9f311..033b42214b 100644 --- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c | |||
@@ -887,6 +887,16 @@ void system_reboot(void) | |||
887 | while (1); | 887 | while (1); |
888 | } | 888 | } |
889 | 889 | ||
890 | void system_exception_wait(void) | ||
891 | { | ||
892 | /* check for power button without including any .h file */ | ||
893 | while (1) | ||
894 | { | ||
895 | if( (~(*(volatile unsigned int *)(0xB0010300))) & (1 << 29) ) | ||
896 | break; | ||
897 | } | ||
898 | } | ||
899 | |||
890 | void power_off(void) | 900 | void power_off(void) |
891 | { | 901 | { |
892 | /* Put system into hibernate mode */ | 902 | /* Put system into hibernate mode */ |
diff --git a/firmware/target/sh/system-sh.c b/firmware/target/sh/system-sh.c index 63703ab786..02af40282f 100644 --- a/firmware/target/sh/system-sh.c +++ b/firmware/target/sh/system-sh.c | |||
@@ -283,10 +283,6 @@ extern void UIE4(void); /* needed for calculating the UIE number */ | |||
283 | void UIE (unsigned int pc) __attribute__((section(".text"))); | 283 | void UIE (unsigned int pc) __attribute__((section(".text"))); |
284 | void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */ | 284 | void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */ |
285 | { | 285 | { |
286 | #if CONFIG_LED == LED_REAL | ||
287 | bool state = false; | ||
288 | int i = 0; | ||
289 | #endif | ||
290 | unsigned int n; | 286 | unsigned int n; |
291 | char str[32]; | 287 | char str[32]; |
292 | 288 | ||
@@ -305,35 +301,13 @@ void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */ | |||
305 | lcd_puts(0,1,str); | 301 | lcd_puts(0,1,str); |
306 | lcd_update (); | 302 | lcd_update (); |
307 | 303 | ||
308 | while (1) | 304 | /* try to restart firmware if ON is pressed */ |
309 | { | 305 | system_exception_wait(); |
310 | #if CONFIG_LED == LED_REAL | ||
311 | if (--i <= 0) | ||
312 | { | ||
313 | state = !state; | ||
314 | led(state); | ||
315 | i = 240000; | ||
316 | } | ||
317 | #endif | ||
318 | 306 | ||
319 | /* try to restart firmware if ON is pressed */ | 307 | /* enable the watchguard timer, but don't service it */ |
320 | #if CONFIG_KEYPAD == PLAYER_PAD | 308 | RSTCSR_W = 0x5a40; /* Reset enabled, power-on reset */ |
321 | if (!(PADRL & 0x20)) | 309 | TCSR_W = 0xa560; /* Watchdog timer mode, timer enabled, sysclk/2 */ |
322 | #elif CONFIG_KEYPAD == RECORDER_PAD | 310 | while (1); |
323 | #ifdef HAVE_FMADC | ||
324 | if (!(PCDR & 0x0008)) | ||
325 | #else | ||
326 | if (!(PBDRH & 0x01)) | ||
327 | #endif | ||
328 | #elif CONFIG_KEYPAD == ONDIO_PAD | ||
329 | if (!(PCDR & 0x0008)) | ||
330 | #endif | ||
331 | { | ||
332 | /* enable the watchguard timer, but don't service it */ | ||
333 | RSTCSR_W = 0x5a40; /* Reset enabled, power-on reset */ | ||
334 | TCSR_W = 0xa560; /* Watchdog timer mode, timer enabled, sysclk/2 */ | ||
335 | } | ||
336 | } | ||
337 | } | 311 | } |
338 | 312 | ||
339 | void system_init(void) | 313 | void system_init(void) |
@@ -378,6 +352,42 @@ void system_reboot (void) | |||
378 | "r"(*(int*)0),"r"(4)); | 352 | "r"(*(int*)0),"r"(4)); |
379 | } | 353 | } |
380 | 354 | ||
355 | void system_exception_wait(void) | ||
356 | { | ||
357 | #if (CONFIG_LED == LED_REAL) | ||
358 | bool state = false; | ||
359 | int i = 0; | ||
360 | #endif | ||
361 | |||
362 | while (1) | ||
363 | { | ||
364 | #if (CONFIG_LED == LED_REAL) | ||
365 | if (--i <= 0) | ||
366 | { | ||
367 | state = !state; | ||
368 | led(state); | ||
369 | i = 240000; | ||
370 | } | ||
371 | #endif | ||
372 | |||
373 | #if CONFIG_KEYPAD == PLAYER_PAD | ||
374 | /* Player */ | ||
375 | if (!(PADRL & 0x20)) | ||
376 | #elif CONFIG_KEYPAD == RECORDER_PAD | ||
377 | /* Recorder */ | ||
378 | #ifdef HAVE_FMADC | ||
379 | if (!(PCDR & 0x0008)) | ||
380 | #else | ||
381 | if (!(PBDRH & 0x01)) | ||
382 | #endif | ||
383 | #elif CONFIG_KEYPAD == ONDIO_PAD | ||
384 | /* Ondio */ | ||
385 | if (!(PCDR & 0x0008)) | ||
386 | #endif /* CONFIG_KEYPAD */ | ||
387 | return; | ||
388 | } | ||
389 | } | ||
390 | |||
381 | /* Utilise the user break controller to catch invalid memory accesses. */ | 391 | /* Utilise the user break controller to catch invalid memory accesses. */ |
382 | int system_memory_guard(int newmode) | 392 | int system_memory_guard(int newmode) |
383 | { | 393 | { |
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index f50425b494..12b6f293a4 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c | |||
@@ -340,6 +340,16 @@ void touchpad_set_sensitivity(int level) | |||
340 | } | 340 | } |
341 | #endif | 341 | #endif |
342 | 342 | ||
343 | void system_exception_wait(void) | ||
344 | { | ||
345 | while(1); | ||
346 | } | ||
347 | |||
348 | void system_reboot(void) | ||
349 | { | ||
350 | while(1); | ||
351 | } | ||
352 | |||
343 | /* assure an unused place to direct virtual pointers to */ | 353 | /* assure an unused place to direct virtual pointers to */ |
344 | #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */ | 354 | #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */ |
345 | unsigned char vp_dummy[VIRT_SIZE]; | 355 | unsigned char vp_dummy[VIRT_SIZE]; |