Factor out some drawing code.
[kugel-rb.git] / firmware / target / arm / system-arm.c
blob60e57cf9ff35d723b50f983e739f9eccacbb4430
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 by Thom Johansen
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 ****************************************************************************/
21 #include "config.h"
22 #include "system.h"
23 #include <stdio.h>
24 #include "lcd.h"
25 #include "font.h"
27 static const char* const uiename[] = {
28 "Undefined instruction",
29 "Prefetch abort",
30 "Data abort",
31 "Divide by zero"
34 /* Unexpected Interrupt or Exception handler. Currently only deals with
35 exceptions, but will deal with interrupts later.
37 void __attribute__((noreturn)) UIE(unsigned int pc, unsigned int num)
39 #if LCD_DEPTH > 1
40 lcd_set_backdrop(NULL);
41 lcd_set_drawmode(DRMODE_SOLID);
42 lcd_set_foreground(LCD_BLACK);
43 lcd_set_background(LCD_WHITE);
44 #endif
45 lcd_setfont(FONT_SYSFIXED);
46 lcd_set_viewport(NULL);
47 lcd_clear_display();
48 lcd_puts(0, 0, uiename[num]);
49 lcd_putsf(0, 1, "at %08x" IF_COP(" (%d)"), pc
50 IF_COP(, CURRENT_CORE));
51 lcd_update();
53 disable_interrupt(IRQ_FIQ_STATUS);
55 system_exception_wait(); /* If this returns, try to reboot */
56 system_reboot();
57 while (1); /* halt */
60 /* Needs to be here or gcc won't find it */
61 void __attribute__((naked)) __div0(void)
63 asm volatile (
64 "ldr r0, [sp] \r\n"
65 "mov r1, #3 \r\n"
66 "b UIE \r\n"