source: rtems/c/src/librdbg/src/powerpc/excep_f.c @ cb4185c

4.104.114.84.95
Last change on this file since cb4185c was cb4185c, checked in by Joel Sherrill <joel.sherrill@…>, on 06/17/05 at 14:35:57

2005-06-17 Joel Sherrill <joel@…>

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