Fixed red build...
[kugel-rb.git] / firmware / panic.c
blobbc46c82824777a4366e34472348c15e9222b897d
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 <stdio.h>
21 #include <stdarg.h>
22 #include <string.h>
23 #include "panic.h"
24 #include "lcd.h"
25 #include "font.h"
26 #include "debug.h"
27 #include "led.h"
29 static char panic_buf[128];
32 * "Dude. This is pretty fucked-up, right here."
34 void panicf( const char *fmt, ...)
36 va_list ap;
38 #ifndef SIMULATOR
39 bool state = false;
41 /* Disable interrupts */
42 #if CONFIG_CPU == SH7034
43 asm volatile ("ldc\t%0,sr" : : "r"(15<<4));
44 #elif CONFIG_CPU == MCF5249
45 asm volatile ("move.w #0x2700,%sr");
46 #endif
47 #endif
49 va_start( ap, fmt );
50 vsnprintf( panic_buf, sizeof(panic_buf), fmt, ap );
51 va_end( ap );
53 #ifdef HAVE_LCD_CHARCELLS
54 lcd_double_height(false);
55 lcd_puts(0,0,"*PANIC*");
56 lcd_puts(0,1,panic_buf);
57 #elif defined(HAVE_LCD_BITMAP)
58 lcd_clear_display();
59 lcd_setfont(FONT_SYSFIXED);
60 lcd_puts(0,0,"*PANIC*");
62 /* wrap panic line */
63 int i, y=1, len = strlen(panic_buf);
64 for (i=0; i<len; i+=18) {
65 unsigned char c = panic_buf[i+18];
66 panic_buf[i+18] = 0;
67 lcd_puts(0,y++,panic_buf+i);
68 panic_buf[i+18] = c;
71 lcd_update();
73 #else
74 /* no LCD */
75 #endif
76 DEBUGF(panic_buf);
77 while (1)
79 #ifndef SIMULATOR
80 volatile long i;
81 led (state);
82 state = state?false:true;
84 for (i = 0; i < 400000; ++i);
85 #endif