OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [librdbg/] [src/] [powerpc/] [rdbg_f.c] - Blame information for rev 1026

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.