summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/as3525/system-as3525.c5
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/system-imx31.c10
-rw-r--r--firmware/target/arm/pnx0101/system-pnx0101.c5
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/system-meg-fx.c6
-rw-r--r--firmware/target/arm/s5l8700/system-s5l8700.c5
-rw-r--r--firmware/target/arm/system-arm.c66
-rw-r--r--firmware/target/arm/system-pp5002.c12
-rw-r--r--firmware/target/arm/system-pp502x.c11
-rw-r--r--firmware/target/arm/tcc77x/system-tcc77x.c5
-rw-r--r--firmware/target/arm/tcc780x/system-tcc780x.c5
-rw-r--r--firmware/target/coldfire/system-coldfire.c21
-rw-r--r--firmware/target/mips/ingenic_jz47xx/system-jz4740.c10
-rw-r--r--firmware/target/sh/system-sh.c74
13 files changed, 194 insertions, 41 deletions
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
282void system_exception_wait(void)
283{
284 while (1);
285}
286
282int system_memory_guard(int newmode) 287int 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
66void system_reboot(void) 66void system_reboot(void)
67{ 67{
68 /* Multi-context so no SPI available (WDT?) */
69 while (1);
70}
71
72void 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
70void system_init(void) 80void 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
308void system_exception_wait(void)
309{
310 while (1);
311}
312
308int system_memory_guard(int newmode) 313int 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
114void system_exception_wait(void)
115{
116 INTMSK = 0xFFFFFFFF;
117 while (GPGDAT & (1 << 0)) == 0); /* Wait for power button */
118}
119
114static void set_page_tables(void) 120static 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
135void system_exception_wait(void)
136{
137 while (1);
138}
139
135int system_memory_guard(int newmode) 140int 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
27static 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 */
37void __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 */
59void __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)
203void system_reboot(void) 203void system_reboot(void)
204{ 204{
205 DEV_RS |= 4; 205 DEV_RS |= 4;
206 while (1);
207}
208
209void 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
208int system_memory_guard(int newmode) 220int 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
458void 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
458int system_memory_guard(int newmode) 469int 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
61void 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
290void system_exception_wait(void)
291{
292 while ((GPIOA & 0x10) == 0); /* check for power button */
293}
294
290int system_memory_guard(int newmode) 295int 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
292void 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. */
298int system_memory_guard(int newmode) 301int 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
890void 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
890void power_off(void) 900void 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 */
283void UIE (unsigned int pc) __attribute__((section(".text"))); 283void UIE (unsigned int pc) __attribute__((section(".text")));
284void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */ 284void 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
339void system_init(void) 313void 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
355void 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. */
382int system_memory_guard(int newmode) 392int system_memory_guard(int newmode)
383{ 393{