except.c
2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <R4300.h>
#include "romloader.h"
extern int _ExceptionPreamble[];
typedef struct {
unsigned int inst1; /* lui k0,XXXX */
unsigned int inst2; /* addiu k0,k0,XXXX */
unsigned int inst3; /* jr k0 */
unsigned int inst4; /* nop */
} vector;
typedef struct {
unsigned int at, v0, v1, a0, a1, a2, a3;
unsigned int t0, t1, t2, t3, t4, t5, t6, t7;
unsigned int s0, s1, s2, s3, s4, s5, s6, s7;
unsigned int t8, t9, gp, sp, s8, ra;
unsigned int pagemask;
unsigned int wired;
unsigned int entrylo0;
unsigned int entrylo1;
unsigned int context;
unsigned int badvaddr;
unsigned int entryhi;
unsigned int compare;
unsigned int sr;
unsigned int cause;
unsigned int epc;
unsigned int config;
} eframe;
eframe _ExceptionFrame;
void
_ExceptionInitialize(void)
{
*(vector *)UT_VEC = *(vector *)_ExceptionPreamble;
*(vector *)XUT_VEC = *(vector *)_ExceptionPreamble;
*(vector *)ECC_VEC = *(vector *)_ExceptionPreamble;
*(vector *)E_VEC = *(vector *)_ExceptionPreamble;
}
static char *excCodeNames[32] = {
"Int", "Mod", "TLBL", "TLBS", "AdEL", "AdES", "IBE", "DBE",
"Sys", "Bp", "RI", "CpU", "Ov", "Tr", "VCEI", "FPE",
"!!!!", "!!!!", "!!!!", "!!!!", "!!!!", "!!!!", "!!!!", "WATCH",
"!!!!", "!!!!", "!!!!", "!!!!", "!!!!", "!!!!", "!!!!", "VCED"
};
void
_ExceptionPrint(void)
{
register int i;
register eframe *ef = &_ExceptionFrame;
printf("PANIC:\n");
printf("epc\t0x%08x\n", ef->epc);
printf("cause\t0x%08b<%s>\n", ef->cause, CAUSE_FMT,
excCodeNames[(ef->cause & CAUSE_EXCMASK) >> CAUSE_EXCSHIFT]);
printf("sr\t0x%b\n", ef->sr, SR_FMT);
printf("badvaddr\t0x%08x\n", ef->badvaddr);
printf("pagemask\t0x%08x\n", ef->pagemask);
printf("wired\t0x%08x\n", ef->wired);
printf("entrylo0\t0x%08x\n", ef->entrylo0);
printf("entrylo1\t0x%08x\n", ef->entrylo1);
printf("context\t0x%08x\n", ef->context);
printf("entryhi\t0x%08x\n", ef->entryhi);
printf("compare\t0x%08x\n", ef->compare);
printf("config\t0x%08x\n", ef->config);
printf("at 0x%08x v0\t0x%08x v1\t0x%08x\n",
ef->at, ef->v0, ef->v1);
printf("a0 0x%08x a1\t0x%08x a2\t0x%08x a3\t0x%08x\n",
ef->a0, ef->a1, ef->a2, ef->a3);
printf("t0 0x%08x t1\t0x%08x t2\t0x%08x t3\t0x%08x\n",
ef->t0, ef->t1, ef->t2, ef->t3);
printf("t4 0x%08x t5\t0x%08x t6\t0x%08x t7\t0x%08x\n",
ef->t4, ef->t5, ef->t6, ef->t7);
printf("s0 0x%08x s1\t0x%08x s2\t0x%08x s3\t0x%08x\n",
ef->s0, ef->s1, ef->s2, ef->s3);
printf("s4 0x%08x s5\t0x%08x s6\t0x%08x s7\t0x%08x\n",
ef->s4, ef->s5, ef->s6, ef->s7);
printf("t8 0x%08x t9\t0x%08x\n",
ef->t8, ef->t9);
printf("gp 0x%08x sp\t0x%08x s8\t0x%08x ra\t0x%08x\n\n",
ef->gp, ef->sp, ef->s8, ef->ra);
for (;;);
}