source: rtems/c/src/librdbg/src/powerpc/rdbg_f.c @ ffa5b98

4.104.114.84.95
Last change on this file since ffa5b98 was ffa5b98, checked in by Joel Sherrill <joel.sherrill@…>, on 04/18/02 at 22:24:27

2002-04-18 Ralf Corsepius <corsepiu@…>

  • src/powerpc/rdbg_cpu_asm.S: Reflect changes to <rtems/score/cpu.h>.
  • src/powerpc/rdbg_f.c: Ditto.
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 **************************************************************************
3 *
4 * Component =   
5 *
6 * Synopsis  =   rdbg/powerpc/rdbg_f.c
7 *
8 * $Id$
9 *
10 **************************************************************************
11 */
12
13#include <rtems/score/cpu.h>
14#include <assert.h>
15#include <errno.h>
16#include <rdbg/reg.h>
17#include <rdbg/remdeb.h>
18#include <rdbg/rdbg.h>
19#include <rtems/score/thread.h>
20
21  void
22CtxToRegs (const CPU_Exception_frame * ctx, xdr_regs * regs)
23{
24  *((CPU_Exception_frame *) regs) = *ctx;
25}
26
27  void
28RegsToCtx (const xdr_regs * regs, CPU_Exception_frame * ctx)
29{
30  *ctx = *((CPU_Exception_frame *) regs);
31}
32
33  void
34get_ctx_thread (Thread_Control * thread, CPU_Exception_frame * ctx)
35{
36  unsigned int *ptr;
37  unsigned int i;
38
39  ctx->EXC_SRR0 = thread->Registers.pc;
40  ctx->EXC_SRR1 = thread->Registers.msr;
41  ctx->_EXC_number = 0xdeadbeef;
42
43  ctx->GPR1 = thread->Registers.gpr1;
44  ctx->GPR2 = thread->Registers.gpr2;
45  /*
46   * Fill with dummy values...
47   */
48  ptr = &ctx->GPR3;
49  for (i = 0; i < 10; i++)
50    ptr[i] = 0xdeadbeef;
51
52  ctx->GPR13 = thread->Registers.gpr13;
53  ctx->GPR14 = thread->Registers.gpr14;
54  ctx->GPR15 = thread->Registers.gpr15;
55  ctx->GPR16 = thread->Registers.gpr16;
56  ctx->GPR17 = thread->Registers.gpr17;
57  ctx->GPR18 = thread->Registers.gpr18;
58  ctx->GPR19 = thread->Registers.gpr19;
59  ctx->GPR20 = thread->Registers.gpr20;
60  ctx->GPR21 = thread->Registers.gpr21;
61  ctx->GPR22 = thread->Registers.gpr22;
62  ctx->GPR23 = thread->Registers.gpr23;
63  ctx->GPR24 = thread->Registers.gpr24;
64  ctx->GPR25 = thread->Registers.gpr25;
65  ctx->GPR26 = thread->Registers.gpr26;
66  ctx->GPR27 = thread->Registers.gpr27;
67  ctx->GPR28 = thread->Registers.gpr28;
68  ctx->GPR29 = thread->Registers.gpr29;
69  ctx->GPR30 = thread->Registers.gpr30;
70  ctx->GPR31 = thread->Registers.gpr31;
71  ctx->EXC_CR = thread->Registers.cr;
72  ctx->EXC_CTR = 0xdeadbeef;
73  ctx->EXC_XER = 0xdeadbeef;
74  ctx->EXC_LR = 0xdeadbeef;
75  ctx->EXC_MSR = 0xdeadbeef;
76  ctx->EXC_DAR = 0xdeadbeef;
77}
78
79  void
80set_ctx_thread (Thread_Control * thread, CPU_Exception_frame * ctx)
81{
82  thread->Registers.gpr1 = ctx->GPR1;
83  thread->Registers.gpr2 = ctx->GPR2;
84
85  thread->Registers.gpr13 = ctx->GPR13;
86  thread->Registers.gpr14 = ctx->GPR14;
87  thread->Registers.gpr15 = ctx->GPR15;
88  thread->Registers.gpr16 = ctx->GPR16;
89  thread->Registers.gpr17 = ctx->GPR17;
90  thread->Registers.gpr18 = ctx->GPR18;
91  thread->Registers.gpr19 = ctx->GPR19;
92  thread->Registers.gpr20 = ctx->GPR20;
93  thread->Registers.gpr21 = ctx->GPR21;
94  thread->Registers.gpr22 = ctx->GPR22;
95  thread->Registers.gpr23 = ctx->GPR23;
96  thread->Registers.gpr24 = ctx->GPR24;
97  thread->Registers.gpr25 = ctx->GPR25;
98  thread->Registers.gpr26 = ctx->GPR26;
99  thread->Registers.gpr27 = ctx->GPR27;
100  thread->Registers.gpr28 = ctx->GPR28;
101  thread->Registers.gpr29 = ctx->GPR29;
102  thread->Registers.gpr30 = ctx->GPR30;
103  thread->Registers.gpr31 = ctx->GPR31;
104  thread->Registers.cr = ctx->EXC_CR;
105  thread->Registers.pc = ctx->EXC_SRR0;
106  thread->Registers.msr = ctx->EXC_SRR1;
107}
108
109  int
110Single_Step (CPU_Exception_frame * ctx)
111{
112  if ((ctx->EXC_SRR1 & MSR_SE) != 0 || ExitForSingleStep != 0) {
113    /*
114     * Check coherency
115     */
116    assert ((ctx->EXC_SRR1 & MSR_SE) != 0);
117    assert (ExitForSingleStep != 0);
118    return 0;
119  }
120  ctx->EXC_SRR1 |= MSR_SE;
121  ++ExitForSingleStep;
122  return 0;
123}
124
125  int
126CheckForSingleStep (CPU_Exception_frame * ctx)
127{
128  if (ExitForSingleStep) {
129    /*
130     *  This functions can be called both from
131     *  INT1 and INT3 handlers. In case it is
132     *  called from INT3, need to clear TF.
133     */
134    ctx->EXC_SRR1 &= ~MSR_SE;
135    ExitForSingleStep = 0;
136    return 1;
137  }
138  return 0;
139}
140
141  void
142CancelSingleStep (CPU_Exception_frame * ctx)
143{
144  /*
145   * Cancel scheduled SS
146   */
147  ctx->EXC_SRR1 &= ~MSR_SE;
148  ExitForSingleStep--;
149}
150
151static cpuExcHandlerType oldExcHandler;
152
153  void
154connect_rdbg_exception ()
155{
156  /*
157   * test if rdbg already connected its exception handler
158   */
159  if (globalExceptHdl != BreakPointExcHdl) {
160    oldExcHandler = globalExceptHdl;
161    globalExceptHdl = BreakPointExcHdl;
162  }
163}
164
165  void
166disconnect_rdbg_exception ()
167{
168  /*
169   * test if current execption handler is rdbg's one
170   * and restore the original one in this case.
171   */
172  if (globalExceptHdl == BreakPointExcHdl) {
173    globalExceptHdl = oldExcHandler;
174  }
175}
Note: See TracBrowser for help on using the repository browser.