OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [librdbg/] [src/] [powerpc/] [rdbg_f.c] - Blame information for rev 30

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

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

powered by: WebSVN 2.1.0

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