Clean up panicf and introduce system_exception_wait to do further target tasks and wait for a button when an unrecoverable error has occurred (panic, UIE, etc.). Returning from that function should reboot or don't return from it. Move UIE and __div0 for ARM to its own file.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19716 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2009-01-08 10:15:32 +00:00
parent 32d9752dcc
commit 4ed78f5c72
18 changed files with 220 additions and 159 deletions

View file

@ -279,6 +279,11 @@ void system_reboot(void)
while(1);
}
void system_exception_wait(void)
{
while (1);
}
int system_memory_guard(int newmode)
{
(void)newmode;

View file

@ -65,6 +65,16 @@ int system_memory_guard(int newmode)
void system_reboot(void)
{
/* Multi-context so no SPI available (WDT?) */
while (1);
}
void system_exception_wait(void)
{
/* Called in many contexts so button reading may be a chore */
avic_disable_int(ALL);
core_idle();
while (1);
}
void system_init(void)

View file

@ -305,6 +305,11 @@ void system_reboot(void)
while (1);
}
void system_exception_wait(void)
{
while (1);
}
int system_memory_guard(int newmode)
{
(void)newmode;

View file

@ -111,6 +111,12 @@ void system_reboot(void)
;
}
void system_exception_wait(void)
{
INTMSK = 0xFFFFFFFF;
while (GPGDAT & (1 << 0)) == 0); /* Wait for power button */
}
static void set_page_tables(void)
{
map_section(0, 0, 0x1000, CACHE_NONE); /* map every memory region to itself */

View file

@ -132,6 +132,11 @@ void system_reboot(void)
{
}
void system_exception_wait(void)
{
while (1);
}
int system_memory_guard(int newmode)
{
(void)newmode;

View file

@ -0,0 +1,66 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2006 by Thom Johansen
*
* 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.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "system.h"
#include <stdio.h>
#include "lcd.h"
#include "font.h"
static const char* const uiename[] = {
"Undefined instruction",
"Prefetch abort",
"Data abort",
"Divide by zero"
};
/* Unexpected Interrupt or Exception handler. Currently only deals with
exceptions, but will deal with interrupts later.
*/
void __attribute__((noreturn)) UIE(unsigned int pc, unsigned int num)
{
char str[32];
lcd_clear_display();
#ifdef HAVE_LCD_BITMAP
lcd_setfont(FONT_SYSFIXED);
#endif
lcd_puts(0, 0, uiename[num]);
snprintf(str, sizeof(str), "at %08x" IF_COP(" (%d)"), pc
IF_COP(, CURRENT_CORE));
lcd_puts(0, 1, str);
lcd_update();
disable_interrupt(IRQ_FIQ_STATUS);
system_exception_wait(); /* If this returns, try to reboot */
system_reboot();
while (1); /* halt */
}
/* Needs to be here or gcc won't find it */
void __attribute__((naked)) __div0(void)
{
asm volatile (
"ldr r0, [sp] \r\n"
"mov r1, #3 \r\n"
"b UIE \r\n"
);
}

View file

@ -203,6 +203,18 @@ void system_init(void)
void system_reboot(void)
{
DEV_RS |= 4;
while (1);
}
void system_exception_wait(void)
{
/* FIXME: we just need the right buttons */
CPU_INT_DIS = -1;
COP_INT_DIS = -1;
/* Halt */
sleep_core(CURRENT_CORE);
while (1);
}
int system_memory_guard(int newmode)

View file

@ -455,6 +455,17 @@ void system_reboot(void)
while (1);
}
void system_exception_wait(void)
{
/* FIXME: we just need the right buttons */
CPU_INT_DIS = -1;
COP_INT_DIS = -1;
/* Halt */
PROC_CTL(CURRENT_CORE) = 0x40000000;
while (1);
}
int system_memory_guard(int newmode)
{
(void)newmode;

View file

@ -58,6 +58,11 @@ void system_reboot(void)
{
}
void system_exception_wait(void)
{
while (1);
}
/* TODO - these should live in the target-specific directories and
once we understand what all the GPIO pins do, move the init to the
specific driver for that hardware. For now, we just perform the

View file

@ -287,6 +287,11 @@ void system_reboot(void)
while (1);
}
void system_exception_wait(void)
{
while ((GPIOA & 0x10) == 0); /* check for power button */
}
int system_memory_guard(int newmode)
{
(void)newmode;