2002-04-30 19:23:44 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by wavey@wavey.org
|
2002-08-11 09:17:47 +00:00
|
|
|
*nn
|
2002-04-30 19:23:44 +00:00
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* 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];
|
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
|
2007-02-18 05:07:19 +00:00
|
|
|
#if (CONFIG_LED == LED_REAL)
|
2006-10-08 21:34:26 +00:00
|
|
|
bool state = false;
|
|
|
|
int i = 0;
|
2005-06-04 23:15:52 +00:00
|
|
|
#endif
|
2002-11-12 09:04:06 +00:00
|
|
|
|
2002-05-05 17:51:23 +00:00
|
|
|
/* Disable interrupts */
|
2007-05-12 05:20:04 +00:00
|
|
|
#ifdef CPU_ARM
|
|
|
|
disable_fiq();
|
2004-11-02 21:43:37 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-12 05:20:04 +00:00
|
|
|
set_irq_level(DISABLE_INTERRUPTS);
|
|
|
|
#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)
|
|
|
|
lcd_clear_display();
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
2005-11-25 00:10:12 +00:00
|
|
|
lcd_puts(0, 0, (unsigned char *)"*PANIC*");
|
2002-11-12 09:04:06 +00:00
|
|
|
{
|
|
|
|
/* wrap panic line */
|
|
|
|
int i, y=1, len = strlen(panic_buf);
|
|
|
|
for (i=0; i<len; i+=18) {
|
|
|
|
unsigned char c = panic_buf[i+18];
|
|
|
|
panic_buf[i+18] = 0;
|
2005-11-25 00:10:12 +00:00
|
|
|
lcd_puts(0, y++, (unsigned char *)panic_buf+i);
|
2002-11-12 09:04:06 +00:00
|
|
|
panic_buf[i+18] = c;
|
|
|
|
}
|
|
|
|
}
|
2002-05-05 11:17:10 +00:00
|
|
|
#else
|
|
|
|
/* no LCD */
|
|
|
|
#endif
|
2007-04-06 22:55:00 +00:00
|
|
|
lcd_update();
|
2002-05-02 14:05:51 +00:00
|
|
|
DEBUGF(panic_buf);
|
2005-09-12 10:34:27 +00:00
|
|
|
|
|
|
|
set_cpu_frequency(0);
|
|
|
|
|
|
|
|
#ifdef HAVE_ATA_POWER_OFF
|
|
|
|
ide_power_enable(false);
|
|
|
|
#endif
|
|
|
|
|
2002-11-12 09:04:06 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2005-11-09 00:54:43 +00:00
|
|
|
#ifndef SIMULATOR
|
2007-02-18 05:07:19 +00:00
|
|
|
#if (CONFIG_LED == LED_REAL)
|
2006-10-08 21:34:26 +00:00
|
|
|
if (--i <= 0)
|
|
|
|
{
|
|
|
|
state = !state;
|
|
|
|
led(state);
|
|
|
|
i = 240000;
|
|
|
|
}
|
2005-09-12 10:34:27 +00:00
|
|
|
#endif
|
2005-11-09 00:54:43 +00:00
|
|
|
|
|
|
|
/* try to restart firmware if ON is pressed */
|
2007-05-12 05:20:04 +00:00
|
|
|
#if defined (CPU_PP)
|
|
|
|
/* For now, just sleep the core */
|
2008-04-20 17:53:05 +00:00
|
|
|
sleep_core(CURRENT_CORE);
|
2007-05-12 05:20:04 +00:00
|
|
|
#define system_reboot() nop
|
|
|
|
#elif defined (TOSHIBA_GIGABEAT_F)
|
|
|
|
if ((GPGDAT & (1 << 0)) != 0)
|
2008-03-17 00:19:23 +00:00
|
|
|
#elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
|
2006-06-08 22:08:24 +00:00
|
|
|
if ((GPIO1_READ & 0x22) == 0) /* check for ON button and !hold */
|
2008-03-17 00:19:23 +00:00
|
|
|
#elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
|
|
|
|
if ((GPIO_READ & 0x0c000000) == 0x08000000) /* check for ON button and !hold */
|
|
|
|
#elif defined(IAUDIO_M3)
|
|
|
|
if ((GPIO1_READ & 0x202) == 0x200) /* check for ON button and !hold */
|
2005-09-12 10:34:27 +00:00
|
|
|
#elif CONFIG_CPU == SH7034
|
|
|
|
#if CONFIG_KEYPAD == PLAYER_PAD
|
2005-11-09 00:54:43 +00:00
|
|
|
if (!(PADRL & 0x20))
|
2005-09-12 10:34:27 +00:00
|
|
|
#elif CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
#ifdef HAVE_FMADC
|
|
|
|
if (!(PCDR & 0x0008))
|
|
|
|
#else
|
2005-11-09 00:54:43 +00:00
|
|
|
if (!(PBDRH & 0x01))
|
2005-09-12 10:34:27 +00:00
|
|
|
#endif
|
2005-11-09 00:54:43 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD
|
|
|
|
if (!(PCDR & 0x0008))
|
|
|
|
#endif /* CONFIG_KEYPAD */
|
2008-04-24 20:08:28 +00:00
|
|
|
#elif defined(CREATIVE_ZVM)
|
|
|
|
if(false)
|
2005-11-09 00:54:43 +00:00
|
|
|
#endif /* CPU */
|
2005-09-12 10:34:27 +00:00
|
|
|
system_reboot();
|
2005-11-09 00:54:43 +00:00
|
|
|
#endif /* !SIMULATOR */
|
2002-11-12 09:04:06 +00:00
|
|
|
}
|
2002-04-30 19:23:44 +00:00
|
|
|
}
|