source: rtems/c/src/lib/libcpu/mips/shared/interrupts/vectorexceptions.c @ 7c99007

4.104.114.84.95
Last change on this file since 7c99007 was 7c99007, checked in by Greg Menke <gregory.menke@…>, on 06/08/06 at 18:03:55

B.Robinson MIPS patch

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  Common Code for Vectoring MIPS Exceptions
3 *
4 *  The actual decoding of the cause register and vector number assignment
5 *  is CPU model specific.
6 *
7 *  $Id$
8 */
9
10#include <rtems.h>
11#include <stdlib.h>
12#include <string.h>
13#include <rtems/mips/iregdef.h>
14#include <rtems/mips/idtcpu.h>
15#include <rtems/bspIo.h>
16
17static const char *cause_strings[32] =
18{
19  /*  0 */ "Int",
20  /*  1 */ "TLB Mods",
21  /*  2 */ "TLB Load",
22  /*  3 */ "TLB Store",
23  /*  4 */ "Address Load",
24  /*  5 */ "Address Store",
25  /*  6 */ "Instruction Bus Error",
26  /*  7 */ "Data Bus Error",
27  /*  8 */ "Syscall",
28  /*  9 */ "Breakpoint",
29  /* 10 */ "Reserved Instruction",
30  /* 11 */ "Coprocessor Unuseable",
31  /* 12 */ "Overflow",
32  /* 13 */ "Trap",
33  /* 14 */ "Instruction Virtual Coherency Error",
34  /* 15 */ "FP Exception",
35  /* 16 */ "Reserved 16",
36  /* 17 */ "Reserved 17",
37  /* 18 */ "Reserved 18",
38  /* 19 */ "Reserved 19",
39  /* 20 */ "Reserved 20",
40  /* 21 */ "Reserved 21",
41  /* 22 */ "Reserved 22",
42  /* 23 */ "Watch",
43  /* 24 */ "Reserved 24",
44  /* 25 */ "Reserved 25",
45  /* 26 */ "Reserved 26",
46  /* 27 */ "Reserved 27",
47  /* 28 */ "Reserved 28",
48  /* 29 */ "Reserved 29",
49  /* 30 */ "Reserved 30",
50  /* 31 */ "Data Virtual Coherency Error"
51};
52
53struct regdef
54{
55  int  offset;
56  char *name;
57};
58
59static const struct regdef dumpregs[]= {
60  { R_RA, "R_RA" }, { R_V0, "R_V0" },     { R_V1, "R_V1" },
61  { R_A0, "R_A0" }, { R_A1, "R_A1" },     { R_A2, "R_A2" },
62  { R_A3, "R_A3" }, { R_T0, "R_T0" },     { R_T1, "R_T1" },
63  { R_T2, "R_T2" }, { R_T3, "R_T3" },     { R_T4, "R_T4" },
64  { R_T5, "R_T5" }, { R_T6, "R_T6" },     { R_T7, "R_T7" },
65  { R_T8, "R_T8" }, { R_MDLO, "R_MDLO" }, { R_MDHI, "R_MDHI" },
66  { R_GP, "R_GP" }, { R_FP, "R_FP" },     { R_AT, "R_AT" },
67  { R_EPC,"R_EPC"}, { -1, NULL }
68};
69
70void mips_dump_exception_frame( CPU_Interrupt_frame *frame )
71{
72  uint32_t *frame_u32;
73  int   i, j;
74
75  frame_u32 = (uint32_t *)frame;
76  for(i=0; dumpregs[i].offset > -1; i++)
77  {
78     printk("   %s", dumpregs[i].name);
79     for(j=0; j< 7-strlen(dumpregs[i].name); j++) printk(" ");
80#if (__mips == 1 ) || (__mips == 32)
81     printk("  %08X%c", frame_u32[dumpregs[i].offset], (i%3) ? '\t' : '\n' );
82#elif __mips == 3
83     printk("  %08X", frame_u32[2 * dumpregs[i].offset + 1] );
84     printk("%08X%c", frame_u32[2 * dumpregs[i].offset], (i%2) ? '\t' : '\n' );
85#endif
86  }
87  printk( "\n" );
88}
89
90void mips_default_exception_code_handler( int exc, CPU_Interrupt_frame *frame )
91{
92  uint32_t sr;
93  uint32_t cause;
94
95  mips_get_sr( sr );
96  mips_get_cause( cause );
97
98  printk( "Unhandled exception %d\n", exc );
99  printk( "sr: 0x%08x  cause: 0x%08x --> %s\n", sr, cause,
100     cause_strings[(cause >> 2) &0x1f] );
101  mips_dump_exception_frame( frame );
102
103  rtems_fatal_error_occurred(1);
104}
105
106#define CALL_EXC(_vector,_frame) \
107   do { \
108        if ( _ISR_Vector_table[_vector] ) \
109             (_ISR_Vector_table[_vector])(_vector,_frame); \
110          else \
111             mips_default_exception_code_handler( _vector, _frame ); \
112   } while(0)
113
114/*
115 *  There are constants defined for these but they should basically
116 *  all be close to the same set.
117 */
118
119void mips_vector_exceptions( CPU_Interrupt_frame *frame )
120{
121  uint32_t   cause;
122  uint32_t   exc;
123
124  mips_get_cause( cause );
125  exc = (cause >> 2) & 0x1f;
126
127  CALL_EXC( exc, frame );
128}
Note: See TracBrowser for help on using the repository browser.