source: rtems/c/src/librdbg/src/powerpc/excep_f.c @ 8e3caa5

4.104.114.84.95
Last change on this file since 8e3caa5 was b077dc4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/18/02 at 14:14:17

2002-01-18 Till Straumann <strauman@…>

  • src/powerpc/excep_f.c: This patch addresses the following issues:
    • exception handler needs to enable MSR_FP if the interrupted thread is FP enabled.
    • printk message for MSR fixed and added stacktrace

NOTE: this requires the stacktrace patch to

lib/libbsp/powerpc/shared/vectors/vector_init.c
(#ifdef DDEBUG only, however)

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rdbg/powerpc/excep_f.c
7 *
8 * $Id$
9 *
10 **************************************************************************
11 */
12
13#include <rtems.h>
14#include <rtems/error.h>
15#include <assert.h>
16#include <errno.h>
17#include <rdbg/rdbg.h>
18#include <rdbg/servrpc.h>
19
20    int
21ExcepToSig (Exception_context *ctx)
22{
23  int excep = getExcNum (ctx);
24 
25  switch (excep) {
26        case ASM_FLOAT_VECTOR   : return SIGFPE;
27       
28        case ASM_TRACE_VECTOR   :
29        case ASM_PROG_VECTOR    :
30        case ASM_SYS_VECTOR     : return SIGTRAP;
31       
32        case ASM_ISI_VECTOR     : return SIGSEGV;
33       
34        case ASM_RESET_VECTOR   :
35        case ASM_MACH_VECTOR    :
36        case ASM_EXT_VECTOR     :
37        case ASM_ALIGN_VECTOR   : return SIGILL;
38       
39    default:
40        break;
41    }
42    return SIGKILL;
43}
44
45 
46/*----- Breakpoint Exception management -----*/
47
48    /*
49     *  Handler for Breakpoint Exceptions :
50     *  software breakpoints.
51     */
52
53void
54BreakPointExcHdl(CPU_Exception_frame *ctx)
55{
56  rtems_status_code status;
57  rtems_id continueSemId;
58
59  /* T. Straumann, 1/16/2002: we must re-enable the floating point engine
60   *                          if the interrupted thread is FP. Otherwise,
61   *                          the semaphore primitives may crash when they
62   *                          try to save FP context while switching this
63   *                          thread...
64   */
65  if (ctx->EXC_SRR1 & 0x2000) {
66        register unsigned long msr;
67        __asm__ __volatile__("mfmsr %0":"=r"(msr));
68        __asm__ __volatile__("mtmsr %0"::"r"(msr|MSR_FP));
69  }
70
71  if ( (justSaveContext) && (ctx->_EXC_number == ASM_SYS_VECTOR) ) {
72    PushSavedExceptCtx (_Thread_Executing->Object.id, ctx);
73    justSaveContext = 0;
74  }
75  else {
76    if (ctx->_EXC_number != ASM_TRACE_VECTOR){
77      NbSerializedCtx++;
78      rtems_semaphore_obtain(serializeSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
79      NbSerializedCtx--;
80    }
81     
82    currentTargetThread = _Thread_Executing->Object.id;
83
84#ifdef DDEBUG
85    printk("----------------------------------------------------------\n");
86    printk("Exception %d caught at PC %x by thread %d\n",
87           ctx->_EXC_number,
88           ctx->EXC_SRR0,
89           _Thread_Executing->Object.id);
90    printk("----------------------------------------------------------\n");
91    printk("Processor execution context at time of the fault was  :\n");
92    printk("----------------------------------------------------------\n");
93    printk("\t R0 = %x\n", ctx->GPR0);
94    printk("\t R1 = %x\n", ctx->GPR1);
95    printk("\t R2 = %x\n", ctx->GPR2);
96    printk("\t R3 = %x\n", ctx->GPR3);
97    printk("\t R4 = %x\n", ctx->GPR4);
98    printk("\t R5 = %x\n", ctx->GPR5);
99    printk("\t R6 = %x\n", ctx->GPR6);
100    printk("\t R7 = %x\n", ctx->GPR7);
101    printk("\t R8 = %x\n", ctx->GPR8);
102    printk("\t R9 = %x\n", ctx->GPR9);
103    printk("\t R10 = %x\n", ctx->GPR10);
104    printk("\t R11 = %x\n", ctx->GPR11);
105    printk("\t R12 = %x\n", ctx->GPR12);
106    printk("\t R13 = %x\n", ctx->GPR13);
107    printk("\t R14 = %x\n", ctx->GPR14);
108    printk("\t R15 = %x\n", ctx->GPR15);
109    printk("\t R16 = %x\n", ctx->GPR16);
110    printk("\t R17 = %x\n", ctx->GPR17);
111    printk("\t R18 = %x\n", ctx->GPR18);
112    printk("\t R19 = %x\n", ctx->GPR19);
113    printk("\t R20 = %x\n", ctx->GPR20);
114    printk("\t R21 = %x\n", ctx->GPR21);
115    printk("\t R22 = %x\n", ctx->GPR22);
116    printk("\t R23 = %x\n", ctx->GPR23);
117    printk("\t R24 = %x\n", ctx->GPR24);
118    printk("\t R25 = %x\n", ctx->GPR25);
119    printk("\t R26 = %x\n", ctx->GPR26);
120    printk("\t R27 = %x\n", ctx->GPR27);
121    printk("\t R28 = %x\n", ctx->GPR28);
122    printk("\t R29 = %x\n", ctx->GPR29);
123    printk("\t R30 = %x\n", ctx->GPR30);
124    printk("\t R31 = %x\n", ctx->GPR31);
125    printk("\t CR = %x\n", ctx->EXC_CR);
126    printk("\t CTR = %x\n", ctx->EXC_CTR);
127    printk("\t XER = %x\n", ctx->EXC_XER);
128    printk("\t LR = %x\n", ctx->EXC_LR);
129    printk("\t MSR = %x\n", ctx->EXC_SRR1);
130#endif
131
132    status = rtems_semaphore_create (rtems_build_name('D', 'B', 'G', 'c'),
133                                     0,
134                                     RTEMS_FIFO |
135                                     RTEMS_COUNTING_SEMAPHORE |
136                                     RTEMS_NO_INHERIT_PRIORITY |
137                                     RTEMS_NO_PRIORITY_CEILING |
138                                     RTEMS_LOCAL,
139                                     0,
140                                     &continueSemId);
141    if (status != RTEMS_SUCCESSFUL)
142      rtems_panic ("Can't create continue semaphore: `%s'\n",rtems_status_text(status));
143
144    PushExceptCtx (_Thread_Executing->Object.id, continueSemId, ctx);
145 
146    switch (ctx->_EXC_number){
147    case ASM_TRACE_VECTOR :
148      DPRINTF((" TRACE EXCEPTION !!!\n"));
149      ctx->EXC_SRR1 &= ~MSR_SE;
150      ExitForSingleStep-- ;
151      rtems_semaphore_release( wakeupEventSemId );
152    break;
153
154    case ASM_PROG_VECTOR :
155      DPRINTF((" BREAKPOINT EXCEPTION !!!\n"));
156      rtems_semaphore_release( wakeupEventSemId );
157    break;
158
159    case ASM_SYS_VECTOR :
160      DPRINTF((" ENTER RDBG !!!\n"));
161      rtems_semaphore_release( wakeupEventSemId );
162      break;
163
164    default:
165      DPRINTF((" OTHER EXCEPTION !!!\n"));
166#ifdef DDEBUG
167        { extern void BSP_printStackTrace();
168                BSP_printStackTrace(ctx);
169        }
170#endif
171      rtems_semaphore_release( wakeupEventSemId );
172      break;
173    }
174
175    rtems_semaphore_obtain(continueSemId, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
176   
177    PopExceptCtx (_Thread_Executing->Object.id);
178    rtems_semaphore_delete(continueSemId);
179  }
180
181}
182
183
184
Note: See TracBrowser for help on using the repository browser.