1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: 16: 17: 18: 19:
20:
21: #include "sysdepend.h"
22: #include <tk/sysdef.h>
23:
24: 25: 26:
27: typedef struct vecinfo VECINFO;
28: struct vecinfo {
29: UW vec;
30: B *msg;
31:
32: 33: 34: 35:
36: W (*func)( const VECINFO*, UW vec, UW pc, UW cpsr );
37: };
38:
39:
40: LOCAL W vf_msg( const VECINFO *vi, UW vec, UW pc, UW cpsr )
41: {
42: B *msg = vi->msg;
43: B opt;
44:
45: if ( msg == NULL ) return 0;
46:
47: 48: 49: 50:
51: opt = 0;
52: if ( *msg < ' ' ) opt = *msg++;
53:
54: DSP_F5(S,"Exception ", D,vec, S," (", S,msg, CH,')');
55:
56: return ( opt & 020 )? 1: 0;
57: }
58:
59:
60: LOCAL W vf_undef( const VECINFO *vi, UW vec, UW pc, UW cpsr )
61: {
62: if (cpsr & PSR_T) {
63: DSP_F3(S,vi->msg, CH,' ', 04X,*((UH*)(pc - 2)));
64: } else {
65: DSP_F3(S,vi->msg, CH,' ', 08X,*((UW*)(pc - 4)));
66: }
67: return 1;
68: }
69:
70:
71: LOCAL W vf_dabort( const VECINFO *vi, UW vec, UW pc, UW cpsr )
72: {
73: DSP_F1(S,vi->msg);
74: DSP_F4(S," ADDR: ", 08X,getCP15(6, 0), S," STAT: ", 08X,getCP15(5, 0));
75: return 0;
76: }
77:
78: 79: 80: 81:
82: LOCAL const VECINFO VecInfoTable[] = {
83: { 0, "\020" "Undefined SWI", vf_msg },
84: { EIT_UNDEF, "Undefined Instruction", vf_undef },
85: { EIT_IABORT, "Prefetch Abort", vf_msg },
86: { EIT_DABORT, "Data Abort", vf_dabort },
87: { EIT_DABORT+1, "\020" "Undefined SWI", vf_msg },
88:
89: { EIT_FIQ, "Undefined FIQ", vf_msg },
90: { EIT_IRQ(0), "Undefined IRQ", vf_msg },
91: { EIT_GPIO(0), "Undefined GPIO-INT", vf_msg },
92: { EIT_GPIO(127)+1,"\020" "Undefined SWI", vf_msg },
93:
94: { N_INTVEC, NULL, vf_msg }
95: };
96: #define N_VECINFO ( sizeof(VecInfoTable) / sizeof(VECINFO) )
97:
98: 99: 100: 101: 102:
103: EXPORT W procEIT( UW vec )
104: {
105: const VECINFO *vp;
106: UW pc, cpsr;
107: W i;
108:
109: pc = getCurPCX();
110: cpsr = getCurCPSR();
111:
112:
113: i = procHwInt(vec);
114: if ( i == 2 ) return 1;
115:
116: if ( i == 0 ) {
117:
118: for ( i = 1; i < N_VECINFO; ++i ) {
119: if ( vec < VecInfoTable[i].vec ) break;
120: }
121: vp = &VecInfoTable[i-1];
122: i = (*vp->func)(vp, vec, pc, cpsr);
123: if ( i > 0 ) {
124:
125: pc -= ( (cpsr & PSR_T) != 0 )? 2: 4;
126: }
127: }
128:
129: DSP_F5(S,"\nPC: ", 08X,pc, S," CPSR: ", 08X,cpsr, CH,'\n');
130:
131: return 0;
132: }