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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [gdbserver/] [linux-or32-low.c] - Blame information for rev 512

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

Line No. Rev Author Line
1 441 jeremybenn
/* GNU/Linux/or32 specific low level interface, for the remote server for GDB.
2
   Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3
   Copyright (C) 2010 Embecosm Limited
4
 
5
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
6
 
7
   This file is part of GDB.
8
 
9
   This program is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 3 of the License, or
12
   (at your option) any later version.
13
 
14
   This program is distributed in the hope that it will be useful,
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
   GNU General Public License for more details.
18
 
19
   You should have received a copy of the GNU General Public License
20
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
 
22
/* -------------------------------------------------------------------------- */
23
/* OpenRISC 1000 specific low level Linux interface for GDB server.
24
 
25
   This implementation includes full Doxygen compatible documentation         */
26
/* -------------------------------------------------------------------------- */
27
 
28
#ifdef HAVE_STRINGS_H
29
#include <strings.h>
30
#endif
31
 
32
#include "server.h"
33
#include "regdef.h"
34
#include "linux-low.h"
35
 
36 445 julius
#include <asm/ptrace.h> /* For openrisc kernel ptrace register offsets */
37
 
38 512 jeremybenn
/* Defined in auto-generated file reg-or32.c.  */
39
void init_registers_or32 (void);
40
 
41 441 jeremybenn
#ifdef HAVE_SYS_REG_H
42
#include <sys/reg.h>
43
#endif
44
 
45 447 jeremybenn
 
46 453 jeremybenn
/*! Some useful GDB register numbers. */
47
#define GDB_REGNUM_R0    0
48
#define GDB_REGNUM_R31  31
49
#define GDB_REGNUM_PPC  32
50
#define GDB_REGNUM_NPC  33
51
#define GDB_REGNUM_SR   34
52
 
53 447 jeremybenn
/*! This is the number of *GDB* registers. I.e. r0-r31, PPC, NPC and SR. */
54 453 jeremybenn
#define or32_num_regs  (GDB_REGNUM_SR + 1)
55 441 jeremybenn
 
56
 
57
/* -------------------------------------------------------------------------- */
58
/*!Provide the ptrace "address" of a register.
59 447 jeremybenn
 
60
   This must be in GDB order (r0-r1, ppc, npc, sr) to ptrace offset. As with
61
   regs_or32, we substitute r31 for r0 and NPC for PPC.                       */
62 441 jeremybenn
/* -------------------------------------------------------------------------- */
63
static int or32_regmap[] = {
64 447 jeremybenn
  GPR31, SP,    GPR2,  GPR3,  GPR4,  GPR5,  GPR6,  GPR7,
65
  GPR8,  GPR9,  GPR10, GPR11, GPR12, GPR13, GPR14, GPR15,
66
  GPR16, GPR17, GPR18, GPR19, GPR20, GPR21, GPR22, GPR23,
67
  GPR24, GPR25, GPR26, GPR27, GPR28, GPR29, GPR30, GPR31,
68
  PC,    PC,    SR
69 441 jeremybenn
};
70
 
71
 
72
/* -------------------------------------------------------------------------- */
73
/*!Predicate to indicate if a register can be read.
74
 
75 453 jeremybenn
   We mark r0 as not readable.
76 441 jeremybenn
 
77
   @param[in] regno  Register to read.
78
 
79
   @return  Non-zero (TRUE) if the register can be read, zero (FALSE)
80
            otherwise.                                                        */
81
/* -------------------------------------------------------------------------- */
82
static int
83
or32_cannot_fetch_register (int  regno)
84
{
85 453 jeremybenn
  return (GDB_REGNUM_R0 == regno) || (regno >= or32_num_regs);
86 441 jeremybenn
 
87
}       /* or32_cannot_fetch_register () */
88
 
89
 
90
/* -------------------------------------------------------------------------- */
91
/*!Predicate to indicate if a register can be written.
92
 
93 453 jeremybenn
   We mark r0 and the SR as not writeable.
94 441 jeremybenn
 
95
   @param[in] regno  Register to write.
96
 
97
   @return  Non-zero (TRUE) if the register can be written, zero (FALSE)
98
            otherwise.                                                        */
99
/* -------------------------------------------------------------------------- */
100
static int
101
or32_cannot_store_register (int  regno)
102
{
103 453 jeremybenn
  return (GDB_REGNUM_R0 == regno) || (GDB_REGNUM_SR == regno) ||
104
         (regno >= or32_num_regs);
105 441 jeremybenn
 
106
}       /* or32_cannot_store_register () */
107
 
108
 
