00001
00007
00008
00009 #include <kernel.h>
00010 #include <mips.h>
00011 #include <interrupt.h>
00012
00013 char *trap_names[] =
00014 {
00015 "Int, Interrupt",
00016 "Mod, TLB modification exception",
00017 "TLBL, TLB exception (load or instruction fetch)",
00018 "TLBS, TLB exception (store)",
00019 "AdEL, Address error exception (load or instruction fetch)",
00020 "AdES, Address error exception (store)",
00021 "IBE, Bus error exception (instruction fetch)",
00022 "DBE, Bus error exception (data reference: load or store)",
00023 "Sys, Syscall exception",
00024 "Bp, Breakpoint exception",
00025 "RI, Reserved instruction exception",
00026 "CpU, Coprocessor Unusable exception",
00027 "Ov, Arithmetic Overflow exception",
00028 "Tr, Trap Exception",
00029 "Reserved",
00030 "FPE, Floating point exception",
00031 "Reserved",
00032 "Reserved",
00033 "C2E, Reserved for precise Coprocessor 2 exceptions",
00034 "Reserved",
00035 "Reserved",
00036 "Reserved",
00037 "MDMX, MDMX Unusuable in MIPS64",
00038 "WATCH, Reference to WatchHi/WatchLo address",
00039 "MCheck, Machine Check",
00040 "Reserved",
00041 "Reserved",
00042 "Reserved",
00043 "Reserved",
00044 "Reserved",
00045 "CacheErr, Cache error / Debug Mode",
00046 "Reserved"
00047 };
00048
00049 char *irq_names[] =
00050 {
00051 "Software interrupt request 0",
00052 "Software interrupt request 1",
00053 "Hardware interrupt request 0, eth1",
00054 "Hardware interrupt request 1, UART",
00055 "Hardware interrupt request 2, eth0",
00056 "Hardware interrupt request 3",
00057 "Hardware interrupt request 4",
00058 "Hardware interrupt request 5, Timer"
00059 };
00060
00068 void xtrap(long cause, long *frame)
00069 {
00070 long exccode = 0, irqcode = 0, irqnum = -1;
00071 void (*handler)(void);
00072
00073 exccode = (cause >> 2) & 0x0000001F;
00074 irqcode = (cause >> 8) & 0x000000FF;
00075
00076 if (exccode)
00077 {
00078 kprintf("XINU Exception 0x%04X, %s\r\n", cause, trap_names[exccode]);
00079 }
00080 else
00081 {
00082
00083 while (irqcode)
00084 { irqnum++; irqcode = irqcode >> 1; }
00085
00086 if ( NULL != (handler = interruptVector[irqnum]) )
00087 {
00088 (*handler)();
00089 return;
00090 }
00091 kprintf("XINU Trap %d, %s\r\n", irqnum, irq_names[irqnum]);
00092 }
00093
00094 kprintf("Faulting address: 0x%08X\r\n", frame[(IRQREC_EPC) / 4]);
00095
00096 kprintf("[0x%08X] sta:0x%08X\r\n",
00097 frame+36, frame[IRQREC_STATUS/4]);
00098 kprintf("[0x%08X] lo:0x%08X hi:0x%08X epc:0x%08X cau:0x%08X\r\n",
00099 frame+32, frame[IRQREC_LO/4], frame[IRQREC_HI/4],
00100 frame[IRQREC_EPC/4], frame[IRQREC_CAUSE/4]);
00101 kprintf("[0x%08X] gp:0x%08X sp:0x%08X fp:0x%08X ra:0x%08X\r\n",
00102 frame+28, frame[IRQREC_GP/4], frame[IRQREC_SP/4],
00103 frame[IRQREC_FP/4], frame[IRQREC_RA/4]);
00104 kprintf("[0x%08X] t8:0x%08X t9:0x%08X k0:0x%08X k1:0x%08X\r\n",
00105 frame+24, frame[IRQREC_T8/4], frame[IRQREC_T9/4],
00106 frame[IRQREC_K0/4], frame[IRQREC_K1/4]);
00107 kprintf("[0x%08X] s4:0x%08X s5:0x%08X s6:0x%08X s7:0x%08X\r\n",
00108 frame+20, frame[IRQREC_S4/4], frame[IRQREC_S5/4],
00109 frame[IRQREC_S6/4], frame[IRQREC_S7/4]);
00110 kprintf("[0x%08X] s0:0x%08X s1:0x%08X s2:0x%08X s3:0x%08X\r\n",
00111 frame+16, frame[IRQREC_S0/4], frame[IRQREC_S1/4],
00112 frame[IRQREC_S2/4], frame[IRQREC_S3/4]);
00113 kprintf("[0x%08X] t4:0x%08X t5:0x%08X t6:0x%08X t7:0x%08X\r\n",
00114 frame+12, frame[IRQREC_T4/4], frame[IRQREC_T5/4],
00115 frame[IRQREC_T6/4], frame[IRQREC_T7/4]);
00116 kprintf("[0x%08X] t0:0x%08X t1:0x%08X t2:0x%08X t3:0x%08X\r\n",
00117 frame+8, frame[IRQREC_T0/4], frame[IRQREC_T1/4],
00118 frame[IRQREC_T2/4], frame[IRQREC_T3/4]);
00119 kprintf("[0x%08X] a0:0x%08X a1:0x%08X a2:0x%08X a3:0x%08X\r\n",
00120 frame+4, frame[IRQREC_A0/4], frame[IRQREC_A1/4],
00121 frame[IRQREC_A2/4], frame[IRQREC_A3/4]);
00122 kprintf("[0x%08X] zer:0x%08X at:0x%08X v0:0x%08X v1:0x%08X\r\n",
00123 frame+0, frame[IRQREC_ZER/4], frame[IRQREC_AT/4],
00124 frame[IRQREC_V0/4], frame[IRQREC_V1/4]);
00125
00126 while (1)
00127 ;
00128 }
00129