My Devcon 2008 contribution: port for Philips GoGear HDD1630 (PP5022-based). Current...
[Rockbox.git] / firmware / panic.c
blobfbb6afc57704a74a1f21955faf69305e5f41f688
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by wavey@wavey.org
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <string.h>
24 #include "panic.h"
25 #include "lcd.h"
26 #include "font.h"
27 #include "debug.h"
28 #include "led.h"
29 #include "power.h"
30 #include "system.h"
32 static char panic_buf[128];
35 * "Dude. This is pretty fucked-up, right here."
37 void panicf( const char *fmt, ...)
39 va_list ap;
41 #ifndef SIMULATOR
42 #if (CONFIG_LED == LED_REAL)
43 bool state = false;
44 int i = 0;
45 #endif
47 /* Disable interrupts */
48 #ifdef CPU_ARM
49 disable_fiq();
50 #endif
52 set_irq_level(DISABLE_INTERRUPTS);
53 #endif /* SIMULATOR */
55 va_start( ap, fmt );
56 vsnprintf( panic_buf, sizeof(panic_buf), fmt, ap );
57 va_end( ap );
59 #ifdef HAVE_LCD_CHARCELLS
60 lcd_double_height(false);
61 lcd_puts(0, 0, "*PANIC*");
62 lcd_puts(0, 1, panic_buf);
63 #elif defined(HAVE_LCD_BITMAP)
64 lcd_clear_display();
65 lcd_setfont(FONT_SYSFIXED);
66 lcd_puts(0, 0, (unsigned char *)"*PANIC*");
68 /* wrap panic line */
69 int i, y=1, len = strlen(panic_buf);
70 for (i=0; i<len; i+=18) {
71 unsigned char c = panic_buf[i+18];
72 panic_buf[i+18] = 0;
73 lcd_puts(0, y++, (unsigned char *)panic_buf+i);
74 panic_buf[i+18] = c;
77 #else
78 /* no LCD */
79 #endif
80 lcd_update();
81 DEBUGF(panic_buf);
83 set_cpu_frequency(0);
85 #ifdef HAVE_ATA_POWER_OFF
86 ide_power_enable(false);
87 #endif
89 while (1)
91 #ifndef SIMULATOR
92 #if (CONFIG_LED == LED_REAL)
93 if (--i <= 0)
95 state = !state;
96 led(state);
97 i = 240000;
99 #endif
101 /* try to restart firmware if ON is pressed */
102 #if defined (CPU_PP)
103 /* For now, just sleep the core */
104 sleep_core(CURRENT_CORE);
105 #define system_reboot() nop
106 #elif defined (TOSHIBA_GIGABEAT_F)
107 if ((GPGDAT & (1 << 0)) != 0)
108 #elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
109 if ((GPIO1_READ & 0x22) == 0) /* check for ON button and !hold */
110 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
111 if ((GPIO_READ & 0x0c000000) == 0x08000000) /* check for ON button and !hold */
112 #elif defined(IAUDIO_M3)
113 if ((GPIO1_READ & 0x202) == 0x200) /* check for ON button and !hold */
114 #elif defined(COWON_D2)
115 if (GPIOA & 0x10) /* check for power button */
116 #elif CONFIG_CPU == SH7034
117 #if CONFIG_KEYPAD == PLAYER_PAD
118 if (!(PADRL & 0x20))
119 #elif CONFIG_KEYPAD == RECORDER_PAD
120 #ifdef HAVE_FMADC
121 if (!(PCDR & 0x0008))
122 #else
123 if (!(PBDRH & 0x01))
124 #endif
125 #elif CONFIG_KEYPAD == ONDIO_PAD
126 if (!(PCDR & 0x0008))
127 #endif /* CONFIG_KEYPAD */
128 #elif defined(CREATIVE_ZVx)
129 if(false)
130 #endif /* CPU */
131 system_reboot();
132 #endif /* !SIMULATOR */