Remove .a files before running ar, to avoid problems with renamed files remaining...
[kugel-rb.git] / firmware / panic.c
blob8fcdd24188c731cf34206248e980461620ccbece
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by wavey@wavey.org
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "config.h"
23 #include <stdio.h>
24 #include <stdarg.h>
25 #include <string.h>
26 #include "panic.h"
27 #include "lcd.h"
28 #include "font.h"
29 #include "debug.h"
30 #include "led.h"
31 #include "power.h"
32 #include "system.h"
34 static char panic_buf[128];
37 * "Dude. This is pretty fucked-up, right here."
39 void panicf( const char *fmt, ...)
41 va_list ap;
43 #ifndef SIMULATOR
44 #if (CONFIG_LED == LED_REAL)
45 bool state = false;
46 int i = 0;
47 #endif
49 /* Disable interrupts */
50 #ifdef CPU_ARM
51 disable_fiq();
52 #endif
54 set_irq_level(DISABLE_INTERRUPTS);
55 #endif /* SIMULATOR */
57 va_start( ap, fmt );
58 vsnprintf( panic_buf, sizeof(panic_buf), fmt, ap );
59 va_end( ap );
61 #ifdef HAVE_LCD_CHARCELLS
62 lcd_double_height(false);
63 lcd_puts(0, 0, "*PANIC*");
64 lcd_puts(0, 1, panic_buf);
65 #elif defined(HAVE_LCD_BITMAP)
66 lcd_clear_display();
67 lcd_setfont(FONT_SYSFIXED);
68 lcd_puts(0, 0, (unsigned char *)"*PANIC*");
70 /* wrap panic line */
71 int i, y=1, len = strlen(panic_buf);
72 #define STEP (LCD_WIDTH/SYSFONT_WIDTH)
73 for (i=0; i<len; i+=STEP) {
74 unsigned char c = panic_buf[i+STEP];
75 panic_buf[i+STEP] = 0;
76 lcd_puts(0, y++, (unsigned char *)panic_buf+i);
77 panic_buf[i+STEP] = c;
80 #else
81 /* no LCD */
82 #endif
83 lcd_update();
84 DEBUGF("%s", panic_buf);
86 set_cpu_frequency(0);
88 #ifdef HAVE_ATA_POWER_OFF
89 ide_power_enable(false);
90 #endif
92 while (1)
94 #ifndef SIMULATOR
95 #if (CONFIG_LED == LED_REAL)
96 if (--i <= 0)
98 state = !state;
99 led(state);
100 i = 240000;
102 #endif
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 */