source: rtems/c/src/lib/libbsp/mips/shared/irq/vectorexceptions.c @ 815994f

4.115
Last change on this file since 815994f was 815994f, checked in by Sebastian Huber <sebastian.huber@…>, on 11/25/12 at 16:48:11

score: Add CPU_Exception_frame

Add CPU port type CPU_Exception_frame and function
_CPU_Exception_frame_print().

The CPU ports of avr, bfin, h8300, lm32, m32c, m32r, m68k, nios2, sh,
sparc64, and v850 use an empty default implementation of
_CPU_Exception_frame_print().

Add rtems_exception_frame and rtems_exception_frame_print().

Add RTEMS_FATAL_SOURCE_EXCEPTION for CPU exceptions. Use rtems_fatal()
with source RTEMS_FATAL_SOURCE_EXCEPTION in CPU ports of i386, powerpc,
and sparc for unexpected exceptions.

Add third parameter to RTEMS_BSP_CLEANUP_OPTIONS() which controls the
BSP_PRINT_EXCEPTION_CONTEXT define used in the default
bsp_fatal_extension().

Add test sptests/spfatal26.

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