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 447

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 441 jeremybenn
#ifdef HAVE_SYS_REG_H
39
#include <sys/reg.h>
40
#endif
41
 
42 447 jeremybenn
 
43
/* -------------------------------------------------------------------------- */
44
/*!Global register map
45
 
46
   This should be in GDB order (r0-r1, ppc, npc, sr) to ptrace offset.
47
 
48
   ptrace does not support r0 (so we use r31 for now), nor ppc (so we use npc
49
   for now).
50
 
51
   @note This must be a global variable.
52
 
53
   @todo Fix r0 and ppc (needs ptrace changes).                               */
54
/* -------------------------------------------------------------------------- */
55 446 julius
struct reg regs_or32[] = {
56 447 jeremybenn
  { "r0",  GPR31 * 8, 32 },
57
  { "sp",  SP    * 8, 32 },
58
  { "fp",  GPR2  * 8, 32 },
59
  { "r3",  GPR3  * 8, 32 },
60
  { "r4",  GPR4  * 8, 32 },
61
  { "r5",  GPR5  * 8, 32 },
62
  { "r6",  GPR6  * 8, 32 },
63
  { "r7",  GPR7  * 8, 32 },
64
  { "r8",  GPR8  * 8, 32 },
65
  { "lr",  GPR9  * 8, 32 },
66
  { "r10", GPR10 * 8, 32 },
67
  { "r11", GPR11 * 8, 32 },
68
  { "r12", GPR12 * 8, 32 },
69
  { "r13", GPR13 * 8, 32 },
70
  { "r14", GPR14 * 8, 32 },
71
  { "r15", GPR15 * 8, 32 },
72
  { "r16", GPR16 * 8, 32 },
73
  { "r17", GPR17 * 8, 32 },
74
  { "r18", GPR18 * 8, 32 },
75
  { "r19", GPR19 * 8, 32 },
76
  { "r20", GPR20 * 8, 32 },
77
  { "r21", GPR21 * 8, 32 },
78
  { "r22", GPR22 * 8, 32 },
79
  { "r23", GPR23 * 8, 32 },
80
  { "r24", GPR24 * 8, 32 },
81
  { "r25", GPR25 * 8, 32 },
82
  { "r26", GPR26 * 8, 32 },
83
  { "r27", GPR27 * 8, 32 },
84
  { "r28", GPR28 * 8, 32 },
85
  { "r29", GPR29 * 8, 32 },
86
  { "r30", GPR30 * 8, 32 },
87
  { "r31", GPR31 * 8, 32 },
88
  { "ppc", PC    * 8, 32 },
89
  { "npc", PC    * 8, 32 },
90
  { "sr",  SR    * 8, 32 }
91
};
92 446 julius
 
93
/* -------------------------------------------------------------------------- */
94
/*!Initialize the register data.
95
 
96
  Should be automagically created from a data file in gdb/regformats, but for
97
  now we do it manually.                                                      */
98
/* -------------------------------------------------------------------------- */
99
static void
100
init_registers_or32 ()
101
{
102
 
103 441 jeremybenn
  static const char *expedite_regs_or32[] = { "sp", "lr", "npc", 0 };
104
 
105
  set_register_cache (regs_or32, sizeof (regs_or32) / sizeof (regs_or32[0]));
106
  gdbserver_expedite_regs = expedite_regs_or32;
107
  gdbserver_xmltarget     = NULL;
108
}
109
 
110
 
111 447 jeremybenn
/*! This is the number of *GDB* registers. I.e. r0-r31, PPC, NPC and SR. */
112
#define or32_num_regs  35
113 441 jeremybenn
 
114
 
115
/* -------------------------------------------------------------------------- */
116
/*!Provide the ptrace "address" of a register.
117 447 jeremybenn
 
118
   This must be in GDB order (r0-r1, ppc, npc, sr) to ptrace offset. As with
119
   regs_or32, we substitute r31 for r0 and NPC for PPC.                       */
120 441 jeremybenn
/* -------------------------------------------------------------------------- */
121
static int or32_regmap[] = {
122 447 jeremybenn
  GPR31, SP,    GPR2,  GPR3,  GPR4,  GPR5,  GPR6,  GPR7,
123
  GPR8,  GPR9,  GPR10, GPR11, GPR12, GPR13, GPR14, GPR15,
124
  GPR16, GPR17, GPR18, GPR19, GPR20, GPR21, GPR22, GPR23,
125
  GPR24, GPR25, GPR26, GPR27, GPR28, GPR29, GPR30, GPR31,
126
  PC,    PC,    SR
127 441 jeremybenn
};
128
 
129
 
130
/* -------------------------------------------------------------------------- */
131
/*!Predicate to indicate if a register can be read.
132
 
133
   For now, we believe all OR32 registers are readable.
134
 
135
   @param[in] regno  Register to read.
136
 
137
   @return  Non-zero (TRUE) if the register can be read, zero (FALSE)
138
            otherwise.                                                        */
139
/* -------------------------------------------------------------------------- */
140
static int
141
or32_cannot_fetch_register (int  regno)
142
{
143
  return (regno >= or32_num_regs);
144
 
145
}       /* or32_cannot_fetch_register () */
146
 
147
 
