Correct compiler errors from last commit.
[Rockbox.git] / firmware / panic.c
blob07b7a5f4ded59f68a76bc36f075e945912ab5bd9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by wavey@wavey.org
11 *nn
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 = true;
44 #endif
46 /* Disable interrupts */
47 #if CONFIG_CPU == SH7034
48 asm volatile ("ldc\t%0,sr" : : "r"(15<<4));
49 #elif defined(CPU_COLDFIRE)
50 asm volatile ("move.w #0x2700,%sr");
51 #endif
52 #endif
54 va_start( ap, fmt );
55 vsnprintf( panic_buf, sizeof(panic_buf), fmt, ap );
56 va_end( ap );
58 #ifdef HAVE_LCD_CHARCELLS
59 lcd_double_height(false);
60 lcd_puts(0, 0, "*PANIC*");
61 lcd_puts(0, 1, panic_buf);
62 #elif defined(HAVE_LCD_BITMAP)
63 lcd_clear_display();
64 lcd_setfont(FONT_SYSFIXED);
65 lcd_puts(0, 0, (unsigned char *)"*PANIC*");
67 /* wrap panic line */
68 int i, y=1, len = strlen(panic_buf);
69 for (i=0; i<len; i+=18) {
70 unsigned char c = panic_buf[i+18];
71 panic_buf[i+18] = 0;
72 lcd_puts(0, y++, (unsigned char *)panic_buf+i);
73 panic_buf[i+18] = c;
76 lcd_update();
78 #else
79 /* no LCD */
80 #endif
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 volatile long i;
94 led (state);
95 state = !state;
97 for (i = 0; i < 240000; ++i);
98 #endif
100 /* try to restart firmware if ON is pressed */
101 #ifdef IRIVER_H100_SERIES
102 if ((GPIO1_READ & 0x22) == 0) /* check for ON button and !hold */
103 #elif CONFIG_CPU == SH7034
104 #if CONFIG_KEYPAD == PLAYER_PAD
105 if (!(PADRL & 0x20))
106 #elif CONFIG_KEYPAD == RECORDER_PAD
107 #ifdef HAVE_FMADC
108 if (!(PCDR & 0x0008))
109 #else
110 if (!(PBDRH & 0x01))
111 #endif
112 #elif CONFIG_KEYPAD == ONDIO_PAD
113 if (!(PCDR & 0x0008))
114 #endif /* CONFIG_KEYPAD */
115 #endif /* CPU */
116 system_reboot();
117 #endif /* !SIMULATOR */