2002-04-30 19:23:44 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by wavey@wavey.org
|
2008-05-18 16:21:52 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-04-30 19:23:44 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2005-09-12 10:34:27 +00:00
|
|
|
#include "config.h"
|
2002-04-30 19:23:44 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
2002-11-12 09:04:06 +00:00
|
|
|
#include <string.h>
|
2002-04-30 19:23:44 +00:00
|
|
|
#include "panic.h"
|
2002-05-02 14:05:51 +00:00
|
|
|
#include "lcd.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
#include "font.h"
|
2002-04-30 19:23:44 +00:00
|
|
|
#include "debug.h"
|
2002-11-12 09:04:06 +00:00
|
|
|
#include "led.h"
|
2005-09-12 10:34:27 +00:00
|
|
|
#include "power.h"
|
|
|
|
#include "system.h"
|
2002-04-30 19:23:44 +00:00
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
static char panic_buf[128];
|
2010-02-17 16:12:21 +00:00
|
|
|
#define LINECHARS (LCD_WIDTH/SYSFONT_WIDTH)
|
2002-04-30 19:23:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* "Dude. This is pretty fucked-up, right here."
|
|
|
|
*/
|
2004-08-16 23:37:23 +00:00
|
|
|
void panicf( const char *fmt, ...)
|
2002-04-30 19:23:44 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
2002-05-05 17:51:23 +00:00
|
|
|
|
2002-05-05 17:52:59 +00:00
|
|
|
#ifndef SIMULATOR
|
2002-05-05 17:51:23 +00:00
|
|
|
/* Disable interrupts */
|
2007-05-12 05:20:04 +00:00
|
|
|
#ifdef CPU_ARM
|
2009-01-08 10:15:32 +00:00
|
|
|
disable_interrupt(IRQ_FIQ_STATUS);
|
|
|
|
#else
|
2007-05-12 05:20:04 +00:00
|
|
|
set_irq_level(DISABLE_INTERRUPTS);
|
2009-01-08 10:15:32 +00:00
|
|
|
#endif
|
2007-05-12 05:20:04 +00:00
|
|
|
#endif /* SIMULATOR */
|
|
|
|
|
2002-04-30 19:23:44 +00:00
|
|
|
va_start( ap, fmt );
|
2002-05-02 11:44:15 +00:00
|
|
|
vsnprintf( panic_buf, sizeof(panic_buf), fmt, ap );
|
2002-04-30 19:23:44 +00:00
|
|
|
va_end( ap );
|
|
|
|
|
2002-05-05 11:17:10 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2002-08-08 15:32:15 +00:00
|
|
|
lcd_double_height(false);
|
2005-11-25 00:10:12 +00:00
|
|
|
lcd_puts(0, 0, "*PANIC*");
|
|
|
|
lcd_puts(0, 1, panic_buf);
|
2002-05-05 11:17:10 +00:00
|
|
|
#elif defined(HAVE_LCD_BITMAP)
|
2009-08-10 20:27:03 +00:00
|
|
|
int y = 1;
|
|
|
|
|
2009-08-10 20:36:34 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2009-08-10 20:27:03 +00:00
|
|
|
lcd_set_backdrop(NULL);
|
2009-11-14 11:27:41 +00:00
|
|
|
lcd_set_drawmode(DRMODE_SOLID);
|
2009-08-10 20:27:03 +00:00
|
|
|
lcd_set_foreground(LCD_BLACK);
|
|
|
|
lcd_set_background(LCD_WHITE);
|
|
|
|
#endif
|
|
|
|
|
2002-05-05 11:17:10 +00:00
|
|
|
lcd_clear_display();
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2009-08-18 03:55:55 +00:00
|
|
|
lcd_set_viewport(NULL);
|
2009-08-10 20:27:03 +00:00
|
|
|
lcd_puts(1, y++, (unsigned char *)"*PANIC*");
|
2002-11-12 09:04:06 +00:00
|
|
|
{
|
|
|
|
/* wrap panic line */
|
2009-08-10 20:27:03 +00:00
|
|
|
int i, len = strlen(panic_buf);
|
2009-01-08 10:15:32 +00:00
|
|
|
for (i=0; i<len; i+=LINECHARS) {
|
|
|
|
unsigned char c = panic_buf[i+LINECHARS];
|
|
|
|
panic_buf[i+LINECHARS] = 0;
|
2009-08-10 20:27:03 +00:00
|
|
|
lcd_puts(1, y++, (unsigned char *)panic_buf+i);
|
2009-01-08 10:15:32 +00:00
|
|
|
panic_buf[i+LINECHARS] = c;
|
2002-11-12 09:04:06 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-05 11:17:10 +00:00
|
|
|
#else
|
|
|
|
/* no LCD */
|
|
|
|
#endif
|
2009-07-25 18:23:06 +00:00
|
|
|
|
2007-04-06 22:55:00 +00:00
|
|
|
lcd_update();
|
2008-08-13 21:38:33 +00:00
|
|
|
DEBUGF("%s", panic_buf);
|
2005-09-12 10:34:27 +00:00
|
|
|
|
|
|
|
set_cpu_frequency(0);
|
|
|
|
|
|
|
|
#ifdef HAVE_ATA_POWER_OFF
|
|
|
|
ide_power_enable(false);
|
|
|
|
#endif
|
|
|
|
|
2009-01-08 10:15:32 +00:00
|
|
|
system_exception_wait(); /* if this returns, try to reboot */
|
|
|
|
system_reboot();
|
|
|
|
while (1); /* halt */
|
2002-04-30 19:23:44 +00:00
|
|
|
}
|