source: rtems/c/src/lib/libcpu/mips/shared/interrupts/vectorexceptions.c @ 0ab87349

4.104.114.84.95
Last change on this file since 0ab87349 was 0ab87349, checked in by Joel Sherrill <joel.sherrill@…>, on 02/05/02 at 21:06:13

2001-02-05 Joel Sherrill <joel@…>

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