Subversion Repositories freemyipod

Rev

Rev 14 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 15
Line 21... Line 21...
21
//
21
//
22
 
22
 
23
 
23
 
24
#include "global.h"
24
#include "global.h"
25
#include "panic.h"
25
#include "panic.h"
-
 
26
#include "lcd.h"
-
 
27
#include "lcdconsole.h"
26
#include "console.h"
28
#include "console.h"
-
 
29
#include "format.h"
-
 
30
#include "thread.h"
-
 
31
#include "contextswitch.h"
-
 
32
 
-
 
33
 
-
 
34
void hang();
27
 
35
 
28
 
36
 
29
void handle_panic(enum panic_severity severity)
37
void handle_panic(enum panic_severity severity)
30
{
38
{
31
  while(1);
39
    thread_exit();
32
}
40
}
33
 
41
 
34
void panic(enum panic_severity severity, const char* string)
42
void panic(enum panic_severity severity, const char* string)
35
{
43
{
-
 
44
    if (severity == PANIC_FATAL)
-
 
45
    {
-
 
46
        enter_critical_section();
-
 
47
        while (!displaylcd_safe());
-
 
48
        lcdconsole_puts_noblit("\n*PANIC*\n", 0, -1);
-
 
49
        lcdconsole_puts_noblit(string, 0, -1);
-
 
50
        lcdconsole_puts_noblit("\n", 0, -1);
-
 
51
        lcdconsole_update();
-
 
52
        hang();
-
 
53
    }
-
 
54
    else
-
 
55
    {
36
  cputs(1, "\n*PANIC*\n");
56
        cputs(1, "\n*PANIC*\n");
37
  cputs(1, string);
57
        cputs(1, string);
38
  cputc(1, '\n');
58
        cputc(1, '\n');
39
  handle_panic(severity);
59
        handle_panic(severity);
-
 
60
    }
-
 
61
}
-
 
62
 
-
 
63
static int pprfunc(void* ptr, unsigned char letter)
-
 
64
{
-
 
65
    lcdconsole_putc_noblit(letter, 0, -1);
-
 
66
    return true;
40
}
67
}
41
 
68
 
42
void panicf(enum panic_severity severity, const char* string, ...)
69
void panicf(enum panic_severity severity, const char* string, ...)
43
{
70
{
44
  va_list ap;
71
    va_list ap;
-
 
72
    if (severity == PANIC_FATAL)
-
 
73
    {
-
 
74
        enter_critical_section();
-
 
75
        while (!displaylcd_safe());
-
 
76
        lcdconsole_puts_noblit("\n*PANIC*\n", 0, -1);
-
 
77
        va_start(ap, string);
-
 
78
        format(pprfunc, NULL, string, ap);
-
 
79
        va_end(ap);
-
 
80
        lcdconsole_puts_noblit("\n", 0, -1);
-
 
81
        lcdconsole_update();
-
 
82
        hang();
-
 
83
    }
-
 
84
    else
-
 
85
    {
45
  cputs(1, "\n*PANIC*\n");
86
        cputs(1, "\n*PANIC*\n");
46
  va_start(ap, string);
87
        va_start(ap, string);
47
  cvprintf(1, string, ap);
88
        cvprintf(1, string, ap);
48
  va_end(ap);
89
        va_end(ap);
49
  cputc(1, '\n');
90
        cputc(1, '\n');
50
  handle_panic(severity);
91
        handle_panic(severity);
-
 
92
    }
51
}
93
}
52
 
94
 
53
void __div0()
95
void __div0()
54
{
96
{
55
  panic(PANIC_KILLTHREAD, "Division by zero!");
97
    panic(PANIC_KILLTHREAD, "Division by zero!");
56
}
98
}