148
/* -------------------------------------------------------------------------- */
149
/*!Predicate to indicate if a register can be written.
150
 
151
   For now, we believe all OR32 registers are writable.
152
 
153
   @param[in] regno  Register to write.
154
 
155
   @return  Non-zero (TRUE) if the register can be written, zero (FALSE)
156
            otherwise.                                                        */
157
/* -------------------------------------------------------------------------- */
158
static int
159
or32_cannot_store_register (int  regno)
160
{
161
  return (regno >= or32_num_regs);
162
 
163
}       /* or32_cannot_store_register () */
164
 
165
 
166
/* -------------------------------------------------------------------------- */
167
/*!Get the current program counter.
168
 
169
   On the OR32, this is NPC, the *next* program counter.
170
 
171
   @param[in] regcache  Current register cache.
172
 
173
   @return  The value of the NPC.                                             */
174
/* -------------------------------------------------------------------------- */
175
static CORE_ADDR
176
or32_get_pc (struct regcache *regcache)
177
{
178
  unsigned long int  npc;
179 445 julius
  collect_register_by_name (regcache, "npc", &npc);
180 441 jeremybenn
 
181 445 julius
    if (debug_threads)
182 441 jeremybenn
    {
183
      fprintf (stderr, "stop pc is %08lx\n", npc);
184
    }
185 445 julius
 
186 441 jeremybenn
  return  npc;
187
 
188
}       /* or32_get_pc () */
189
 
190
 
191
/* -------------------------------------------------------------------------- */
192
/*!Set the current program counter.
193
 
194
   On the OR32, this is NPC, the *next* program counter.
195
 
196
   @param[in] regcache  Current register cache.
197
   @param[in] pc        The value of the program counter to set.              */
198
/* -------------------------------------------------------------------------- */
199
static void
200
or32_set_pc (struct regcache *regcache,
201
             CORE_ADDR        pc)
202
{
203
  unsigned long int  npc = pc;
204 445 julius
  supply_register_by_name (regcache, "npc", &npc);
205 441 jeremybenn
 
206
}       /* or32_set_pc () */
207
 
208
 
209
/*! The value of a breakpoint instruction (l.trap  1). */
210
static const unsigned char or32_breakpoint [] = {0x21, 0x00, 0x00, 0x01};
211
 
212
 
213
/*! The length of a breakpoint instruction. */
214
#define OR32_BREAKPOINT_LEN  4
215
 
216
 
217
/* -------------------------------------------------------------------------- */
218
/*!Predicate to indicate if there is a breakpoint at the current address.
219
 
220
   For the OR32 we, just look for the l.trap 1 instruction.
221
 
222
   @param[in] where  The address to look for a breakpoint at.
223
 
224
   @return  Non-zero (TRUE) if there is a breakpoint, zero (FALSE) otherwise. */
225
/* -------------------------------------------------------------------------- */
226
static int
227
or32_breakpoint_at (CORE_ADDR where)
228
{
229
  unsigned char  insn[OR32_BREAKPOINT_LEN];
230
 
231
  (*the_target->read_memory) (where, insn, OR32_BREAKPOINT_LEN);
232
 
233
  return  (0 ==  bcmp (insn, or32_breakpoint, OR32_BREAKPOINT_LEN));
234
 
235
}       /* or32_breakpoint_at () */
236
 
237
 
238
/* -------------------------------------------------------------------------- */
239
/*!Data structure giving all the target specific functions.
240
 
241
   Details are in struct linux_target_ops in linux-low.h.                     */
242
/* -------------------------------------------------------------------------- */
243
struct linux_target_ops the_low_target = {
244
  init_registers_or32,                  /* Arch initialization */
245
  or32_num_regs,                        /* Num regs in arch */
246
  or32_regmap,                          /* Reg offsets for ptrace */
247
  or32_cannot_fetch_register,           /* Predicate for reg reading */
248
  or32_cannot_store_register,           /* Predicate for reg writing */
249
  or32_get_pc,                          /* Read the PC */
250
  or32_set_pc,                          /* Write the PC */
251
  or32_breakpoint,                      /* Breakpoint instruction bytes */
252
  OR32_BREAKPOINT_LEN,                  /* Breakpoint length */
253
  NULL,                                 /* Breakpoint reinsertion (unused) */
254
  0,                                     /* Decrement PC after break (FALSE) */
255
  or32_breakpoint_at,                   /* Predicate to check for breakpoint */
256
  NULL,                                 /* Insert matchpoint (unused) */
257
  NULL,                                 /* Remove matchpoint (unused) */
258
  NULL,                                 /* Predicate if stopped by watchpoint */
259
  NULL,                                 /* Data address for watchpoint stop */
260
  NULL,                                 /* ptrace PEEKUSR hook */
261
  NULL,                                 /* ptrace POKEUSR hook */
262
  NULL,                                 /* ptrace conversion predicate */
263
  NULL,                                 /* New process hook */
264
  NULL,                                 /* New thread hook */
265
  NULL,                                 /* Prepare to resume thread */
266
  NULL,                                 /* Target specific qSupported */
267
  NULL,                                 /* Tracepoint supported predicate */
268
  NULL,                                 /* Get thread area address */
269
  NULL,                                 /* Fast tracepoint jump pad */
270
  NULL,                                 /* Get bytecode operations vector */
271
};

powered by: WebSVN 2.1.0

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