109
/* -------------------------------------------------------------------------- */
110
/*!Get the current program counter.
111
 
112
   On the OR32, this is NPC, the *next* program counter.
113
 
114
   @param[in] regcache  Current register cache.
115
 
116
   @return  The value of the NPC.                                             */
117
/* -------------------------------------------------------------------------- */
118
static CORE_ADDR
119
or32_get_pc (struct regcache *regcache)
120
{
121
  unsigned long int  npc;
122 445 julius
  collect_register_by_name (regcache, "npc", &npc);
123 441 jeremybenn
 
124 445 julius
    if (debug_threads)
125 441 jeremybenn
    {
126
      fprintf (stderr, "stop pc is %08lx\n", npc);
127
    }
128 445 julius
 
129 441 jeremybenn
  return  npc;
130
 
131
}       /* or32_get_pc () */
132
 
133
 
134
/* -------------------------------------------------------------------------- */
135
/*!Set the current program counter.
136
 
137
   On the OR32, this is NPC, the *next* program counter.
138
 
139
   @param[in] regcache  Current register cache.
140
   @param[in] pc        The value of the program counter to set.              */
141
/* -------------------------------------------------------------------------- */
142
static void
143
or32_set_pc (struct regcache *regcache,
144
             CORE_ADDR        pc)
145
{
146
  unsigned long int  npc = pc;
147 445 julius
  supply_register_by_name (regcache, "npc", &npc);
148 441 jeremybenn
 
149
}       /* or32_set_pc () */
150
 
151
 
152
/*! The value of a breakpoint instruction (l.trap  1). */
153
static const unsigned char or32_breakpoint [] = {0x21, 0x00, 0x00, 0x01};
154
 
155
 
156
/*! The length of a breakpoint instruction. */
157
#define OR32_BREAKPOINT_LEN  4
158
 
159
 
160
/* -------------------------------------------------------------------------- */
161
/*!Predicate to indicate if there is a breakpoint at the current address.
162
 
163
   For the OR32 we, just look for the l.trap 1 instruction.
164
 
165
   @param[in] where  The address to look for a breakpoint at.
166
 
167
   @return  Non-zero (TRUE) if there is a breakpoint, zero (FALSE) otherwise. */
168
/* -------------------------------------------------------------------------- */
169
static int
170
or32_breakpoint_at (CORE_ADDR where)
171
{
172
  unsigned char  insn[OR32_BREAKPOINT_LEN];
173
 
174
  (*the_target->read_memory) (where, insn, OR32_BREAKPOINT_LEN);
175
 
176
  return  (0 ==  bcmp (insn, or32_breakpoint, OR32_BREAKPOINT_LEN));
177
 
178
}       /* or32_breakpoint_at () */
179
 
180
 
181
/* -------------------------------------------------------------------------- */
182
/*!Data structure giving all the target specific functions.
183
 
184
   Details are in struct linux_target_ops in linux-low.h.                     */
185
/* -------------------------------------------------------------------------- */
186
struct linux_target_ops the_low_target = {
187
  init_registers_or32,                  /* Arch initialization */
188
  or32_num_regs,                        /* Num regs in arch */
189
  or32_regmap,                          /* Reg offsets for ptrace */
190
  or32_cannot_fetch_register,           /* Predicate for reg reading */
191
  or32_cannot_store_register,           /* Predicate for reg writing */
192
  or32_get_pc,                          /* Read the PC */
193
  or32_set_pc,                          /* Write the PC */
194
  or32_breakpoint,                      /* Breakpoint instruction bytes */
195
  OR32_BREAKPOINT_LEN,                  /* Breakpoint length */
196
  NULL,                                 /* Breakpoint reinsertion (unused) */
197
  0,                                     /* Decrement PC after break (FALSE) */
198
  or32_breakpoint_at,                   /* Predicate to check for breakpoint */
199 512 jeremybenn
  NULL,                                 /* Insert watchpoint (unused) */
200
  NULL,                                 /* Remove watchpoint (unused) */
201 441 jeremybenn
  NULL,                                 /* Predicate if stopped by watchpoint */
202
  NULL,                                 /* Data address for watchpoint stop */
203
  NULL,                                 /* ptrace PEEKUSR hook */
204
  NULL,                                 /* ptrace POKEUSR hook */
205
  NULL,                                 /* ptrace conversion predicate */
206
  NULL,                                 /* New process hook */
207
  NULL,                                 /* New thread hook */
208
  NULL,                                 /* Prepare to resume thread */
209
  NULL,                                 /* Target specific qSupported */
210
  NULL,                                 /* Tracepoint supported predicate */
211
  NULL,                                 /* Get thread area address */
212
  NULL,                                 /* Fast tracepoint jump pad */
213
  NULL,                                 /* Get bytecode operations vector */
214
};

powered by: WebSVN 2.1.0

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