copy the images for the skins.
[kugel-rb.git] / firmware / panic.c
blob36eec67f124fe64ebce886d85d6ce6d34ef9a0c2
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];
35 #define LINECHARS (LCD_WIDTH/SYSFONT_WIDTH) - 2
38 * "Dude. This is pretty fucked-up, right here."
40 void panicf( const char *fmt, ...)
42 va_list ap;
44 #ifndef SIMULATOR
45 /* Disable interrupts */
46 #ifdef CPU_ARM
47 disable_interrupt(IRQ_FIQ_STATUS);
48 #else
49 set_irq_level(DISABLE_INTERRUPTS);
50 #endif
51 #endif /* SIMULATOR */
53 va_start( ap, fmt );
54 vsnprintf( panic_buf, sizeof(panic_buf), fmt, ap );
55 va_end( ap );
57 #ifdef HAVE_LCD_CHARCELLS
58 lcd_double_height(false);
59 lcd_puts(0, 0, "*PANIC*");
60 lcd_puts(0, 1, panic_buf);
61 #elif defined(HAVE_LCD_BITMAP)
62 int y = 1;
64 #if LCD_DEPTH > 1
65 lcd_set_backdrop(NULL);
66 lcd_set_drawmode(DRMODE_SOLID);
67 lcd_set_foreground(LCD_BLACK);
68 lcd_set_background(LCD_WHITE);
69 #endif
71 lcd_clear_display();
72 lcd_setfont(FONT_SYSFIXED);
73 lcd_set_viewport(NULL);
74 lcd_puts(1, y++, (unsigned char *)"*PANIC*");
76 /* wrap panic line */
77 int i, len = strlen(panic_buf);
78 for (i=0; i<len; i+=LINECHARS) {
79 unsigned char c = panic_buf[i+LINECHARS];
80 panic_buf[i+LINECHARS] = 0;
81 lcd_puts(1, y++, (unsigned char *)panic_buf+i);
82 panic_buf[i+LINECHARS] = c;
85 #else
86 /* no LCD */
87 #endif
89 lcd_update();
90 DEBUGF("%s", panic_buf);
92 set_cpu_frequency(0);
94 #ifdef HAVE_ATA_POWER_OFF
95 ide_power_enable(false);
96 #endif
98 system_exception_wait(); /* if this returns, try to reboot */
99 system_reboot();
100 while (1); /* halt */