Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 theseven 1
//
2
//
3
//    Copyright 2010 TheSeven
4
//
5
//
677 theseven 6
//    This file is part of emCORE.
2 theseven 7
//
677 theseven 8
//    emCORE is free software: you can redistribute it and/or
2 theseven 9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
677 theseven 13
//    emCORE is distributed in the hope that it will be useful,
2 theseven 14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
677 theseven 19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
2 theseven 20
//
21
//
22
 
23
 
24
#include "global.h"
14 theseven 25
#include "panic.h"
15 theseven 26
#include "lcd.h"
27
#include "lcdconsole.h"
28
#include "format.h"
2 theseven 29
 
30
 
14 theseven 31
void panic(enum panic_severity severity, const char* string)
2 theseven 32
{
243 theseven 33
    enter_critical_section();
34
    while (!displaylcd_safe());
421 theseven 35
    lcdconsole_puts_noblit("\n*PANIC*\n", LCDCONSOLE_FGCOLOR, LCDCONSOLE_BGCOLOR);
36
    lcdconsole_puts_noblit(string, LCDCONSOLE_FGCOLOR, LCDCONSOLE_BGCOLOR);
37
    lcdconsole_puts_noblit("\n", LCDCONSOLE_FGCOLOR, LCDCONSOLE_BGCOLOR);
243 theseven 38
    lcdconsole_update();
39
    hang();
2 theseven 40
}
41
 
15 theseven 42
static int pprfunc(void* ptr, unsigned char letter)
43
{
421 theseven 44
    lcdconsole_putc_noblit(letter, LCDCONSOLE_FGCOLOR, LCDCONSOLE_BGCOLOR);
15 theseven 45
    return true;
46
}
47
 
14 theseven 48
void panicf(enum panic_severity severity, const char* string, ...)
2 theseven 49
{
15 theseven 50
    va_list ap;
243 theseven 51
    enter_critical_section();
52
    while (!displaylcd_safe());
421 theseven 53
    lcdconsole_puts_noblit("\n*PANIC*\n", LCDCONSOLE_FGCOLOR, LCDCONSOLE_BGCOLOR);
243 theseven 54
    va_start(ap, string);
55
    format(pprfunc, NULL, string, ap);
56
    va_end(ap);
421 theseven 57
    lcdconsole_puts_noblit("\n", LCDCONSOLE_FGCOLOR, LCDCONSOLE_BGCOLOR);
243 theseven 58
    lcdconsole_update();
59
    hang();
2 theseven 60
}
61
 
62
void __div0()
63
{
15 theseven 64
    panic(PANIC_KILLTHREAD, "Division by zero!");
2 theseven 65
}