1 |
330 |
jeremybenn |
/* Target-dependent code for the 32-bit OpenRISC 1000, for the GNU Debugger.
|
2 |
|
|
|
3 |
|
|
Copyright 1988-2008, Free Software Foundation, Inc.
|
4 |
|
|
Copyright (C) 2008, 2010 Embecosm Limited
|
5 |
|
|
|
6 |
|
|
Contributed by Alessandro Forin(af@cs.cmu.edu at CMU
|
7 |
|
|
and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
|
8 |
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
9 |
|
|
|
10 |
|
|
This file is part of GDB.
|
11 |
|
|
|
12 |
|
|
This program is free software; you can redistribute it and/or modify it
|
13 |
|
|
under the terms of the GNU General Public License as published by the Free
|
14 |
|
|
Software Foundation; either version 3 of the License, or (at your option)
|
15 |
|
|
any later version.
|
16 |
|
|
|
17 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
18 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
20 |
|
|
more details.
|
21 |
|
|
|
22 |
|
|
You should have received a copy of the GNU General Public License along
|
23 |
|
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
24 |
|
|
|
25 |
|
|
/*-----------------------------------------------------------------------------
|
26 |
|
|
This version for the OpenRISC 1000 architecture is a rewrite by Jeremy
|
27 |
|
|
Bennett of the old GDB 5.3 interface to make use of gdbarch for GDB 6.8.
|
28 |
|
|
|
29 |
|
|
The code tries to follow the GDB coding style.
|
30 |
|
|
|
31 |
|
|
Commenting is Doxygen compatible.
|
32 |
|
|
|
33 |
|
|
Much has been stripped out in the interests of getting a basic working
|
34 |
|
|
system. This is described as the OpenRISC 1000 target architecture, so
|
35 |
|
|
should work with 16, 32 and 64 bit versions of that architecture and should
|
36 |
|
|
work whether or not they have floating point and/or vector registers.
|
37 |
|
|
|
38 |
|
|
There was never a capability to run simulator commands (no remote target
|
39 |
|
|
implemented the required function), so that has been removed.
|
40 |
|
|
|
41 |
|
|
The info trace command has been removed. The meaning of this is not clear -
|
42 |
|
|
it relies on a value in register 255 of the debug group, which is
|
43 |
|
|
undocumented.
|
44 |
|
|
|
45 |
|
|
All the hardware trace has been removed for the time being. The new debug
|
46 |
|
|
interface does not support hardware trace, so there is no plan to reinstate
|
47 |
|
|
this functionality.
|
48 |
|
|
|
49 |
|
|
Support for multiple contexts (which was rudimentary, and not working) has
|
50 |
|
|
been removed. */
|
51 |
|
|
/*---------------------------------------------------------------------------*/
|
52 |
|
|
|
53 |
|
|
#include "demangle.h"
|
54 |
|
|
#include "defs.h"
|
55 |
|
|
#include "gdb_string.h"
|
56 |
|
|
#include "frame.h"
|
57 |
|
|
#include "inferior.h"
|
58 |
|
|
#include "symtab.h"
|
59 |
|
|
#include "value.h"
|
60 |
|
|
#include "gdbcmd.h"
|
61 |
|
|
#include "language.h"
|
62 |
|
|
#include "gdbcore.h"
|
63 |
|
|
#include "symfile.h"
|
64 |
|
|
#include "objfiles.h"
|
65 |
|
|
#include "gdbtypes.h"
|
66 |
|
|
#include "target.h"
|
67 |
|
|
#include "regcache.h"
|
68 |
|
|
|
69 |
|
|
#include "opcode/or32.h"
|
70 |
|
|
#include "or32-tdep.h"
|
71 |
|
|
|
72 |
|
|
#include "safe-ctype.h"
|
73 |
|
|
#include "block.h"
|
74 |
|
|
#include "reggroups.h"
|
75 |
|
|
#include "arch-utils.h"
|
76 |
|
|
#include "frame.h"
|
77 |
|
|
#include "frame-unwind.h"
|
78 |
|
|
#include "frame-base.h"
|
79 |
|
|
#include "dwarf2-frame.h"
|
80 |
|
|
#include "trad-frame.h"
|
81 |
|
|
|
82 |
|
|
#include <inttypes.h>
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
/* Support functions for the architecture definition */
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
/*----------------------------------------------------------------------------*/
|
91 |
|
|
/*!Get an instruction
|
92 |
|
|
|
93 |
|
|
This reads from memory. The old version relied on the frame, this relies
|
94 |
|
|
just on the architecture. The old version also guaranteed not to get a
|
95 |
|
|
software breakpoint if one had been set. However that seems to happen just
|
96 |
|
|
before execution and is removed immediately after, so we believe should not
|
97 |
|
|
happen. The old function from GDB 6.8 to do this has been deleted.
|
98 |
|
|
|
99 |
|
|
@param[in] gdbarch Architecture for which we are getting the instruction.
|
100 |
|
|
@param[in] addr Address from which to get the instruction
|
101 |
|
|
|
102 |
|
|
@return The instruction */
|
103 |
|
|
/*---------------------------------------------------------------------------*/
|
104 |
|
|
|
105 |
|
|
static ULONGEST
|
106 |
|
|
or32_fetch_instruction (struct gdbarch *gdbarch,
|
107 |
|
|
CORE_ADDR addr)
|
108 |
|
|
{
|
109 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
110 |
|
|
char buf[OR32_INSTLEN];
|
111 |
|
|
int status;
|
112 |
|
|
|
113 |
|
|
status = target_read_memory (addr, buf, OR32_INSTLEN);
|
114 |
|
|
|
115 |
|
|
if (status)
|
116 |
|
|
{
|
117 |
|
|
memory_error (status, addr);
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
return extract_unsigned_integer (buf, OR32_INSTLEN, byte_order);
|
121 |
|
|
|
122 |
|
|
} /* or32_fetch_instruction() */
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
/*---------------------------------------------------------------------------*/
|
126 |
|
|
/*!Generic function to read bits from an instruction
|
127 |
|
|
|
128 |
|
|
printf style. Basic syntax
|
129 |
|
|
|
130 |
|
|
or32_analyse_inst (inst, format, &arg1, &arg2 ...)
|
131 |
|
|
|
132 |
|
|
Format string can contain the following characters:
|
133 |
|
|
|
134 |
|
|
- SPACE: Ignored, just for layout
|
135 |
|
|
- 0: Match with a zero bit
|
136 |
|
|
- 1: Match with a one bit
|
137 |
|
|
- %<n>b: Match <n> bits to the next argument (n decimal)
|
138 |
|
|
|
139 |
|
|
If the arg corresponding to a bit field is non-null, the value will be
|
140 |
|
|
assigned to that argument (using NULL allows fields to be skipped).
|
141 |
|
|
|
142 |
|
|
Any bad string will cause a fatal error. These are constant strings, so
|
143 |
|
|
should be correct.
|
144 |
|
|
|
145 |
|
|
The bit field must be 32 bits long. A failure here will cause a fatal error
|
146 |
|
|
for the same reason.
|
147 |
|
|
|
148 |
|
|
@note The format string is presented MS field to LS field, left to
|
149 |
|
|
right. This means that it is read lowest numbered char first.
|
150 |
|
|
|
151 |
|
|
@note Some of the arg fields may be populated, even if recognition
|
152 |
|
|
ultimately fails.
|
153 |
|
|
|
154 |
|
|
@param[in] inst The instruction to analyse
|
155 |
|
|
@param[in] format The format string
|
156 |
|
|
@param[out] ... Argument fields
|
157 |
|
|
|
158 |
|
|
@return 1 (TRUE) if the instruction matches, 0 (FALSE) otherwise. */
|
159 |
|
|
/*---------------------------------------------------------------------------*/
|
160 |
|
|
static int
|
161 |
|
|
or32_analyse_inst (uint32_t inst,
|
162 |
|
|
const char *format,
|
163 |
|
|
...)
|
164 |
|
|
{
|
165 |
|
|
/* Break out each field in turn, validating as we go. */
|
166 |
|
|
va_list ap;
|
167 |
|
|
|
168 |
|
|
int i;
|
169 |
|
|
int iptr = 0; /* Instruction pointer */
|
170 |
|
|
|
171 |
|
|
va_start (ap, format);
|
172 |
|
|
|
173 |
|
|
for (i = 0; 0 != format[i];)
|
174 |
|
|
{
|
175 |
|
|
const char *start_ptr;
|
176 |
|
|
char *end_ptr;
|
177 |
|
|
|
178 |
|
|
uint32_t bits; /* Bit substring of interest */
|
179 |
|
|
uint32_t width; /* Substring width */
|
180 |
|
|
uint32_t *arg_ptr;
|
181 |
|
|
|
182 |
|
|
switch (format[i])
|
183 |
|
|
{
|
184 |
|
|
case ' ': i++; break; /* Formatting: ignored */
|
185 |
|
|
|
186 |
|
|
case '0': case '1': /* Constant bit field */
|
187 |
|
|
bits = (inst >> (OR32_INSTBITLEN - iptr - 1)) & 0x1;
|
188 |
|
|
|
189 |
|
|
if ((format[i] - '0') != bits)
|
190 |
|
|
{
|
191 |
|
|
return 0;
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
iptr++;
|
195 |
|
|
i++;
|
196 |
|
|
break;
|
197 |
|
|
|
198 |
|
|
case '%': /* Bit field */
|
199 |
|
|
i++;
|
200 |
|
|
start_ptr = &(format[i]);
|
201 |
|
|
width = strtoul (start_ptr, &end_ptr, 10);
|
202 |
|
|
|
203 |
|
|
/* Check we got something, and if so skip on */
|
204 |
|
|
if (start_ptr == end_ptr)
|
205 |
|
|
{
|
206 |
|
|
fatal ("bitstring \"%s\" at offset %d has no length field.\n",
|
207 |
|
|
format, i);
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
i += end_ptr - start_ptr;
|
211 |
|
|
|
212 |
|
|
/* Look for and skip the terminating 'b'. If it's not there, we
|
213 |
|
|
still give a fatal error, because these are fixed strings that
|
214 |
|
|
just should not be wrong. */
|
215 |
|
|
if ('b' != format[i++])
|
216 |
|
|
{
|
217 |
|
|
fatal ("bitstring \"%s\" at offset %d has no terminating 'b'.\n",
|
218 |
|
|
format, i);
|
219 |
|
|
}
|
220 |
|
|
|
221 |
|
|
/* Break out the field. There is a special case with a bit width of
|
222 |
|
|
32. */
|
223 |
|
|
if (32 == width)
|
224 |
|
|
{
|
225 |
|
|
bits = inst;
|
226 |
|
|
}
|
227 |
|
|
else
|
228 |
|
|
{
|
229 |
|
|
bits = (inst >> (OR32_INSTBITLEN - iptr - width)) & ((1 << width) - 1);
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
arg_ptr = va_arg (ap, uint32_t *);
|
233 |
|
|
*arg_ptr = bits;
|
234 |
|
|
iptr += width;
|
235 |
|
|
break;
|
236 |
|
|
|
237 |
|
|
default:
|
238 |
|
|
fatal ("invalid character in bitstring \"%s\" at offset %d.\n",
|
239 |
|
|
format, i);
|
240 |
|
|
break;
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
/* Is the length OK? */
|
245 |
|
|
gdb_assert (OR32_INSTBITLEN == iptr);
|
246 |
|
|
|
247 |
|
|
return 1; /* We succeeded */
|
248 |
|
|
|
249 |
|
|
} /* or32_analyse_inst () */
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
/*---------------------------------------------------------------------------*/
|
253 |
|
|
/*!Analyse a l.addi instruction
|
254 |
|
|
|
255 |
|
|
General form is:
|
256 |
|
|
|
257 |
|
|
l.addi rD,rA,I
|
258 |
|
|
|
259 |
|
|
Makes use of the generic analysis function (@see or32_analyse_inst ()).
|
260 |
|
|
|
261 |
|
|
@param[in] inst The instruction to analyse.
|
262 |
|
|
@param[out] rd_ptr Pointer to the rD value.
|
263 |
|
|
@param[out] ra_ptr Pointer to the rA value.
|
264 |
|
|
@param[out] simm_ptr Pointer to the signed immediate value.
|
265 |
|
|
|
266 |
|
|
@return 1 (TRUE) if the instruction matches, 0 (FALSE) otherwise. */
|
267 |
|
|
/*---------------------------------------------------------------------------*/
|
268 |
|
|
static int
|
269 |
|
|
or32_analyse_l_addi (uint32_t inst,
|
270 |
|
|
unsigned int *rd_ptr,
|
271 |
|
|
unsigned int *ra_ptr,
|
272 |
|
|
int *simm_ptr)
|
273 |
|
|
{
|
274 |
|
|
/* Instruction fields */
|
275 |
|
|
uint32_t rd, ra, i;
|
276 |
|
|
|
277 |
|
|
if (or32_analyse_inst (inst, "10 0111 %5b %5b %16b", &rd, &ra, &i))
|
278 |
|
|
{
|
279 |
|
|
/* Found it. Construct the result fields */
|
280 |
|
|
*rd_ptr = (unsigned int) rd;
|
281 |
|
|
*ra_ptr = (unsigned int) ra;
|
282 |
|
|
*simm_ptr = (int) (((i & 0x8000) == 0x8000) ? 0xffff0000 | i : i);
|
283 |
|
|
|
284 |
|
|
return 1; /* Success */
|
285 |
|
|
}
|
286 |
|
|
else
|
287 |
|
|
{
|
288 |
|
|
return 0; /* Failure */
|
289 |
|
|
}
|
290 |
|
|
} /* or32_analyse_l_addi () */
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
/*---------------------------------------------------------------------------*/
|
294 |
|
|
/*!Analyse a l.sw instruction
|
295 |
|
|
|
296 |
|
|
General form is:
|
297 |
|
|
|
298 |
|
|
l.sw I(rA),rB
|
299 |
|
|
|
300 |
|
|
Makes use of the generic analysis function (@see or32_analyse_inst ()).
|
301 |
|
|
|
302 |
|
|
@param[in] inst The instruction to analyse.
|
303 |
|
|
@param[out] simm_ptr Pointer to the signed immediate value.
|
304 |
|
|
@param[out] ra_ptr Pointer to the rA value.
|
305 |
|
|
@param[out] rb_ptr Pointer to the rB value.
|
306 |
|
|
|
307 |
|
|
@return 1 (TRUE) if the instruction matches, 0 (FALSE) otherwise. */
|
308 |
|
|
/*---------------------------------------------------------------------------*/
|
309 |
|
|
static int
|
310 |
|
|
or32_analyse_l_sw (uint32_t inst,
|
311 |
|
|
int *simm_ptr,
|
312 |
|
|
unsigned int *ra_ptr,
|
313 |
|
|
unsigned int *rb_ptr)
|
314 |
|
|
{
|
315 |
|
|
/* Instruction fields */
|
316 |
|
|
uint32_t ihi, ilo, ra, rb;
|
317 |
|
|
|
318 |
|
|
if (or32_analyse_inst (inst, "11 0101 %5b %5b %5b %11b", &ihi, &ra, &rb,
|
319 |
|
|
&ilo))
|
320 |
|
|
|
321 |
|
|
{
|
322 |
|
|
/* Found it. Construct the result fields */
|
323 |
|
|
*simm_ptr = (int) ((ihi << 11) | ilo);
|
324 |
|
|
*simm_ptr |= ((ihi & 0x10) == 0x10) ? 0xffff0000 : 0;
|
325 |
|
|
|
326 |
|
|
*ra_ptr = (unsigned int) ra;
|
327 |
|
|
*rb_ptr = (unsigned int) rb;
|
328 |
|
|
|
329 |
|
|
return 1; /* Success */
|
330 |
|
|
}
|
331 |
|
|
else
|
332 |
|
|
{
|
333 |
|
|
return 0; /* Failure */
|
334 |
|
|
}
|
335 |
|
|
} /* or32_analyse_l_sw () */
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
/* Functions defining the architecture */
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
/*----------------------------------------------------------------------------*/
|
344 |
|
|
/*!Determine the return convention used for a given type
|
345 |
|
|
|
346 |
|
|
Optionally, fetch or set the return value via "readbuf" or "writebuf"
|
347 |
|
|
respectively using "regcache" for the register values.
|
348 |
|
|
|
349 |
|
|
The OpenRISC 1000 returns scalar values via R11 and (for 64 bit values on
|
350 |
|
|
32 bit architectures) R12. Structs and unions are returned by reference,
|
351 |
|
|
with the address in R11
|
352 |
|
|
|
353 |
|
|
The result returned is independent of the function type, so we ignore that.
|
354 |
|
|
|
355 |
|
|
Throughout use read_memory(), not target_read_memory(), since the address
|
356 |
|
|
may be invalid and we want an error reported (read_memory() is
|
357 |
|
|
target_read_memory() with error reporting).
|
358 |
|
|
|
359 |
|
|
@todo This implementation is labelled OR32, but in fact is just for the 32
|
360 |
|
|
bit version, OR32. This should be made explicit
|
361 |
|
|
|
362 |
|
|
@param[in] gdbarch The GDB architecture being used
|
363 |
|
|
@param[in] functype The type of the function to be called (may be NULL)
|
364 |
|
|
@param[in] valtype The type of the entity to be returned
|
365 |
|
|
@param[in] regcache The register cache
|
366 |
|
|
@param[in] readbuf Buffer into which the return value should be written
|
367 |
|
|
@param[out] writebuf Buffer from which the return value should be written
|
368 |
|
|
|
369 |
|
|
@return The type of return value */
|
370 |
|
|
/*---------------------------------------------------------------------------*/
|
371 |
|
|
|
372 |
|
|
static enum return_value_convention
|
373 |
|
|
or32_return_value (struct gdbarch *gdbarch,
|
374 |
|
|
struct type *functype,
|
375 |
|
|
struct type *valtype,
|
376 |
|
|
struct regcache *regcache,
|
377 |
|
|
gdb_byte *readbuf,
|
378 |
|
|
const gdb_byte *writebuf)
|
379 |
|
|
{
|
380 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
381 |
|
|
enum type_code rv_type = TYPE_CODE (valtype);
|
382 |
|
|
unsigned int rv_size = TYPE_LENGTH (valtype);
|
383 |
|
|
ULONGEST tmp;
|
384 |
|
|
|
385 |
|
|
/* Deal with struct/union and large scalars first. Large (> 4 byte) scalars
|
386 |
|
|
are returned via a pointer (despite what is says in the architecture
|
387 |
|
|
document). Result pointed to by R11 */
|
388 |
|
|
|
389 |
|
|
if((TYPE_CODE_STRUCT == rv_type) ||
|
390 |
|
|
(TYPE_CODE_UNION == rv_type) ||
|
391 |
|
|
(rv_size > 4))
|
392 |
|
|
{
|
393 |
|
|
if (readbuf)
|
394 |
|
|
{
|
395 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_RV_REGNUM, &tmp);
|
396 |
|
|
read_memory (tmp, readbuf, rv_size);
|
397 |
|
|
}
|
398 |
|
|
if (writebuf)
|
399 |
|
|
{
|
400 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_RV_REGNUM, &tmp);
|
401 |
|
|
write_memory (tmp, writebuf, rv_size);
|
402 |
|
|
}
|
403 |
|
|
|
404 |
|
|
return RETURN_VALUE_ABI_RETURNS_ADDRESS;
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
/* 1-4 byte scalars are returned in R11 */
|
408 |
|
|
|
409 |
|
|
if (readbuf)
|
410 |
|
|
{
|
411 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_RV_REGNUM, &tmp);
|
412 |
|
|
store_unsigned_integer (readbuf, rv_size, byte_order, tmp);
|
413 |
|
|
}
|
414 |
|
|
if (writebuf)
|
415 |
|
|
{
|
416 |
|
|
gdb_byte buf[4];
|
417 |
|
|
memset (buf, 0, sizeof (buf)); /* Pad with zeros if < 4 bytes */
|
418 |
|
|
|
419 |
|
|
if (BFD_ENDIAN_BIG == byte_order)
|
420 |
|
|
{
|
421 |
|
|
memcpy (buf + sizeof (buf) - rv_size, writebuf, rv_size);
|
422 |
|
|
}
|
423 |
|
|
else
|
424 |
|
|
{
|
425 |
|
|
memcpy (buf, writebuf, rv_size);
|
426 |
|
|
}
|
427 |
|
|
|
428 |
|
|
regcache_cooked_write (regcache, OR32_RV_REGNUM, buf);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
return RETURN_VALUE_REGISTER_CONVENTION;
|
432 |
|
|
|
433 |
|
|
} /* or32_return_value() */
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
/*----------------------------------------------------------------------------*/
|
437 |
|
|
/*!Determine the instruction to use for a breakpoint.
|
438 |
|
|
|
439 |
|
|
Given the address at which to insert a breakpoint (bp_addr), what will
|
440 |
|
|
that breakpoint be?
|
441 |
|
|
|
442 |
|
|
For or32, we have a breakpoint instruction. Since all or32 instructions
|
443 |
|
|
are 32 bits, this is all we need, regardless of address.
|
444 |
|
|
|
445 |
|
|
@param[in] gdbarch The GDB architecture being used
|
446 |
|
|
@param[in] bp_addr The breakpoint address in question
|
447 |
|
|
@param[out] bp_size The size of instruction selected
|
448 |
|
|
|
449 |
|
|
@return The chosen breakpoint instruction */
|
450 |
|
|
/*---------------------------------------------------------------------------*/
|
451 |
|
|
|
452 |
|
|
static const gdb_byte *
|
453 |
|
|
or32_breakpoint_from_pc (struct gdbarch *gdbarch,
|
454 |
|
|
CORE_ADDR *bp_addr,
|
455 |
|
|
int *bp_size)
|
456 |
|
|
{
|
457 |
|
|
static const gdb_byte breakpoint[] = OR32_BRK_INSTR_STRUCT;
|
458 |
|
|
|
459 |
|
|
*bp_size = OR32_INSTLEN;
|
460 |
|
|
return breakpoint;
|
461 |
|
|
|
462 |
|
|
} /* or32_breakpoint_from_pc() */
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
/*----------------------------------------------------------------------------*/
|
466 |
|
|
/*!Determine if we are executing a delay slot
|
467 |
|
|
|
468 |
|
|
Looks at the instruction at the previous instruction to see if it was one
|
469 |
|
|
with a delay slot. But it also has to be the address prior to NPC, because
|
470 |
|
|
we may have just taken an exception.
|
471 |
|
|
|
472 |
|
|
@param[in] gdbarch The GDB architecture being used
|
473 |
|
|
@param[in] this_frame Information about THIS frame
|
474 |
|
|
|
475 |
|
|
@return 1 (true) if this instruction is executing a delay slot, 0 (false)
|
476 |
|
|
otherwise. */
|
477 |
|
|
/*--------------------------------------------------------------------------*/
|
478 |
|
|
|
479 |
|
|
static int
|
480 |
|
|
or32_single_step_through_delay( struct gdbarch *gdbarch,
|
481 |
|
|
struct frame_info *this_frame )
|
482 |
|
|
{
|
483 |
|
|
struct regcache *regcache = get_current_regcache ();
|
484 |
|
|
ULONGEST val;
|
485 |
|
|
CORE_ADDR ppc;
|
486 |
|
|
CORE_ADDR npc;
|
487 |
|
|
int index;
|
488 |
|
|
|
489 |
|
|
/* Get and the previous and current instruction addresses. If they are not
|
490 |
|
|
adjacent, we cannot be in a delay slot. */
|
491 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_PPC_REGNUM, &val);
|
492 |
|
|
ppc = (CORE_ADDR) val;
|
493 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_NPC_REGNUM, &val);
|
494 |
|
|
npc = (CORE_ADDR) val;
|
495 |
|
|
|
496 |
|
|
if (0x4 != (npc - ppc))
|
497 |
|
|
{
|
498 |
|
|
return 0;
|
499 |
|
|
}
|
500 |
|
|
|
501 |
|
|
/* Decode the previous instruction to see if it was a branch or a jump, and
|
502 |
|
|
hence we are in a delay slot. */
|
503 |
|
|
index = insn_decode (or32_fetch_instruction (gdbarch, ppc));
|
504 |
|
|
return or32_opcodes[index].flags & OR32_IF_DELAY;
|
505 |
|
|
|
506 |
|
|
} /* or32_single_step_through_delay() */
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
/*----------------------------------------------------------------------------*/
|
510 |
|
|
/*!Read a pseudo register
|
511 |
|
|
|
512 |
|
|
Since we have no pseudo registers this is a null function for now.
|
513 |
|
|
|
514 |
|
|
@todo The floating point and vector registers ought to be done as
|
515 |
|
|
pseudo-registers.
|
516 |
|
|
|
517 |
|
|
@param[in] gdbarch The GDB architecture to consider
|
518 |
|
|
@param[in] regcache The cached register values as an array
|
519 |
|
|
@param[in] regnum The register to read
|
520 |
|
|
@param[out] buf A buffer to put the result in */
|
521 |
|
|
/*---------------------------------------------------------------------------*/
|
522 |
|
|
|
523 |
|
|
static void
|
524 |
|
|
or32_pseudo_register_read (struct gdbarch *gdbarch,
|
525 |
|
|
struct regcache *regcache,
|
526 |
|
|
int regnum,
|
527 |
|
|
gdb_byte *buf)
|
528 |
|
|
{
|
529 |
|
|
return;
|
530 |
|
|
|
531 |
|
|
} /* or32_pseudo_register_read() */
|
532 |
|
|
|
533 |
|
|
|
534 |
|
|
/*----------------------------------------------------------------------------*/
|
535 |
|
|
/*!Write a pseudo register
|
536 |
|
|
|
537 |
|
|
Since we have no pseudo registers this is a null function for now.
|
538 |
|
|
|
539 |
|
|
@todo The floating point and vector registers ought to be done as
|
540 |
|
|
pseudo-registers.
|
541 |
|
|
|
542 |
|
|
@param[in] gdbarch The GDB architecture to consider
|
543 |
|
|
@param[in] regcache The cached register values as an array
|
544 |
|
|
@param[in] regnum The register to read
|
545 |
|
|
@param[in] buf A buffer with the value to write */
|
546 |
|
|
/*---------------------------------------------------------------------------*/
|
547 |
|
|
|
548 |
|
|
static void
|
549 |
|
|
or32_pseudo_register_write (struct gdbarch *gdbarch,
|
550 |
|
|
struct regcache *regcache,
|
551 |
|
|
int regnum,
|
552 |
|
|
const gdb_byte *buf)
|
553 |
|
|
{
|
554 |
|
|
return;
|
555 |
|
|
|
556 |
|
|
} /* or32_pseudo_register_write() */
|
557 |
|
|
|
558 |
|
|
|
559 |
|
|
/*----------------------------------------------------------------------------*/
|
560 |
|
|
/*!Return the register name for the OpenRISC 1000 architecture
|
561 |
|
|
|
562 |
|
|
This version converted to ANSI C, made static and incorporates the static
|
563 |
|
|
table of register names (this is the only place it is referenced).
|
564 |
|
|
|
565 |
|
|
@todo The floating point and vector registers ought to be done as
|
566 |
|
|
pseudo-registers.
|
567 |
|
|
|
568 |
|
|
@param[in] gdbarch The GDB architecture being used
|
569 |
|
|
@param[in] regnum The register number
|
570 |
|
|
|
571 |
|
|
@return The textual name of the register */
|
572 |
|
|
/*---------------------------------------------------------------------------*/
|
573 |
|
|
|
574 |
|
|
static const char *
|
575 |
|
|
or32_register_name (struct gdbarch *gdbarch,
|
576 |
|
|
int regnum)
|
577 |
|
|
{
|
578 |
|
|
static char *or32_gdb_reg_names[OR32_TOTAL_NUM_REGS] =
|
579 |
|
|
{
|
580 |
|
|
/* general purpose registers */
|
581 |
|
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
582 |
|
|
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
|
583 |
|
|
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
|
584 |
|
|
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
|
585 |
|
|
|
586 |
|
|
/* previous program counter, next program counter and status register */
|
587 |
|
|
"ppc", "npc", "sr"
|
588 |
|
|
|
589 |
|
|
/* Floating point and vector registers may appear as pseudo registers in
|
590 |
|
|
the future. */
|
591 |
|
|
};
|
592 |
|
|
|
593 |
|
|
return or32_gdb_reg_names[regnum];
|
594 |
|
|
|
595 |
|
|
} /* or32_register_name() */
|
596 |
|
|
|
597 |
|
|
|
598 |
|
|
/*----------------------------------------------------------------------------*/
|
599 |
|
|
/*!Identify the type of a register
|
600 |
|
|
|
601 |
|
|
@todo I don't fully understand exactly what this does, but I think this
|
602 |
|
|
makes sense!
|
603 |
|
|
|
604 |
|
|
@param[in] arch The GDB architecture to consider
|
605 |
|
|
@param[in] regnum The register to identify
|
606 |
|
|
|
607 |
|
|
@return The type of the register */
|
608 |
|
|
/*---------------------------------------------------------------------------*/
|
609 |
|
|
|
610 |
|
|
static struct type *
|
611 |
|
|
or32_register_type (struct gdbarch *arch,
|
612 |
|
|
int regnum)
|
613 |
|
|
{
|
614 |
|
|
static struct type *void_func_ptr = NULL;
|
615 |
|
|
static struct type *void_ptr = NULL;
|
616 |
|
|
|
617 |
|
|
/* Set up the static pointers once, the first time*/
|
618 |
|
|
if (NULL == void_func_ptr)
|
619 |
|
|
{
|
620 |
|
|
struct type *void_type = builtin_type (arch)->builtin_void;
|
621 |
|
|
|
622 |
|
|
void_ptr = lookup_pointer_type (void_type);
|
623 |
|
|
void_func_ptr = lookup_pointer_type (lookup_function_type (void_type));
|
624 |
|
|
}
|
625 |
|
|
|
626 |
|
|
if((regnum >= 0) && (regnum < OR32_TOTAL_NUM_REGS))
|
627 |
|
|
{
|
628 |
|
|
switch (regnum)
|
629 |
|
|
{
|
630 |
|
|
case OR32_PPC_REGNUM:
|
631 |
|
|
case OR32_NPC_REGNUM:
|
632 |
|
|
return void_func_ptr; /* Pointer to code */
|
633 |
|
|
|
634 |
|
|
case OR32_SP_REGNUM:
|
635 |
|
|
case OR32_FP_REGNUM:
|
636 |
|
|
return void_ptr; /* Pointer to data */
|
637 |
|
|
|
638 |
|
|
default:
|
639 |
|
|
return builtin_type (arch)->builtin_uint32; /* Data */
|
640 |
|
|
}
|
641 |
|
|
}
|
642 |
|
|
|
643 |
|
|
internal_error (__FILE__, __LINE__,
|
644 |
|
|
_("or32_register_type: illegal register number %d"), regnum);
|
645 |
|
|
|
646 |
|
|
} /* or32_register_type() */
|
647 |
|
|
|
648 |
|
|
|
649 |
|
|
/*----------------------------------------------------------------------------*/
|
650 |
|
|
/*!Handle the "info register" command
|
651 |
|
|
|
652 |
|
|
Print the identified register, unless it is -1, in which case print all
|
653 |
|
|
the registers. If all is 1 means all registers, otherwise only the core
|
654 |
|
|
GPRs.
|
655 |
|
|
|
656 |
|
|
@todo At present all registers are printed with the default method. Should
|
657 |
|
|
there be something special for FP registers?
|
658 |
|
|
|
659 |
|
|
@param[in] gdbarch The GDB architecture being used
|
660 |
|
|
@param[in] file File handle for use with any custom I/O
|
661 |
|
|
@param[in] frame Frame info for use with custom output
|
662 |
|
|
@param[in] regnum Register of interest, or -1 if all registers
|
663 |
|
|
@param[in] all 1 if all means all, 0 if all means just GPRs
|
664 |
|
|
|
665 |
|
|
@return The aligned stack frame address */
|
666 |
|
|
/*---------------------------------------------------------------------------*/
|
667 |
|
|
|
668 |
|
|
static void
|
669 |
|
|
or32_registers_info (struct gdbarch *gdbarch,
|
670 |
|
|
struct ui_file *file,
|
671 |
|
|
struct frame_info *frame,
|
672 |
|
|
int regnum,
|
673 |
|
|
int all)
|
674 |
|
|
{
|
675 |
|
|
if (-1 == regnum)
|
676 |
|
|
{
|
677 |
|
|
/* Do all (valid) registers */
|
678 |
|
|
unsigned int lim = all ? OR32_NUM_REGS : OR32_MAX_GPR_REGS;
|
679 |
|
|
|
680 |
|
|
for (regnum = 0; regnum < lim; regnum++) {
|
681 |
|
|
if ('\0' != *(or32_register_name (gdbarch, regnum)))
|
682 |
|
|
{
|
683 |
|
|
or32_registers_info (gdbarch, file, frame, regnum, all);
|
684 |
|
|
}
|
685 |
|
|
}
|
686 |
|
|
}
|
687 |
|
|
else
|
688 |
|
|
{
|
689 |
|
|
/* Do one specified register - if it is part of this architecture */
|
690 |
|
|
if ('\0' == *(or32_register_name (gdbarch, regnum)))
|
691 |
|
|
{
|
692 |
|
|
error ("Not a valid register for the current processor type");
|
693 |
|
|
}
|
694 |
|
|
else
|
695 |
|
|
{
|
696 |
|
|
default_print_registers_info (gdbarch, file, frame, regnum, all);
|
697 |
|
|
}
|
698 |
|
|
}
|
699 |
|
|
} /* or32_registers_info() */
|
700 |
|
|
|
701 |
|
|
|
702 |
|
|
/*----------------------------------------------------------------------------*/
|
703 |
|
|
/*!Identify if a register belongs to a specified group
|
704 |
|
|
|
705 |
|
|
Return true if the specified register is a member of the specified
|
706 |
|
|
register group.
|
707 |
|
|
|
708 |
|
|
These are the groups of registers that can be displayed via "info reg".
|
709 |
|
|
|
710 |
|
|
@todo The Vector and Floating Point registers ought to be displayed as
|
711 |
|
|
pseudo-registers.
|
712 |
|
|
|
713 |
|
|
@param[in] gdbarch The GDB architecture to consider
|
714 |
|
|
@param[in] regnum The register to consider
|
715 |
|
|
@param[in] group The group to consider
|
716 |
|
|
|
717 |
|
|
@return True (1) if regnum is a member of group */
|
718 |
|
|
/*---------------------------------------------------------------------------*/
|
719 |
|
|
|
720 |
|
|
static int
|
721 |
|
|
or32_register_reggroup_p (struct gdbarch *gdbarch,
|
722 |
|
|
int regnum,
|
723 |
|
|
struct reggroup *group)
|
724 |
|
|
{
|
725 |
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
726 |
|
|
|
727 |
|
|
/* All register group */
|
728 |
|
|
if (group == all_reggroup)
|
729 |
|
|
{
|
730 |
|
|
return ((regnum >= 0) &&
|
731 |
|
|
(regnum < OR32_TOTAL_NUM_REGS) &&
|
732 |
|
|
(or32_register_name (gdbarch, regnum)[0] != '\0'));
|
733 |
|
|
}
|
734 |
|
|
|
735 |
|
|
/* For now everything except the PC */
|
736 |
|
|
if (group == general_reggroup)
|
737 |
|
|
{
|
738 |
|
|
return ((regnum >= OR32_ZERO_REGNUM) &&
|
739 |
|
|
(regnum < tdep->num_gpr_regs) &&
|
740 |
|
|
(regnum != OR32_PPC_REGNUM) &&
|
741 |
|
|
(regnum != OR32_NPC_REGNUM));
|
742 |
|
|
}
|
743 |
|
|
|
744 |
|
|
if (group == float_reggroup)
|
745 |
|
|
{
|
746 |
|
|
return 0; /* No float regs. */
|
747 |
|
|
}
|
748 |
|
|
|
749 |
|
|
if (group == vector_reggroup)
|
750 |
|
|
{
|
751 |
|
|
return 0; /* No vector regs. */
|
752 |
|
|
}
|
753 |
|
|
|
754 |
|
|
/* For any that are not handled above. */
|
755 |
|
|
return default_register_reggroup_p (gdbarch, regnum, group);
|
756 |
|
|
|
757 |
|
|
} /* or32_register_reggroup_p() */
|
758 |
|
|
|
759 |
|
|
|
760 |
|
|
/*----------------------------------------------------------------------------*/
|
761 |
|
|
/*!Is this one of the registers used for passing arguments?
|
762 |
|
|
|
763 |
|
|
These are r3-r8 in the API.
|
764 |
|
|
|
765 |
|
|
@param[in] regnum The register to consider
|
766 |
|
|
|
767 |
|
|
@return Non-zero (TRUE) if it is an argument register, zero (FALSE)
|
768 |
|
|
otherwise. */
|
769 |
|
|
/*----------------------------------------------------------------------------*/
|
770 |
|
|
static int
|
771 |
|
|
or32_is_arg_reg (unsigned int regnum)
|
772 |
|
|
{
|
773 |
|
|
return (OR32_FIRST_ARG_REGNUM <= regnum) && (regnum <= OR32_LAST_ARG_REGNUM);
|
774 |
|
|
|
775 |
|
|
} /* or32_is_arg_reg () */
|
776 |
|
|
|
777 |
|
|
|
778 |
|
|
/*----------------------------------------------------------------------------*/
|
779 |
|
|
/*!Is this a callee saved register?
|
780 |
|
|
|
781 |
|
|
These are r10, r12, r14, r16, r18, r20, r22, r24, r26, r28 and r30 in the
|
782 |
|
|
API.
|
783 |
|
|
|
784 |
|
|
@param[in] regnum The register to consider
|
785 |
|
|
|
786 |
|
|
@return Non-zero (TRUE) if it is a callee saved register, zero (FALSE)
|
787 |
|
|
otherwise. */
|
788 |
|
|
/*----------------------------------------------------------------------------*/
|
789 |
|
|
static int
|
790 |
|
|
or32_is_callee_saved_reg (unsigned int regnum)
|
791 |
|
|
{
|
792 |
|
|
return (OR32_FIRST_SAVED_REGNUM <= regnum) && (0 == regnum % 2);
|
793 |
|
|
|
794 |
|
|
} /* or32_is_callee_saved_reg () */
|
795 |
|
|
|
796 |
|
|
|
797 |
|
|
/*----------------------------------------------------------------------------*/
|
798 |
|
|
/*!Skip a function prolog
|
799 |
|
|
|
800 |
|
|
If the input address, PC, is in a function prologue, return the address of
|
801 |
|
|
the end of the prologue, otherwise return the input address.
|
802 |
|
|
|
803 |
|
|
@see For details of the stack frame, see the function
|
804 |
|
|
or32_frame_cache().
|
805 |
|
|
|
806 |
|
|
@note The old version of this function used to use skip_prologue_using_sal
|
807 |
|
|
to skip the prologue without checking if it had actually worked. It
|
808 |
|
|
doesn't for STABS, so we had better check for a valid result.
|
809 |
|
|
|
810 |
|
|
This function reuses the helper functions from or32_frame_cache() to
|
811 |
|
|
locate the various parts of the prolog, any or all of which may be missing.
|
812 |
|
|
|
813 |
|
|
@param[in] gdbarch The GDB architecture being used
|
814 |
|
|
@param[in] pc Current program counter
|
815 |
|
|
|
816 |
|
|
@return The address of the end of the prolog if the PC is in a function
|
817 |
|
|
prologue, otherwise the input address. */
|
818 |
|
|
/*----------------------------------------------------------------------------*/
|
819 |
|
|
static CORE_ADDR
|
820 |
|
|
or32_skip_prologue (struct gdbarch *gdbarch,
|
821 |
|
|
CORE_ADDR pc)
|
822 |
|
|
{
|
823 |
|
|
CORE_ADDR start_pc;
|
824 |
|
|
CORE_ADDR addr;
|
825 |
|
|
uint32_t inst;
|
826 |
|
|
|
827 |
|
|
unsigned int ra, rb, rd; /* For instruction analysis */
|
828 |
|
|
int simm;
|
829 |
|
|
|
830 |
|
|
int frame_size = 0;
|
831 |
|
|
|
832 |
|
|
/* Try using SAL first if we have symbolic information available. This only
|
833 |
|
|
works for DWARF 2, not STABS. */
|
834 |
|
|
if (find_pc_partial_function (pc, NULL, &start_pc, NULL))
|
835 |
|
|
{
|
836 |
|
|
CORE_ADDR prologue_end = skip_prologue_using_sal( gdbarch, pc );
|
837 |
|
|
|
838 |
|
|
if (0 != prologue_end)
|
839 |
|
|
{
|
840 |
|
|
struct symtab_and_line prologue_sal = find_pc_line (start_pc, 0);
|
841 |
|
|
char *debug_format = prologue_sal.symtab->debugformat;
|
842 |
|
|
|
843 |
|
|
if ((strlen ("dwarf") <= strlen (debug_format))
|
844 |
|
|
&& (0 == strncasecmp ("dwarf", debug_format, strlen ("dwarf"))))
|
845 |
|
|
{
|
846 |
|
|
return (prologue_end > pc) ? prologue_end : pc;
|
847 |
|
|
}
|
848 |
|
|
}
|
849 |
|
|
}
|
850 |
|
|
|
851 |
|
|
/* Look to see if we can find any of the standard prologue sequence. All
|
852 |
|
|
quite difficult, since any or all of it may be missing. So this is just a
|
853 |
|
|
best guess! */
|
854 |
|
|
addr = pc; /* Where we have got to */
|
855 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
856 |
|
|
|
857 |
|
|
/* Look for the new stack pointer being set up. */
|
858 |
|
|
if (or32_analyse_l_addi (inst, &rd, &ra, &simm) &&
|
859 |
|
|
(OR32_SP_REGNUM == rd) && (OR32_SP_REGNUM == ra) &&
|
860 |
|
|
(simm < 0) && (0 == (simm % 4)))
|
861 |
|
|
{
|
862 |
|
|
frame_size = -simm;
|
863 |
|
|
addr += OR32_INSTLEN;
|
864 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
865 |
|
|
}
|
866 |
|
|
|
867 |
|
|
/* Look for the frame pointer being manipulated. */
|
868 |
|
|
if (or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
869 |
|
|
(OR32_SP_REGNUM == ra) && (OR32_FP_REGNUM == rb) &&
|
870 |
|
|
(simm >= 0) && (0 == (simm % 4)))
|
871 |
|
|
{
|
872 |
|
|
addr += OR32_INSTLEN;
|
873 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
874 |
|
|
|
875 |
|
|
gdb_assert (or32_analyse_l_addi (inst, &rd, &ra, &simm) &&
|
876 |
|
|
(OR32_FP_REGNUM == rd) && (OR32_SP_REGNUM == ra) &&
|
877 |
|
|
(simm == frame_size));
|
878 |
|
|
|
879 |
|
|
addr += OR32_INSTLEN;
|
880 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
881 |
|
|
}
|
882 |
|
|
|
883 |
|
|
/* Look for the link register being saved */
|
884 |
|
|
if (or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
885 |
|
|
(OR32_SP_REGNUM == ra) && (OR32_LR_REGNUM == rb) &&
|
886 |
|
|
(simm >= 0) && (0 == (simm % 4)))
|
887 |
|
|
{
|
888 |
|
|
addr += OR32_INSTLEN;
|
889 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
890 |
|
|
}
|
891 |
|
|
|
892 |
|
|
/* Look for arguments or callee-saved register being saved. The register
|
893 |
|
|
must be one of the arguments (r3-r8) or the 10 callee saved registers
|
894 |
|
|
(r10, r12, r14, r16, r18, r20, r22, r24, r26, r28, r30). The base
|
895 |
|
|
register must be the FP (for the args) or the SP (for the callee_saved
|
896 |
|
|
registers). */
|
897 |
|
|
while (1)
|
898 |
|
|
{
|
899 |
|
|
if (or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
900 |
|
|
(((OR32_FP_REGNUM == ra) && or32_is_arg_reg (rb)) ||
|
901 |
|
|
((OR32_SP_REGNUM == ra) && or32_is_callee_saved_reg (rb))) &&
|
902 |
|
|
(0 == (simm % 4)))
|
903 |
|
|
{
|
904 |
|
|
addr += OR32_INSTLEN;
|
905 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
906 |
|
|
}
|
907 |
|
|
else
|
908 |
|
|
{
|
909 |
|
|
/* Nothing else to look for. We have found the end of the prologue. */
|
910 |
|
|
return addr;
|
911 |
|
|
}
|
912 |
|
|
}
|
913 |
|
|
} /* or32_skip_prologue() */
|
914 |
|
|
|
915 |
|
|
|
916 |
|
|
/*----------------------------------------------------------------------------*/
|
917 |
|
|
/*!Align the stack frame
|
918 |
|
|
|
919 |
|
|
OpenRISC 1000 uses a falling stack frame, so this aligns down to the
|
920 |
|
|
nearest 8 bytes. Useful when we'be building a dummy frame.
|
921 |
|
|
|
922 |
|
|
@param[in] gdbarch The GDB architecture being used
|
923 |
|
|
@param[in] sp Current stack pointer
|
924 |
|
|
|
925 |
|
|
@return The aligned stack frame address */
|
926 |
|
|
/*---------------------------------------------------------------------------*/
|
927 |
|
|
|
928 |
|
|
static CORE_ADDR
|
929 |
|
|
or32_frame_align (struct gdbarch *gdbarch,
|
930 |
|
|
CORE_ADDR sp)
|
931 |
|
|
{
|
932 |
|
|
return align_down (sp, OR32_STACK_ALIGN);
|
933 |
|
|
|
934 |
|
|
} /* or32_frame_align() */
|
935 |
|
|
|
936 |
|
|
|
937 |
|
|
/*----------------------------------------------------------------------------*/
|
938 |
|
|
/*!Unwind the program counter from a stack frame
|
939 |
|
|
|
940 |
|
|
This just uses the built in frame unwinder
|
941 |
|
|
|
942 |
|
|
@param[in] gdbarch The GDB architecture being used
|
943 |
|
|
@param[in] next_frame Frame info for the NEXT frame
|
944 |
|
|
|
945 |
|
|
@return The program counter for THIS frame */
|
946 |
|
|
/*---------------------------------------------------------------------------*/
|
947 |
|
|
|
948 |
|
|
static CORE_ADDR
|
949 |
|
|
or32_unwind_pc (struct gdbarch *gdbarch,
|
950 |
|
|
struct frame_info *next_frame)
|
951 |
|
|
{
|
952 |
|
|
CORE_ADDR pc = frame_unwind_register_unsigned (next_frame, OR32_NPC_REGNUM);
|
953 |
|
|
|
954 |
|
|
return pc;
|
955 |
|
|
|
956 |
|
|
} /* or32_unwind_pc() */
|
957 |
|
|
|
958 |
|
|
|
959 |
|
|
/*----------------------------------------------------------------------------*/
|
960 |
|
|
/*!Unwind the stack pointer from a stack frame
|
961 |
|
|
|
962 |
|
|
This just uses the built in frame unwinder
|
963 |
|
|
|
964 |
|
|
@param[in] gdbarch The GDB architecture being used
|
965 |
|
|
@param[in] next_frame Frame info for the NEXT frame
|
966 |
|
|
|
967 |
|
|
@return The stack pointer for THIS frame */
|
968 |
|
|
/*---------------------------------------------------------------------------*/
|
969 |
|
|
|
970 |
|
|
static CORE_ADDR
|
971 |
|
|
or32_unwind_sp (struct gdbarch *gdbarch,
|
972 |
|
|
struct frame_info *next_frame)
|
973 |
|
|
{
|
974 |
|
|
CORE_ADDR sp = frame_unwind_register_unsigned (next_frame, OR32_SP_REGNUM);
|
975 |
|
|
|
976 |
|
|
return sp;
|
977 |
|
|
|
978 |
|
|
} /* or32_unwind_sp() */
|
979 |
|
|
|
980 |
|
|
|
981 |
|
|
/*----------------------------------------------------------------------------*/
|
982 |
|
|
/*!Create a dummy stack frame
|
983 |
|
|
|
984 |
|
|
The arguments are placed in registers and/or pushed on the stack as per the
|
985 |
|
|
OR32 ABI.
|
986 |
|
|
|
987 |
|
|
@param[in] gdbarch The architecture to use
|
988 |
|
|
@param[in] function Pointer to the function that will be called
|
989 |
|
|
@param[in] regcache The register cache to use
|
990 |
|
|
@param[in] bp_addr Breakpoint address
|
991 |
|
|
@param[in] nargs Number of ags to push
|
992 |
|
|
@param[in] args The arguments
|
993 |
|
|
@param[in] sp The stack pointer
|
994 |
|
|
@param[in] struct_return True (1) if this returns a structure
|
995 |
|
|
@param[in] struct_addr Address for returning structures
|
996 |
|
|
|
997 |
|
|
@return The updated stack pointer */
|
998 |
|
|
/*---------------------------------------------------------------------------*/
|
999 |
|
|
|
1000 |
|
|
static CORE_ADDR
|
1001 |
|
|
or32_push_dummy_call (struct gdbarch *gdbarch,
|
1002 |
|
|
struct value *function,
|
1003 |
|
|
struct regcache *regcache,
|
1004 |
|
|
CORE_ADDR bp_addr,
|
1005 |
|
|
int nargs,
|
1006 |
|
|
struct value **args,
|
1007 |
|
|
CORE_ADDR sp,
|
1008 |
|
|
int struct_return,
|
1009 |
|
|
CORE_ADDR struct_addr)
|
1010 |
|
|
{
|
1011 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
1012 |
|
|
|
1013 |
|
|
int argreg;
|
1014 |
|
|
int argnum;
|
1015 |
|
|
int first_stack_arg;
|
1016 |
|
|
int stack_offset = 0;
|
1017 |
|
|
|
1018 |
|
|
unsigned int bpa = (gdbarch_tdep (gdbarch))->bytes_per_address;
|
1019 |
|
|
unsigned int bpw = (gdbarch_tdep (gdbarch))->bytes_per_word;
|
1020 |
|
|
|
1021 |
|
|
/* Return address */
|
1022 |
|
|
regcache_cooked_write_unsigned (regcache, OR32_LR_REGNUM, bp_addr);
|
1023 |
|
|
|
1024 |
|
|
/* Register for the next argument */
|
1025 |
|
|
argreg = OR32_FIRST_ARG_REGNUM;
|
1026 |
|
|
|
1027 |
|
|
/* Location for a returned structure. This is passed as a silent first
|
1028 |
|
|
argument. */
|
1029 |
|
|
|
1030 |
|
|
if (struct_return)
|
1031 |
|
|
{
|
1032 |
|
|
regcache_cooked_write_unsigned (regcache, OR32_FIRST_ARG_REGNUM,
|
1033 |
|
|
struct_addr);
|
1034 |
|
|
argreg++;
|
1035 |
|
|
}
|
1036 |
|
|
|
1037 |
|
|
/* Put as many args as possible in registers */
|
1038 |
|
|
for (argnum = 0; argnum < nargs; argnum++)
|
1039 |
|
|
{
|
1040 |
|
|
char *val;
|
1041 |
|
|
char valbuf[sizeof (ULONGEST) ];
|
1042 |
|
|
|
1043 |
|
|
struct value *arg = args[argnum];
|
1044 |
|
|
struct type *arg_type = check_typedef (value_type (arg));
|
1045 |
|
|
int len = arg_type->length;
|
1046 |
|
|
enum type_code typecode = arg_type->main_type->code;
|
1047 |
|
|
|
1048 |
|
|
/* The EABI passes structures that do not fit in a register by
|
1049 |
|
|
reference. In all other cases, pass the structure by value. */
|
1050 |
|
|
if((len > bpw) &&
|
1051 |
|
|
((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)))
|
1052 |
|
|
{
|
1053 |
|
|
|
1054 |
|
|
store_unsigned_integer (valbuf, bpa, byte_order, value_offset (arg));
|
1055 |
|
|
len = bpa;
|
1056 |
|
|
val = valbuf;
|
1057 |
|
|
}
|
1058 |
|
|
else
|
1059 |
|
|
{
|
1060 |
|
|
val = (char *)value_contents (arg);
|
1061 |
|
|
}
|
1062 |
|
|
|
1063 |
|
|
if((len > bpw) && (argreg <= (OR32_LAST_ARG_REGNUM - 1)))
|
1064 |
|
|
{
|
1065 |
|
|
|
1066 |
|
|
/* Big scalars use two registers, but need NOT be pair aligned. This
|
1067 |
|
|
code breaks if we can have quad-word scalars (e.g. long
|
1068 |
|
|
double). */
|
1069 |
|
|
ULONGEST regval = extract_unsigned_integer (val, len, byte_order);
|
1070 |
|
|
|
1071 |
|
|
unsigned int bits_per_word = bpw * 8;
|
1072 |
|
|
ULONGEST mask = (((ULONGEST) 1) << bits_per_word) - 1;
|
1073 |
|
|
ULONGEST lo = regval & mask;
|
1074 |
|
|
ULONGEST hi = regval >> bits_per_word;
|
1075 |
|
|
|
1076 |
|
|
gdb_assert (len <= (bpw * 2));
|
1077 |
|
|
|
1078 |
|
|
regcache_cooked_write_unsigned (regcache, argreg, hi);
|
1079 |
|
|
regcache_cooked_write_unsigned (regcache, argreg + 1, lo);
|
1080 |
|
|
argreg += 2;
|
1081 |
|
|
}
|
1082 |
|
|
else if (argreg <= OR32_LAST_ARG_REGNUM)
|
1083 |
|
|
{
|
1084 |
|
|
printf ("Writing 0x%08llx to r%d\n",
|
1085 |
|
|
extract_unsigned_integer (val, len, byte_order), argreg);
|
1086 |
|
|
|
1087 |
|
|
regcache_cooked_write_unsigned (regcache, argreg,
|
1088 |
|
|
extract_unsigned_integer (val, len,
|
1089 |
|
|
byte_order));
|
1090 |
|
|
argreg++;
|
1091 |
|
|
}
|
1092 |
|
|
else
|
1093 |
|
|
{
|
1094 |
|
|
/* Run out of regs */
|
1095 |
|
|
break;
|
1096 |
|
|
}
|
1097 |
|
|
}
|
1098 |
|
|
|
1099 |
|
|
first_stack_arg = argnum;
|
1100 |
|
|
|
1101 |
|
|
/* If we get here with argnum < nargs, then arguments remain to be placed on
|
1102 |
|
|
the stack. This is tricky, since they must be pushed in reverse order and
|
1103 |
|
|
the stack in the end must be aligned. The only solution is to do it in
|
1104 |
|
|
two stages, the first to compute the stack size, the second to save the
|
1105 |
|
|
args. */
|
1106 |
|
|
|
1107 |
|
|
for (argnum = first_stack_arg; argnum < nargs; argnum++)
|
1108 |
|
|
{
|
1109 |
|
|
struct value *arg = args[argnum];
|
1110 |
|
|
struct type *arg_type = check_typedef (value_type (arg));
|
1111 |
|
|
int len = arg_type->length;
|
1112 |
|
|
enum type_code typecode = arg_type->main_type->code;
|
1113 |
|
|
|
1114 |
|
|
if((len > bpw) &&
|
1115 |
|
|
((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)))
|
1116 |
|
|
{
|
1117 |
|
|
/* Large structures are passed as addresses */
|
1118 |
|
|
sp -= bpa;
|
1119 |
|
|
}
|
1120 |
|
|
else
|
1121 |
|
|
{
|
1122 |
|
|
/* Big scalars use more than one word. Code here allows for future
|
1123 |
|
|
quad-word entities (e.g. long double) */
|
1124 |
|
|
sp -= ((len + bpw - 1) / bpw) * bpw;
|
1125 |
|
|
}
|
1126 |
|
|
}
|
1127 |
|
|
|
1128 |
|
|
sp = gdbarch_frame_align (gdbarch, sp);
|
1129 |
|
|
stack_offset = 0;
|
1130 |
|
|
|
1131 |
|
|
/* Push the remaining args on the stack */
|
1132 |
|
|
for (argnum = first_stack_arg; argnum < nargs; argnum++)
|
1133 |
|
|
{
|
1134 |
|
|
char *val;
|
1135 |
|
|
char valbuf[sizeof (ULONGEST) ];
|
1136 |
|
|
|
1137 |
|
|
struct value *arg = args[argnum];
|
1138 |
|
|
struct type *arg_type = check_typedef (value_type (arg));
|
1139 |
|
|
int len = arg_type->length;
|
1140 |
|
|
enum type_code typecode = arg_type->main_type->code;
|
1141 |
|
|
|
1142 |
|
|
/* The EABI passes structures that do not fit in a register by
|
1143 |
|
|
reference. In all other cases, pass the structure by value. */
|
1144 |
|
|
if((len > bpw) &&
|
1145 |
|
|
((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)))
|
1146 |
|
|
{
|
1147 |
|
|
|
1148 |
|
|
store_unsigned_integer (valbuf, bpa, byte_order, value_offset (arg));
|
1149 |
|
|
len = bpa;
|
1150 |
|
|
val = valbuf;
|
1151 |
|
|
}
|
1152 |
|
|
else
|
1153 |
|
|
{
|
1154 |
|
|
val = (char *)value_contents (arg);
|
1155 |
|
|
}
|
1156 |
|
|
|
1157 |
|
|
gdb_assert (len <= (bpw * 2));
|
1158 |
|
|
|
1159 |
|
|
write_memory (sp + stack_offset, val, len);
|
1160 |
|
|
stack_offset += ((len + bpw - 1) / bpw) * bpw;
|
1161 |
|
|
}
|
1162 |
|
|
|
1163 |
|
|
/* Save the updated stack pointer */
|
1164 |
|
|
regcache_cooked_write_unsigned (regcache, OR32_SP_REGNUM, sp);
|
1165 |
|
|
|
1166 |
|
|
return sp;
|
1167 |
|
|
|
1168 |
|
|
} /* or32_push_dummy_call() */
|
1169 |
|
|
|
1170 |
|
|
|
1171 |
|
|
/*----------------------------------------------------------------------------*/
|
1172 |
|
|
/*!Return the frame ID for a dummy stack frame
|
1173 |
|
|
|
1174 |
|
|
Tear down a dummy frame created by or32_push_dummy_call(). This data has to
|
1175 |
|
|
be constructed manually from the data in our hand.
|
1176 |
|
|
|
1177 |
|
|
The stack pointer and program counter can be obtained from the frame info.
|
1178 |
|
|
|
1179 |
|
|
@param[in] gdbarch The architecture to use
|
1180 |
|
|
@param[in] this_frame Information about this frame
|
1181 |
|
|
|
1182 |
|
|
@return Frame ID of this frame */
|
1183 |
|
|
/*---------------------------------------------------------------------------*/
|
1184 |
|
|
|
1185 |
|
|
static struct frame_id
|
1186 |
|
|
or32_dummy_id (struct gdbarch *gdbarch,
|
1187 |
|
|
struct frame_info *this_frame)
|
1188 |
|
|
{
|
1189 |
|
|
return frame_id_build (get_frame_sp (this_frame), get_frame_pc (this_frame));
|
1190 |
|
|
|
1191 |
|
|
} /* or32_dummy_id() */
|
1192 |
|
|
|
1193 |
|
|
|
1194 |
|
|
|
1195 |
|
|
|
1196 |
|
|
/* Support functions for frame handling */
|
1197 |
|
|
|
1198 |
|
|
/* -------------------------------------------------------------------------- */
|
1199 |
|
|
/*!Initialize a prologue cache
|
1200 |
|
|
|
1201 |
|
|
This function is changed from its GDB 6.8 version (named
|
1202 |
|
|
or32_frame_unwind_cache), in that it is based on THIS frame, not the NEXT
|
1203 |
|
|
frame.
|
1204 |
|
|
|
1205 |
|
|
We build a cache, saying where registers of the PREV frame can be found
|
1206 |
|
|
from the data so far set up in this THIS.
|
1207 |
|
|
|
1208 |
|
|
We also compute a unique ID for this frame, based on the function start
|
1209 |
|
|
address and the stack pointer (as it will be, even if it has yet to be
|
1210 |
|
|
computed.
|
1211 |
|
|
|
1212 |
|
|
STACK FORMAT
|
1213 |
|
|
============
|
1214 |
|
|
|
1215 |
|
|
The OR32 has a falling stack frame and a simple prolog. The Stack pointer
|
1216 |
|
|
is R1 and the frame pointer R2. The frame base is therefore the address
|
1217 |
|
|
held in R2 and the stack pointer (R1) is the frame base of the NEXT frame.
|
1218 |
|
|
|
1219 |
|
|
@verbatim
|
1220 |
|
|
l.addi r1,r1,-frame_size # SP now points to end of new stack frame
|
1221 |
|
|
@endverbatim
|
1222 |
|
|
|
1223 |
|
|
The stack pointer may not be set up in a frameless function (e.g. a simple
|
1224 |
|
|
leaf function).
|
1225 |
|
|
|
1226 |
|
|
@verbatim
|
1227 |
|
|
l.sw fp_loc(r1),r2 # old FP saved in new stack frame
|
1228 |
|
|
l.addi r2,r1,frame_size # FP now points to base of new stack frame
|
1229 |
|
|
@endverbatim
|
1230 |
|
|
|
1231 |
|
|
The frame pointer is not necessarily saved right at the end of the stack
|
1232 |
|
|
frame - OR32 saves enough space for any args to called functions right at
|
1233 |
|
|
the end (this is a difference from the Architecture Manual).
|
1234 |
|
|
|
1235 |
|
|
@verbatim
|
1236 |
|
|
l.sw lr_loc(r1),r9 # Link (return) address
|
1237 |
|
|
@endverbatim
|
1238 |
|
|
|
1239 |
|
|
The link register is usally saved at fp_loc - 4. It may not be saved at all
|
1240 |
|
|
in a leaf function.
|
1241 |
|
|
|
1242 |
|
|
@verbatim
|
1243 |
|
|
l.sw reg_loc(r1),ry # Save any callee saved regs
|
1244 |
|
|
@endverbatim
|
1245 |
|
|
|
1246 |
|
|
The offsets x for the callee saved registers generally (always?) rise in
|
1247 |
|
|
increments of 4, starting at fp_loc + 4. If the frame pointer is omitted
|
1248 |
|
|
(an option to GCC), then it may not be saved at all. There may be no callee
|
1249 |
|
|
saved registers.
|
1250 |
|
|
|
1251 |
|
|
So in summary none of this may be present. However what is present seems
|
1252 |
|
|
always to follow this fixed order, and occur before any substantive code
|
1253 |
|
|
(it is possible for GCC to have more flexible scheduling of the prologue,
|
1254 |
|
|
but this does not seem to occur for OR32).
|
1255 |
|
|
|
1256 |
|
|
ANALYSIS
|
1257 |
|
|
========
|
1258 |
|
|
|
1259 |
|
|
This prolog is used, even for -O3 with GCC.
|
1260 |
|
|
|
1261 |
|
|
All this analysis must allow for the possibility that the PC is in the
|
1262 |
|
|
middle of the prologue. Data in the cache should only be set up insofar as
|
1263 |
|
|
it has been computed.
|
1264 |
|
|
|
1265 |
|
|
HOWEVER. The frame_id must be created with the SP *as it will be* at the
|
1266 |
|
|
end of the Prologue. Otherwise a recursive call, checking the frame with
|
1267 |
|
|
the PC at the start address will end up with the same frame_id as the
|
1268 |
|
|
caller.
|
1269 |
|
|
|
1270 |
|
|
A suite of "helper" routines are used, allowing reuse for
|
1271 |
|
|
or32_skip_prologue().
|
1272 |
|
|
|
1273 |
|
|
Reportedly, this is only valid for frames less than 0x7fff in size.
|
1274 |
|
|
|
1275 |
|
|
@param[in] this_frame Our stack frame.
|
1276 |
|
|
@param[in,out] prologue_cache The prologue cache. If not supplied, we
|
1277 |
|
|
build it.
|
1278 |
|
|
|
1279 |
|
|
@return The prolog cache (duplicates the return through the argument) */
|
1280 |
|
|
/* ---------------------------------------------------------------------------*/
|
1281 |
|
|
static struct trad_frame_cache *
|
1282 |
|
|
or32_frame_cache (struct frame_info *this_frame,
|
1283 |
|
|
void **prologue_cache)
|
1284 |
|
|
{
|
1285 |
|
|
struct gdbarch *gdbarch;
|
1286 |
|
|
struct trad_frame_cache *info;
|
1287 |
|
|
|
1288 |
|
|
CORE_ADDR this_pc;
|
1289 |
|
|
CORE_ADDR this_sp;
|
1290 |
|
|
CORE_ADDR this_sp_for_id;
|
1291 |
|
|
int frame_size = 0;
|
1292 |
|
|
|
1293 |
|
|
CORE_ADDR start_addr;
|
1294 |
|
|
CORE_ADDR end_addr;
|
1295 |
|
|
|
1296 |
|
|
/* Nothing to do if we already have this info */
|
1297 |
|
|
if (NULL != *prologue_cache)
|
1298 |
|
|
{
|
1299 |
|
|
return *prologue_cache;
|
1300 |
|
|
}
|
1301 |
|
|
|
1302 |
|
|
/* Get a new prologue cache and populate it with default values */
|
1303 |
|
|
info = trad_frame_cache_zalloc (this_frame);
|
1304 |
|
|
*prologue_cache = info;
|
1305 |
|
|
|
1306 |
|
|
/* Find the start address of THIS function (which is a NORMAL frame, even if
|
1307 |
|
|
the NEXT frame is the sentinel frame) and the end of its prologue. */
|
1308 |
|
|
this_pc = get_frame_pc (this_frame);
|
1309 |
|
|
find_pc_partial_function (this_pc, NULL, &start_addr, NULL);
|
1310 |
|
|
|
1311 |
|
|
/* Return early if GDB couldn't find the function. */
|
1312 |
|
|
if (start_addr == 0)
|
1313 |
|
|
{
|
1314 |
|
|
return info;
|
1315 |
|
|
}
|
1316 |
|
|
|
1317 |
|
|
/* Get the stack pointer if we have one (if there's no process executing yet
|
1318 |
|
|
we won't have a frame. */
|
1319 |
|
|
this_sp = (NULL == this_frame) ? 0 :
|
1320 |
|
|
get_frame_register_unsigned (this_frame,
|
1321 |
|
|
OR32_SP_REGNUM);
|
1322 |
|
|
|
1323 |
|
|
/* The default frame base of THIS frame (for ID purposes only - frame base
|
1324 |
|
|
is an overloaded term) is its stack pointer. For now we use the value of
|
1325 |
|
|
the SP register in THIS frame. However if the PC is in the prologue of
|
1326 |
|
|
THIS frame, before the SP has been set up, then the value will actually
|
1327 |
|
|
be that of the PREV frame, and we'll need to adjust it later. */
|
1328 |
|
|
trad_frame_set_this_base (info, this_sp);
|
1329 |
|
|
this_sp_for_id = this_sp;
|
1330 |
|
|
|
1331 |
|
|
/* The default is to find the PC of the PREVIOUS frame in the link register
|
1332 |
|
|
of this frame. This may be changed if we find the link register was saved
|
1333 |
|
|
on the stack. */
|
1334 |
|
|
trad_frame_set_reg_realreg (info, OR32_NPC_REGNUM, OR32_LR_REGNUM);
|
1335 |
|
|
|
1336 |
|
|
/* We should only examine code that is in the prologue. This is all code up
|
1337 |
|
|
to (but not including) end_addr. We should only populate the cache while
|
1338 |
|
|
the address is up to (but not including) the PC or end_addr, whichever is
|
1339 |
|
|
first. */
|
1340 |
|
|
gdbarch = get_frame_arch (this_frame);
|
1341 |
|
|
end_addr = or32_skip_prologue (gdbarch, start_addr);
|
1342 |
|
|
|
1343 |
|
|
/* All the following analysis only occurs if we are in the prologue and have
|
1344 |
|
|
executed the code. Check we have a sane prologue size, and if zero we
|
1345 |
|
|
are frameless and can give up here. */
|
1346 |
|
|
if (end_addr < start_addr)
|
1347 |
|
|
{
|
1348 |
|
|
fatal ("end addr 0x%08x is less than start addr 0x%08x\n",
|
1349 |
|
|
(unsigned int) end_addr, (unsigned int) start_addr);
|
1350 |
|
|
}
|
1351 |
|
|
|
1352 |
|
|
if (end_addr == start_addr)
|
1353 |
|
|
{
|
1354 |
|
|
frame_size = 0;
|
1355 |
|
|
}
|
1356 |
|
|
else
|
1357 |
|
|
{
|
1358 |
|
|
/* have a frame. Look for the various components */
|
1359 |
|
|
CORE_ADDR addr = start_addr; /* Where we have got to */
|
1360 |
|
|
uint32_t inst = or32_fetch_instruction (gdbarch, addr);
|
1361 |
|
|
|
1362 |
|
|
unsigned int ra, rb, rd; /* For instruction analysis */
|
1363 |
|
|
int simm;
|
1364 |
|
|
|
1365 |
|
|
/* Look for the new stack pointer being set up. */
|
1366 |
|
|
if (or32_analyse_l_addi (inst, &rd, &ra, &simm) &&
|
1367 |
|
|
(OR32_SP_REGNUM == rd) && (OR32_SP_REGNUM == ra) &&
|
1368 |
|
|
(simm < 0) && (0 == (simm % 4)))
|
1369 |
|
|
{
|
1370 |
|
|
frame_size = -simm;
|
1371 |
|
|
addr += OR32_INSTLEN;
|
1372 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1373 |
|
|
|
1374 |
|
|
/* If the PC has not actually got to this point, then the frame base
|
1375 |
|
|
will be wrong, and we adjust it.
|
1376 |
|
|
|
1377 |
|
|
If we are past this point, then we need to populate the stack
|
1378 |
|
|
accoringly. */
|
1379 |
|
|
if (this_pc <= addr)
|
1380 |
|
|
{
|
1381 |
|
|
/* Only do if executing */
|
1382 |
|
|
if (0 != this_sp)
|
1383 |
|
|
{
|
1384 |
|
|
this_sp_for_id = this_sp + frame_size;
|
1385 |
|
|
trad_frame_set_this_base (info, this_sp_for_id);
|
1386 |
|
|
}
|
1387 |
|
|
}
|
1388 |
|
|
else
|
1389 |
|
|
{
|
1390 |
|
|
/* We are past this point, so the stack pointer of the PREV
|
1391 |
|
|
frame is frame_size greater than the stack pointer of THIS
|
1392 |
|
|
frame. */
|
1393 |
|
|
trad_frame_set_reg_value (info, OR32_SP_REGNUM,
|
1394 |
|
|
this_sp + frame_size);
|
1395 |
|
|
}
|
1396 |
|
|
}
|
1397 |
|
|
|
1398 |
|
|
/* From now on we are only populating the cache, so we stop once we get
|
1399 |
|
|
to either the end OR the current PC. */
|
1400 |
|
|
end_addr = (this_pc < end_addr) ? this_pc : end_addr;
|
1401 |
|
|
|
1402 |
|
|
/* Look for the frame pointer being manipulated. */
|
1403 |
|
|
if ((addr < end_addr) &&
|
1404 |
|
|
or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
1405 |
|
|
(OR32_SP_REGNUM == ra) && (OR32_FP_REGNUM == rb) &&
|
1406 |
|
|
(simm >= 0) && (0 == (simm % 4)))
|
1407 |
|
|
{
|
1408 |
|
|
addr += OR32_INSTLEN;
|
1409 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1410 |
|
|
|
1411 |
|
|
/* At this stage, we can find the frame pointer of the PREVIOUS
|
1412 |
|
|
frame on the stack of the current frame. */
|
1413 |
|
|
trad_frame_set_reg_addr (info, OR32_FP_REGNUM, this_sp + simm);
|
1414 |
|
|
|
1415 |
|
|
/* Look for the new frame pointer being set up */
|
1416 |
|
|
if (addr < end_addr)
|
1417 |
|
|
{
|
1418 |
|
|
gdb_assert (or32_analyse_l_addi (inst, &rd, &ra, &simm) &&
|
1419 |
|
|
(OR32_FP_REGNUM == rd) && (OR32_SP_REGNUM == ra) &&
|
1420 |
|
|
(simm == frame_size));
|
1421 |
|
|
|
1422 |
|
|
addr += OR32_INSTLEN;
|
1423 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1424 |
|
|
|
1425 |
|
|
/* If we have got this far, the stack pointer of the PREVIOUS
|
1426 |
|
|
frame is the frame pointer of THIS frame. */
|
1427 |
|
|
trad_frame_set_reg_realreg (info, OR32_SP_REGNUM, OR32_FP_REGNUM);
|
1428 |
|
|
}
|
1429 |
|
|
}
|
1430 |
|
|
|
1431 |
|
|
/* Look for the link register being saved */
|
1432 |
|
|
if ((addr < end_addr) &&
|
1433 |
|
|
or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
1434 |
|
|
(OR32_SP_REGNUM == ra) && (OR32_LR_REGNUM == rb) &&
|
1435 |
|
|
(simm >= 0) && (0 == (simm % 4)))
|
1436 |
|
|
{
|
1437 |
|
|
addr += OR32_INSTLEN;
|
1438 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1439 |
|
|
|
1440 |
|
|
/* If the link register is saved in the THIS frame, it holds the
|
1441 |
|
|
value of the PC in the PREVIOUS frame. This overwrites the
|
1442 |
|
|
previous information about finding the PC in the link
|
1443 |
|
|
register. */
|
1444 |
|
|
trad_frame_set_reg_addr (info, OR32_NPC_REGNUM, this_sp + simm);
|
1445 |
|
|
}
|
1446 |
|
|
|
1447 |
|
|
/* Look for arguments or callee-saved register being saved. The register
|
1448 |
|
|
must be one of the arguments (r3-r8) or the 10 callee saved registers
|
1449 |
|
|
(r10, r12, r14, r16, r18, r20, r22, r24, r26, r28, r30). The base
|
1450 |
|
|
register must be the FP (for the args) or the SP (for the
|
1451 |
|
|
callee_saved registers). */
|
1452 |
|
|
while (addr < end_addr)
|
1453 |
|
|
{
|
1454 |
|
|
if (or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
1455 |
|
|
(((OR32_FP_REGNUM == ra) && or32_is_arg_reg (rb)) ||
|
1456 |
|
|
((OR32_SP_REGNUM == ra) && or32_is_callee_saved_reg (rb))) &&
|
1457 |
|
|
(0 == (simm % 4)))
|
1458 |
|
|
{
|
1459 |
|
|
addr += OR32_INSTLEN;
|
1460 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1461 |
|
|
|
1462 |
|
|
/* The register in the PREVIOUS frame can be found at this
|
1463 |
|
|
location in THIS frame */
|
1464 |
|
|
trad_frame_set_reg_addr (info, rb, this_sp + simm);
|
1465 |
|
|
}
|
1466 |
|
|
else
|
1467 |
|
|
{
|
1468 |
|
|
break; /* Not a register save instruction */
|
1469 |
|
|
}
|
1470 |
|
|
}
|
1471 |
|
|
}
|
1472 |
|
|
|
1473 |
|
|
/* Build the frame ID */
|
1474 |
|
|
trad_frame_set_id (info, frame_id_build (this_sp_for_id, start_addr));
|
1475 |
|
|
|
1476 |
|
|
return info;
|
1477 |
|
|
|
1478 |
|
|
} /* or32_frame_cache() */
|
1479 |
|
|
|
1480 |
|
|
|
1481 |
|
|
/* -------------------------------------------------------------------------- */
|
1482 |
|
|
/*!Find the frame ID of this frame
|
1483 |
|
|
|
1484 |
|
|
This function has changed since GDB 6.8 to use THIS frame, rather than the
|
1485 |
|
|
NEXT frame.
|
1486 |
|
|
|
1487 |
|
|
Given a GDB frame, return its frame_id.
|
1488 |
|
|
|
1489 |
|
|
@param[in] this_frame Our frame, for which the ID is wanted.
|
1490 |
|
|
@param[in] prologue_cache Any cached prologue for THIS function.
|
1491 |
|
|
@param[out] this_id Frame ID of our own frame.
|
1492 |
|
|
|
1493 |
|
|
@return Frame ID for THIS frame */
|
1494 |
|
|
/* ------------------------------------------------------------------------- */
|
1495 |
|
|
static void
|
1496 |
|
|
or32_frame_this_id (struct frame_info *this_frame,
|
1497 |
|
|
void **prologue_cache,
|
1498 |
|
|
struct frame_id *this_id)
|
1499 |
|
|
{
|
1500 |
|
|
struct trad_frame_cache *info =
|
1501 |
|
|
or32_frame_cache (this_frame, prologue_cache);
|
1502 |
|
|
|
1503 |
|
|
trad_frame_get_id (info, this_id);
|
1504 |
|
|
|
1505 |
|
|
} /* or32_frame_this_id() */
|
1506 |
|
|
|
1507 |
|
|
|
1508 |
|
|
/*----------------------------------------------------------------------------*/
|
1509 |
|
|
/*!Get a register from the PREVIOUS frame
|
1510 |
|
|
|
1511 |
|
|
This function has changed from GDB 6.8. It now takes a reference to THIS
|
1512 |
|
|
frame, not the NEXT frame. It returns it results via a structure, not its
|
1513 |
|
|
argument list.
|
1514 |
|
|
|
1515 |
|
|
Given a pointer to the THIS frame, return the details of a register in the
|
1516 |
|
|
PREVIOUS frame.
|
1517 |
|
|
|
1518 |
|
|
@param[in] this_frame The stack frame under consideration
|
1519 |
|
|
@param[in] prologue_cache Any cached prologue associated with THIS frame,
|
1520 |
|
|
which may therefore tell us about registers in
|
1521 |
|
|
the PREVIOUS frame.
|
1522 |
|
|
@param[in] regnum The register of interest in the PREVIOUS frame
|
1523 |
|
|
|
1524 |
|
|
@return A value structure representing the register. */
|
1525 |
|
|
/* -------------------------------------------------------------------------- */
|
1526 |
|
|
static struct value *
|
1527 |
|
|
or32_frame_prev_register (struct frame_info *this_frame,
|
1528 |
|
|
void **prologue_cache,
|
1529 |
|
|
int regnum)
|
1530 |
|
|
{
|
1531 |
|
|
struct trad_frame_cache *info = or32_frame_cache (this_frame,
|
1532 |
|
|
prologue_cache);
|
1533 |
|
|
|
1534 |
|
|
return trad_frame_get_register (info, this_frame, regnum);
|
1535 |
|
|
|
1536 |
|
|
} /* or32_frame_prev_register() */
|
1537 |
|
|
|
1538 |
|
|
|
1539 |
|
|
/* -------------------------------------------------------------------------- */
|
1540 |
|
|
/*!Structure defining the OR32 frame unwind functions
|
1541 |
|
|
|
1542 |
|
|
Must be global (to this file), since referred to by multiple functions.
|
1543 |
|
|
|
1544 |
|
|
Since we are the fallback unwinder, we use the default frame sniffer, which
|
1545 |
|
|
always accepts the frame
|
1546 |
|
|
|
1547 |
|
|
This applies to NORMAL frames only. We provide the following functions.
|
1548 |
|
|
- to give the ID of THIS frame
|
1549 |
|
|
- to give the details of a register in PREVIOUS frame
|
1550 |
|
|
- a frame sniffer. */
|
1551 |
|
|
/* -------------------------------------------------------------------------- */
|
1552 |
|
|
static const struct frame_unwind or32_frame_unwind = {
|
1553 |
|
|
.type = NORMAL_FRAME,
|
1554 |
|
|
.this_id = or32_frame_this_id,
|
1555 |
|
|
.prev_register = or32_frame_prev_register,
|
1556 |
|
|
.unwind_data = NULL,
|
1557 |
|
|
.sniffer = default_frame_sniffer,
|
1558 |
|
|
.dealloc_cache = NULL,
|
1559 |
|
|
.prev_arch = NULL
|
1560 |
|
|
};
|
1561 |
|
|
|
1562 |
|
|
|
1563 |
|
|
/*----------------------------------------------------------------------------*/
|
1564 |
|
|
/*!Return the base address of the frame
|
1565 |
|
|
|
1566 |
|
|
The implementations has changed since GDB 6.8, since we are now provided
|
1567 |
|
|
with the address of THIS frame, rather than the NEXT frame.
|
1568 |
|
|
|
1569 |
|
|
For the OR32, the base address is the frame pointer
|
1570 |
|
|
|
1571 |
|
|
@param[in] this_frame The current stack frame.
|
1572 |
|
|
@param[in] prologue_cache Any cached prologue for THIS function.
|
1573 |
|
|
|
1574 |
|
|
@return The frame base address */
|
1575 |
|
|
/*---------------------------------------------------------------------------*/
|
1576 |
|
|
|
1577 |
|
|
static CORE_ADDR
|
1578 |
|
|
or32_frame_base_address (struct frame_info *this_frame,
|
1579 |
|
|
void **prologue_cache)
|
1580 |
|
|
{
|
1581 |
|
|
return (CORE_ADDR) get_frame_register_unsigned (this_frame, OR32_FP_REGNUM);
|
1582 |
|
|
|
1583 |
|
|
} /* or32_frame_base_address() */
|
1584 |
|
|
|
1585 |
|
|
|
1586 |
|
|
/* -------------------------------------------------------------------------- */
|
1587 |
|
|
/*!Identify our frame base sniffer functions
|
1588 |
|
|
|
1589 |
|
|
This function just identifies our family of frame sniffing functions.
|
1590 |
|
|
|
1591 |
|
|
@param[in] this_frame The frame of THIS function. Not used here.
|
1592 |
|
|
|
1593 |
|
|
@return A pointer to a struct identifying the frame base sniffing
|
1594 |
|
|
functions. */
|
1595 |
|
|
/* -------------------------------------------------------------------------- */
|
1596 |
|
|
static const struct frame_base *
|
1597 |
|
|
or32_frame_base_sniffer (struct frame_info *this_frame)
|
1598 |
|
|
{
|
1599 |
|
|
/* Structure defining how the frame base is to be identified. */
|
1600 |
|
|
static const struct frame_base or32_frame_base =
|
1601 |
|
|
{
|
1602 |
|
|
.unwind = &or32_frame_unwind,
|
1603 |
|
|
.this_base = or32_frame_base_address,
|
1604 |
|
|
.this_locals = or32_frame_base_address,
|
1605 |
|
|
.this_args = or32_frame_base_address
|
1606 |
|
|
};
|
1607 |
|
|
|
1608 |
|
|
return &or32_frame_base;
|
1609 |
|
|
|
1610 |
|
|
} /* or32_frame_base_sniffer () */
|
1611 |
|
|
|
1612 |
|
|
|
1613 |
|
|
/* -------------------------------------------------------------------------- */
|
1614 |
|
|
/*!Architecture initialization for OpenRISC 1000
|
1615 |
|
|
|
1616 |
|
|
Looks for a candidate architecture in the list of architectures supplied
|
1617 |
|
|
using the info supplied. If none match, create a new architecture.
|
1618 |
|
|
|
1619 |
|
|
@param[in] info Information about the target architecture
|
1620 |
|
|
@param[in] arches The list of currently know architectures
|
1621 |
|
|
|
1622 |
|
|
@return A structure describing the target architecture */
|
1623 |
|
|
/* -------------------------------------------------------------------------- */
|
1624 |
|
|
static struct gdbarch *
|
1625 |
|
|
or32_gdbarch_init (struct gdbarch_info info,
|
1626 |
|
|
struct gdbarch_list *arches)
|
1627 |
|
|
{
|
1628 |
|
|
static struct frame_base or32_frame_base;
|
1629 |
|
|
struct gdbarch *gdbarch;
|
1630 |
|
|
struct gdbarch_tdep *tdep;
|
1631 |
|
|
const struct bfd_arch_info *binfo;
|
1632 |
|
|
|
1633 |
|
|
/* Find a candidate among the list of pre-declared architectures. */
|
1634 |
|
|
arches = gdbarch_list_lookup_by_info (arches, &info);
|
1635 |
|
|
if (NULL != arches)
|
1636 |
|
|
{
|
1637 |
|
|
return arches->gdbarch;
|
1638 |
|
|
}
|
1639 |
|
|
|
1640 |
|
|
/* None found, create a new architecture from the information
|
1641 |
|
|
provided. Can't initialize all the target dependencies until we actually
|
1642 |
|
|
know which target we are talking to, but put in some defaults for now. */
|
1643 |
|
|
|
1644 |
|
|
binfo = info.bfd_arch_info;
|
1645 |
|
|
tdep = xmalloc (sizeof *tdep);
|
1646 |
|
|
tdep->num_matchpoints = OR32_MAX_MATCHPOINTS;
|
1647 |
|
|
tdep->num_gpr_regs = OR32_MAX_GPR_REGS;
|
1648 |
|
|
tdep->bytes_per_word = binfo->bits_per_word / binfo->bits_per_byte;
|
1649 |
|
|
tdep->bytes_per_address = binfo->bits_per_address / binfo->bits_per_byte;
|
1650 |
|
|
gdbarch = gdbarch_alloc (&info, tdep);
|
1651 |
|
|
|
1652 |
|
|
/* Target data types. */
|
1653 |
|
|
set_gdbarch_short_bit (gdbarch, 16);
|
1654 |
|
|
set_gdbarch_int_bit (gdbarch, 32);
|
1655 |
|
|
set_gdbarch_long_bit (gdbarch, 32);
|
1656 |
|
|
set_gdbarch_long_long_bit (gdbarch, 64);
|
1657 |
|
|
set_gdbarch_float_bit (gdbarch, 32);
|
1658 |
|
|
set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
|
1659 |
|
|
set_gdbarch_double_bit (gdbarch, 64);
|
1660 |
|
|
set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
|
1661 |
|
|
set_gdbarch_long_double_bit (gdbarch, 64);
|
1662 |
|
|
set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
|
1663 |
|
|
set_gdbarch_ptr_bit (gdbarch, binfo->bits_per_address);
|
1664 |
|
|
set_gdbarch_addr_bit (gdbarch, binfo->bits_per_address);
|
1665 |
|
|
set_gdbarch_char_signed (gdbarch, 1);
|
1666 |
|
|
|
1667 |
|
|
/* Information about the target architecture */
|
1668 |
|
|
set_gdbarch_return_value (gdbarch, or32_return_value);
|
1669 |
|
|
set_gdbarch_breakpoint_from_pc (gdbarch, or32_breakpoint_from_pc);
|
1670 |
|
|
set_gdbarch_single_step_through_delay
|
1671 |
|
|
(gdbarch, or32_single_step_through_delay);
|
1672 |
|
|
set_gdbarch_have_nonsteppable_watchpoint
|
1673 |
|
|
(gdbarch, 1);
|
1674 |
|
|
switch (gdbarch_byte_order (gdbarch))
|
1675 |
|
|
{
|
1676 |
|
|
case BFD_ENDIAN_BIG:
|
1677 |
|
|
set_gdbarch_print_insn (gdbarch, print_insn_big_or32);
|
1678 |
|
|
break;
|
1679 |
|
|
|
1680 |
|
|
case BFD_ENDIAN_LITTLE:
|
1681 |
|
|
set_gdbarch_print_insn (gdbarch, print_insn_little_or32);
|
1682 |
|
|
break;
|
1683 |
|
|
|
1684 |
|
|
case BFD_ENDIAN_UNKNOWN:
|
1685 |
|
|
error ("or32_gdbarch_init: Unknown endianness");
|
1686 |
|
|
break;
|
1687 |
|
|
}
|
1688 |
|
|
|
1689 |
|
|
/* Register architecture */
|
1690 |
|
|
set_gdbarch_pseudo_register_read (gdbarch, or32_pseudo_register_read);
|
1691 |
|
|
set_gdbarch_pseudo_register_write (gdbarch, or32_pseudo_register_write);
|
1692 |
|
|
set_gdbarch_num_regs (gdbarch, OR32_NUM_REGS);
|
1693 |
|
|
set_gdbarch_num_pseudo_regs (gdbarch, OR32_NUM_PSEUDO_REGS);
|
1694 |
|
|
set_gdbarch_sp_regnum (gdbarch, OR32_SP_REGNUM);
|
1695 |
|
|
set_gdbarch_pc_regnum (gdbarch, OR32_NPC_REGNUM);
|
1696 |
|
|
set_gdbarch_ps_regnum (gdbarch, OR32_SR_REGNUM);
|
1697 |
|
|
set_gdbarch_deprecated_fp_regnum (gdbarch, OR32_FP_REGNUM);
|
1698 |
|
|
|
1699 |
|
|
/* Functions to supply register information */
|
1700 |
|
|
set_gdbarch_register_name (gdbarch, or32_register_name);
|
1701 |
|
|
set_gdbarch_register_type (gdbarch, or32_register_type);
|
1702 |
|
|
set_gdbarch_print_registers_info (gdbarch, or32_registers_info);
|
1703 |
|
|
set_gdbarch_register_reggroup_p (gdbarch, or32_register_reggroup_p);
|
1704 |
|
|
|
1705 |
|
|
/* Functions to analyse frames */
|
1706 |
|
|
set_gdbarch_skip_prologue (gdbarch, or32_skip_prologue);
|
1707 |
|
|
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
|
1708 |
|
|
set_gdbarch_frame_align (gdbarch, or32_frame_align);
|
1709 |
|
|
set_gdbarch_frame_red_zone_size (gdbarch, OR32_FRAME_RED_ZONE_SIZE);
|
1710 |
|
|
|
1711 |
|
|
/* Functions to access frame data */
|
1712 |
|
|
set_gdbarch_unwind_pc (gdbarch, or32_unwind_pc);
|
1713 |
|
|
set_gdbarch_unwind_sp (gdbarch, or32_unwind_sp);
|
1714 |
|
|
|
1715 |
|
|
/* Functions handling dummy frames */
|
1716 |
|
|
set_gdbarch_push_dummy_call (gdbarch, or32_push_dummy_call);
|
1717 |
|
|
set_gdbarch_dummy_id (gdbarch, or32_dummy_id);
|
1718 |
|
|
|
1719 |
|
|
/* Set up sniffers for the frame base. Use DWARF debug info if available,
|
1720 |
|
|
otherwise use our own sniffer. */
|
1721 |
|
|
frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
|
1722 |
|
|
frame_base_append_sniffer (gdbarch, or32_frame_base_sniffer);
|
1723 |
|
|
|
1724 |
|
|
/* Frame unwinders. Use DWARF debug info if available, otherwise use our
|
1725 |
|
|
own unwinder. */
|
1726 |
|
|
dwarf2_append_unwinders (gdbarch);
|
1727 |
|
|
frame_unwind_append_unwinder (gdbarch, &or32_frame_unwind);
|
1728 |
|
|
|
1729 |
|
|
return gdbarch;
|
1730 |
|
|
|
1731 |
|
|
} /* or32_gdbarch_init() */
|
1732 |
|
|
|
1733 |
|
|
|
1734 |
|
|
/*----------------------------------------------------------------------------*/
|
1735 |
|
|
/*!Dump the target specific data for this architecture
|
1736 |
|
|
|
1737 |
|
|
@param[in] gdbarch The architecture of interest
|
1738 |
|
|
@param[in] file Where to dump the data */
|
1739 |
|
|
/*---------------------------------------------------------------------------*/
|
1740 |
|
|
|
1741 |
|
|
static void
|
1742 |
|
|
or32_dump_tdep (struct gdbarch *gdbarch,
|
1743 |
|
|
struct ui_file *file)
|
1744 |
|
|
{
|
1745 |
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
1746 |
|
|
|
1747 |
|
|
if (NULL == tdep)
|
1748 |
|
|
{
|
1749 |
|
|
return; /* Nothing to report */
|
1750 |
|
|
}
|
1751 |
|
|
|
1752 |
|
|
fprintf_unfiltered (file, "or32_dump_tdep: %d matchpoints available\n",
|
1753 |
|
|
tdep->num_matchpoints);
|
1754 |
|
|
fprintf_unfiltered (file, "or32_dump_tdep: %d general purpose registers\n",
|
1755 |
|
|
tdep->num_gpr_regs);
|
1756 |
|
|
fprintf_unfiltered (file, "or32_dump_tdep: %d bytes per word\n",
|
1757 |
|
|
tdep->bytes_per_word);
|
1758 |
|
|
fprintf_unfiltered (file, "or32_dump_tdep: %d bytes per address\n",
|
1759 |
|
|
tdep->bytes_per_address);
|
1760 |
|
|
|
1761 |
|
|
} /* or32_dump_tdep() */
|
1762 |
|
|
|
1763 |
|
|
|
1764 |
|
|
|
1765 |
|
|
/* Functions to add extra commands to GDB */
|
1766 |
|
|
|
1767 |
|
|
|
1768 |
|
|
/*----------------------------------------------------------------------------*/
|
1769 |
|
|
/*!Returns a special purpose register group name
|
1770 |
|
|
|
1771 |
|
|
@param[in] group The SPR group number
|
1772 |
|
|
|
1773 |
|
|
@return The SPR name (pointer to the name argument) */
|
1774 |
|
|
/*---------------------------------------------------------------------------*/
|
1775 |
|
|
|
1776 |
|
|
static const char *
|
1777 |
|
|
or32_spr_group_name (int group)
|
1778 |
|
|
{
|
1779 |
|
|
static const char *or32_group_names[OR32_NUM_SPGS] =
|
1780 |
|
|
{
|
1781 |
|
|
"SYS",
|
1782 |
|
|
"DMMU",
|
1783 |
|
|
"IMMU",
|
1784 |
|
|
"DCACHE",
|
1785 |
|
|
"ICACHE",
|
1786 |
|
|
"MAC",
|
1787 |
|
|
"DEBUG",
|
1788 |
|
|
"PERF",
|
1789 |
|
|
"POWER",
|
1790 |
|
|
"PIC",
|
1791 |
|
|
"TIMER",
|
1792 |
|
|
"FPU"
|
1793 |
|
|
};
|
1794 |
|
|
|
1795 |
|
|
if ((0 <= group) && (group < OR32_NUM_SPGS))
|
1796 |
|
|
{
|
1797 |
|
|
return or32_group_names[group];
|
1798 |
|
|
}
|
1799 |
|
|
else
|
1800 |
|
|
{
|
1801 |
|
|
return "";
|
1802 |
|
|
}
|
1803 |
|
|
} /* or32_spr_group_name() */
|
1804 |
|
|
|
1805 |
|
|
|
1806 |
|
|
/*----------------------------------------------------------------------------*/
|
1807 |
|
|
/*!Returns a special purpose register name
|
1808 |
|
|
|
1809 |
|
|
@param[in] group The SPR group
|
1810 |
|
|
@param[in] index The index within the SPR group
|
1811 |
|
|
@param[out] name Array to put the name in
|
1812 |
|
|
|
1813 |
|
|
@return The SPR name (pointer to the name argument) */
|
1814 |
|
|
/*---------------------------------------------------------------------------*/
|
1815 |
|
|
|
1816 |
|
|
static char *
|
1817 |
|
|
or32_spr_register_name (int group,
|
1818 |
|
|
int index,
|
1819 |
|
|
char *name)
|
1820 |
|
|
{
|
1821 |
|
|
char di;
|
1822 |
|
|
|
1823 |
|
|
switch (group)
|
1824 |
|
|
{
|
1825 |
|
|
|
1826 |
|
|
case OR32_SPG_SYS:
|
1827 |
|
|
/* 1:1 names */
|
1828 |
|
|
switch (index)
|
1829 |
|
|
{
|
1830 |
|
|
case OR32_SPG_SYS_VR: sprintf (name, "VR" ); return name;
|
1831 |
|
|
case OR32_SPG_SYS_UPR: sprintf (name, "UPR" ); return name;
|
1832 |
|
|
case OR32_SPG_SYS_CPUCFGR: sprintf (name, "CPUCFGR" ); return name;
|
1833 |
|
|
case OR32_SPG_SYS_DMMUCFGR: sprintf (name, "DMMUCFGR"); return name;
|
1834 |
|
|
case OR32_SPG_SYS_IMMUCFGR: sprintf (name, "IMMUCFGR"); return name;
|
1835 |
|
|
case OR32_SPG_SYS_DCCFGR: sprintf (name, "DCCFGR" ); return name;
|
1836 |
|
|
case OR32_SPG_SYS_ICCFGR: sprintf (name, "ICCFGR" ); return name;
|
1837 |
|
|
case OR32_SPG_SYS_DCFGR: sprintf (name, "DCFGR" ); return name;
|
1838 |
|
|
case OR32_SPG_SYS_PCCFGR: sprintf (name, "PCCFGR" ); return name;
|
1839 |
|
|
case OR32_SPG_SYS_NPC: sprintf (name, "NPC" ); return name;
|
1840 |
|
|
case OR32_SPG_SYS_SR: sprintf (name, "SR" ); return name;
|
1841 |
|
|
case OR32_SPG_SYS_PPC: sprintf (name, "PPC" ); return name;
|
1842 |
|
|
case OR32_SPG_SYS_FPCSR: sprintf (name, "FPCSR" ); return name;
|
1843 |
|
|
}
|
1844 |
|
|
|
1845 |
|
|
/* Exception PC regs */
|
1846 |
|
|
if((OR32_SPG_SYS_EPCR <= index) &&
|
1847 |
|
|
(index <= OR32_SPG_SYS_EPCR_END))
|
1848 |
|
|
{
|
1849 |
|
|
sprintf (name, "EPCR%d", index - OR32_SPG_SYS_EPCR);
|
1850 |
|
|
return name;
|
1851 |
|
|
}
|
1852 |
|
|
|
1853 |
|
|
/* Exception EA regs */
|
1854 |
|
|
if((OR32_SPG_SYS_EEAR <= index) &&
|
1855 |
|
|
(index <= OR32_SPG_SYS_EEAR_END))
|
1856 |
|
|
{
|
1857 |
|
|
sprintf (name, "EEAR%d", index - OR32_SPG_SYS_EEAR);
|
1858 |
|
|
return name;
|
1859 |
|
|
}
|
1860 |
|
|
|
1861 |
|
|
/* Exception SR regs */
|
1862 |
|
|
if((OR32_SPG_SYS_ESR <= index) &&
|
1863 |
|
|
(index <= OR32_SPG_SYS_ESR_END))
|
1864 |
|
|
{
|
1865 |
|
|
sprintf (name, "ESR%d", index - OR32_SPG_SYS_ESR);
|
1866 |
|
|
return name;
|
1867 |
|
|
}
|
1868 |
|
|
|
1869 |
|
|
/* GPRs */
|
1870 |
|
|
if((OR32_SPG_SYS_GPR <= index) &&
|
1871 |
|
|
(index <= OR32_SPG_SYS_GPR_END))
|
1872 |
|
|
{
|
1873 |
|
|
sprintf (name, "GPR%d", index - OR32_SPG_SYS_GPR);
|
1874 |
|
|
return name;
|
1875 |
|
|
}
|
1876 |
|
|
|
1877 |
|
|
break;
|
1878 |
|
|
|
1879 |
|
|
case OR32_SPG_DMMU:
|
1880 |
|
|
case OR32_SPG_IMMU:
|
1881 |
|
|
/* MMU registers. Use DMMU constants throughout, but these are identical
|
1882 |
|
|
to the corresponding IMMU constants */
|
1883 |
|
|
di = OR32_SPG_DMMU == group ? 'D' : 'I';
|
1884 |
|
|
|
1885 |
|
|
/* 1:1 names */
|
1886 |
|
|
switch (index)
|
1887 |
|
|
{
|
1888 |
|
|
case OR32_SPG_DMMU_DMMUCR:
|
1889 |
|
|
sprintf (name, "%cMMUCR", di); return name;
|
1890 |
|
|
case OR32_SPG_DMMU_DMMUPR:
|
1891 |
|
|
sprintf (name, "%cMMUPR", di); return name;
|
1892 |
|
|
case OR32_SPG_DMMU_DTLBEIR:
|
1893 |
|
|
sprintf (name, "%cTLBEIR", di); return name;
|
1894 |
|
|
}
|
1895 |
|
|
|
1896 |
|
|
/* ATB Match registers */
|
1897 |
|
|
if((OR32_SPG_DMMU_DATBMR <= index) &&
|
1898 |
|
|
(index <= OR32_SPG_DMMU_DATBMR_END))
|
1899 |
|
|
{
|
1900 |
|
|
sprintf (name, "%cATBMR%d", di, index - OR32_SPG_DMMU_DATBMR);
|
1901 |
|
|
return name;
|
1902 |
|
|
}
|
1903 |
|
|
|
1904 |
|
|
/* ATB Translate registers */
|
1905 |
|
|
if((OR32_SPG_DMMU_DATBTR <= index) &&
|
1906 |
|
|
(index <= OR32_SPG_DMMU_DATBTR_END))
|
1907 |
|
|
{
|
1908 |
|
|
sprintf (name, "%cATBTR%d", di, index - OR32_SPG_DMMU_DATBTR);
|
1909 |
|
|
return name;
|
1910 |
|
|
}
|
1911 |
|
|
|
1912 |
|
|
/* TLB Way 1 Match registers */
|
1913 |
|
|
if((OR32_SPG_DMMU_DTLBW1MR <= index) &&
|
1914 |
|
|
(index <= OR32_SPG_DMMU_DTLBW1MR_END))
|
1915 |
|
|
{
|
1916 |
|
|
sprintf (name, "%cTLBW1MR%d", di, index - OR32_SPG_DMMU_DTLBW1MR);
|
1917 |
|
|
return name;
|
1918 |
|
|
}
|
1919 |
|
|
|
1920 |
|
|
/* TLB Way 1 Translate registers */
|
1921 |
|
|
if((OR32_SPG_DMMU_DTLBW1TR <= index) &&
|
1922 |
|
|
(index <= OR32_SPG_DMMU_DTLBW1TR_END))
|
1923 |
|
|
{
|
1924 |
|
|
sprintf (name, "%cTLBW1TR%d", di, index - OR32_SPG_DMMU_DTLBW1TR);
|
1925 |
|
|
return name;
|
1926 |
|
|
}
|
1927 |
|
|
|
1928 |
|
|
/* TLB Way 2 Match registers */
|
1929 |
|
|
if((OR32_SPG_DMMU_DTLBW2MR <= index) &&
|
1930 |
|
|
(index <= OR32_SPG_DMMU_DTLBW2MR_END))
|
1931 |
|
|
{
|
1932 |
|
|
sprintf (name, "%cTLBW2MR%d", di, index - OR32_SPG_DMMU_DTLBW2MR);
|
1933 |
|
|
return name;
|
1934 |
|
|
}
|
1935 |
|
|
|
1936 |
|
|
/* TLB Way 2 Translate registers */
|
1937 |
|
|
if((OR32_SPG_DMMU_DTLBW2TR <= index) &&
|
1938 |
|
|
(index <= OR32_SPG_DMMU_DTLBW2TR_END))
|
1939 |
|
|
{
|
1940 |
|
|
sprintf (name, "%cTLBW2TR%d", di, index - OR32_SPG_DMMU_DTLBW2TR);
|
1941 |
|
|
return name;
|
1942 |
|
|
}
|
1943 |
|
|
|
1944 |
|
|
/* TLB Way 3 Match registers */
|
1945 |
|
|
if((OR32_SPG_DMMU_DTLBW3MR <= index) &&
|
1946 |
|
|
(index <= OR32_SPG_DMMU_DTLBW3MR_END))
|
1947 |
|
|
{
|
1948 |
|
|
sprintf (name, "%cTLBW3MR%d", di, index - OR32_SPG_DMMU_DTLBW3MR);
|
1949 |
|
|
return name;
|
1950 |
|
|
}
|
1951 |
|
|
|
1952 |
|
|
/* TLB Way 3 Translate registers */
|
1953 |
|
|
if((OR32_SPG_DMMU_DTLBW3TR <= index) &&
|
1954 |
|
|
(index <= OR32_SPG_DMMU_DTLBW3TR_END))
|
1955 |
|
|
{
|
1956 |
|
|
sprintf (name, "%cTLBW3TR%d", di, index - OR32_SPG_DMMU_DTLBW3TR);
|
1957 |
|
|
return name;
|
1958 |
|
|
}
|
1959 |
|
|
|
1960 |
|
|
break;
|
1961 |
|
|
|
1962 |
|
|
case OR32_SPG_DC:
|
1963 |
|
|
/* Data cache registers. These do not have an exact correspondence with
|
1964 |
|
|
their instruction cache counterparts, so must be done separately. */
|
1965 |
|
|
|
1966 |
|
|
/* 1:1 names */
|
1967 |
|
|
switch (index)
|
1968 |
|
|
{
|
1969 |
|
|
case OR32_SPG_DC_DCCR: sprintf (name, "DCCR" ); return name;
|
1970 |
|
|
case OR32_SPG_DC_DCBPR: sprintf (name, "DCBPR"); return name;
|
1971 |
|
|
case OR32_SPG_DC_DCBFR: sprintf (name, "DCBFR"); return name;
|
1972 |
|
|
case OR32_SPG_DC_DCBIR: sprintf (name, "DCBIR"); return name;
|
1973 |
|
|
case OR32_SPG_DC_DCBWR: sprintf (name, "DCBWR"); return name;
|
1974 |
|
|
case OR32_SPG_DC_DCBLR: sprintf (name, "DCBLR"); return name;
|
1975 |
|
|
}
|
1976 |
|
|
|
1977 |
|
|
break;
|
1978 |
|
|
|
1979 |
|
|
case OR32_SPG_IC:
|
1980 |
|
|
/* Instruction cache registers */
|
1981 |
|
|
|
1982 |
|
|
/* 1:1 names */
|
1983 |
|
|
switch (index)
|
1984 |
|
|
{
|
1985 |
|
|
case OR32_SPG_IC_ICCR: sprintf (name, "ICCR" ); return name;
|
1986 |
|
|
case OR32_SPG_IC_ICBPR: sprintf (name, "ICBPR"); return name;
|
1987 |
|
|
case OR32_SPG_IC_ICBIR: sprintf (name, "ICBIR"); return name;
|
1988 |
|
|
case OR32_SPG_IC_ICBLR: sprintf (name, "ICBLR"); return name;
|
1989 |
|
|
}
|
1990 |
|
|
|
1991 |
|
|
break;
|
1992 |
|
|
|
1993 |
|
|
case OR32_SPG_MAC:
|
1994 |
|
|
/* MAC registers */
|
1995 |
|
|
|
1996 |
|
|
/* 1:1 names */
|
1997 |
|
|
switch (index)
|
1998 |
|
|
{
|
1999 |
|
|
case OR32_SPG_MAC_MACLO: sprintf (name, "MACLO"); return name;
|
2000 |
|
|
case OR32_SPG_MAC_MACHI: sprintf (name, "MACHI"); return name;
|
2001 |
|
|
}
|
2002 |
|
|
|
2003 |
|
|
break;
|
2004 |
|
|
|
2005 |
|
|
case OR32_SPG_DEBUG:
|
2006 |
|
|
/* Debug registers */
|
2007 |
|
|
|
2008 |
|
|
/* Debug Value registers */
|
2009 |
|
|
if((OR32_SPG_DEBUG_DVR <= index) &&
|
2010 |
|
|
(index <= OR32_SPG_DEBUG_DVR_END))
|
2011 |
|
|
{
|
2012 |
|
|
sprintf (name, "DVR%d", index - OR32_SPG_DEBUG_DVR);
|
2013 |
|
|
return name;
|
2014 |
|
|
}
|
2015 |
|
|
|
2016 |
|
|
/* Debug Control registers */
|
2017 |
|
|
if((OR32_SPG_DEBUG_DCR <= index) &&
|
2018 |
|
|
(index <= OR32_SPG_DEBUG_DCR_END))
|
2019 |
|
|
{
|
2020 |
|
|
sprintf (name, "DCR%d", index - OR32_SPG_DEBUG_DCR);
|
2021 |
|
|
return name;
|
2022 |
|
|
}
|
2023 |
|
|
|
2024 |
|
|
/* 1:1 names */
|
2025 |
|
|
switch (index)
|
2026 |
|
|
{
|
2027 |
|
|
case OR32_SPG_DEBUG_DMR1: sprintf (name, "DMR1" ); return name;
|
2028 |
|
|
case OR32_SPG_DEBUG_DMR2: sprintf (name, "DMR2" ); return name;
|
2029 |
|
|
case OR32_SPG_DEBUG_DCWR0: sprintf (name, "DCWR0"); return name;
|
2030 |
|
|
case OR32_SPG_DEBUG_DCWR1: sprintf (name, "DCWR1"); return name;
|
2031 |
|
|
case OR32_SPG_DEBUG_DSR: sprintf (name, "DSR" ); return name;
|
2032 |
|
|
case OR32_SPG_DEBUG_DRR: sprintf (name, "DRR" ); return name;
|
2033 |
|
|
}
|
2034 |
|
|
|
2035 |
|
|
break;
|
2036 |
|
|
|
2037 |
|
|
case OR32_SPG_PC:
|
2038 |
|
|
/* Performance Counter registers */
|
2039 |
|
|
|
2040 |
|
|
/* Performance Counters Count registers */
|
2041 |
|
|
if((OR32_SPG_PC_PCCR <= index) &&
|
2042 |
|
|
(index <= OR32_SPG_PC_PCCR_END))
|
2043 |
|
|
{
|
2044 |
|
|
sprintf (name, "PCCR%d", index - OR32_SPG_PC_PCCR);
|
2045 |
|
|
return name;
|
2046 |
|
|
}
|
2047 |
|
|
|
2048 |
|
|
/* Performance Counters Mode registers */
|
2049 |
|
|
if((OR32_SPG_PC_PCMR <= index) &&
|
2050 |
|
|
(index <= OR32_SPG_PC_PCMR_END))
|
2051 |
|
|
{
|
2052 |
|
|
sprintf (name, "PCMR%d", index - OR32_SPG_PC_PCMR);
|
2053 |
|
|
return name;
|
2054 |
|
|
}
|
2055 |
|
|
|
2056 |
|
|
break;
|
2057 |
|
|
|
2058 |
|
|
case OR32_SPG_PM:
|
2059 |
|
|
/* Power Management registers */
|
2060 |
|
|
|
2061 |
|
|
/* 1:1 names */
|
2062 |
|
|
switch (index)
|
2063 |
|
|
{
|
2064 |
|
|
case OR32_SPG_PM_PMR: sprintf (name, "PMR"); return name;
|
2065 |
|
|
}
|
2066 |
|
|
|
2067 |
|
|
break;
|
2068 |
|
|
|
2069 |
|
|
case OR32_SPG_PIC:
|
2070 |
|
|
/* Programmable Interrupt Controller registers */
|
2071 |
|
|
|
2072 |
|
|
/* 1:1 names */
|
2073 |
|
|
switch (index)
|
2074 |
|
|
{
|
2075 |
|
|
case OR32_SPG_PIC_PICMR: sprintf (name, "PICMR"); return name;
|
2076 |
|
|
case OR32_SPG_PIC_PICSR: sprintf (name, "PICSR"); return name;
|
2077 |
|
|
}
|
2078 |
|
|
|
2079 |
|
|
break;
|
2080 |
|
|
|
2081 |
|
|
case OR32_SPG_TT:
|
2082 |
|
|
/* Tick Timer registers */
|
2083 |
|
|
|
2084 |
|
|
/* 1:1 names */
|
2085 |
|
|
switch (index)
|
2086 |
|
|
{
|
2087 |
|
|
case OR32_SPG_TT_TTMR: sprintf (name, "TTMR"); return name;
|
2088 |
|
|
case OR32_SPG_TT_TTCR: sprintf (name, "TTCR"); return name;
|
2089 |
|
|
}
|
2090 |
|
|
|
2091 |
|
|
break;
|
2092 |
|
|
|
2093 |
|
|
case OR32_SPG_FPU:
|
2094 |
|
|
|
2095 |
|
|
break;
|
2096 |
|
|
}
|
2097 |
|
|
|
2098 |
|
|
/* Not a recognized register */
|
2099 |
|
|
strcpy (name, "");
|
2100 |
|
|
return name;
|
2101 |
|
|
|
2102 |
|
|
} /* or32_spr_register_name() */
|
2103 |
|
|
|
2104 |
|
|
|
2105 |
|
|
/*----------------------------------------------------------------------------*/
|
2106 |
|
|
/*!Get SPR group number from a name
|
2107 |
|
|
|
2108 |
|
|
@param[in] group_name SPR register group
|
2109 |
|
|
|
2110 |
|
|
@return The index, or negative if no match. */
|
2111 |
|
|
/*----------------------------------------------------------------------------*/
|
2112 |
|
|
|
2113 |
|
|
static int
|
2114 |
|
|
or32_groupnum_from_name (char *group_name)
|
2115 |
|
|
{
|
2116 |
|
|
int group;
|
2117 |
|
|
|
2118 |
|
|
for (group = 0; group < OR32_NUM_SPGS; group++)
|
2119 |
|
|
{
|
2120 |
|
|
if (0 == strcasecmp (group_name, or32_spr_group_name (group)))
|
2121 |
|
|
{
|
2122 |
|
|
return group;
|
2123 |
|
|
}
|
2124 |
|
|
}
|
2125 |
|
|
|
2126 |
|
|
return -1;
|
2127 |
|
|
|
2128 |
|
|
} /* or32_groupnum_from_name() */
|
2129 |
|
|
|
2130 |
|
|
|
2131 |
|
|
/*----------------------------------------------------------------------------*/
|
2132 |
|
|
/*!Get register index in special purpose register group from name
|
2133 |
|
|
|
2134 |
|
|
The name may either be SPR<group_num>_<index> or a known unique name. In
|
2135 |
|
|
either case the group number must match the supplied group number.
|
2136 |
|
|
|
2137 |
|
|
@param[in] group SPR register group
|
2138 |
|
|
@param[in] name Register name
|
2139 |
|
|
|
2140 |
|
|
@return The index, or negative if no match. */
|
2141 |
|
|
/*----------------------------------------------------------------------------*/
|
2142 |
|
|
|
2143 |
|
|
static int
|
2144 |
|
|
or32_regnum_from_name (int group,
|
2145 |
|
|
char *name)
|
2146 |
|
|
{
|
2147 |
|
|
/* Last valid register in each group. */
|
2148 |
|
|
static const int or32_spr_group_last[OR32_NUM_SPGS] =
|
2149 |
|
|
{
|
2150 |
|
|
OR32_SPG_SYS_LAST,
|
2151 |
|
|
OR32_SPG_DMMU_LAST,
|
2152 |
|
|
OR32_SPG_IMMU_LAST,
|
2153 |
|
|
OR32_SPG_DC_LAST,
|
2154 |
|
|
OR32_SPG_IC_LAST,
|
2155 |
|
|
OR32_SPG_MAC_LAST,
|
2156 |
|
|
OR32_SPG_DEBUG_LAST,
|
2157 |
|
|
OR32_SPG_PC_LAST,
|
2158 |
|
|
OR32_SPG_PM_LAST,
|
2159 |
|
|
OR32_SPG_PIC_LAST,
|
2160 |
|
|
OR32_SPG_TT_LAST,
|
2161 |
|
|
OR32_SPG_FPU_LAST
|
2162 |
|
|
};
|
2163 |
|
|
|
2164 |
|
|
int i;
|
2165 |
|
|
char spr_name[32];
|
2166 |
|
|
|
2167 |
|
|
if (0 == strcasecmp (name, "SPR"))
|
2168 |
|
|
{
|
2169 |
|
|
char *ptr_c;
|
2170 |
|
|
|
2171 |
|
|
/* Skip SPR */
|
2172 |
|
|
name += 3;
|
2173 |
|
|
|
2174 |
|
|
/* Get group number */
|
2175 |
|
|
i = (int) strtoul (name, &ptr_c, 10);
|
2176 |
|
|
if (*ptr_c != '_' || i != group)
|
2177 |
|
|
{
|
2178 |
|
|
return -1;
|
2179 |
|
|
}
|
2180 |
|
|
|
2181 |
|
|
/* Get index */
|
2182 |
|
|
ptr_c++;
|
2183 |
|
|
i = (int) strtoul (name, &ptr_c, 10);
|
2184 |
|
|
if (*ptr_c)
|
2185 |
|
|
{
|
2186 |
|
|
return -1;
|
2187 |
|
|
}
|
2188 |
|
|
else
|
2189 |
|
|
{
|
2190 |
|
|
return i;
|
2191 |
|
|
}
|
2192 |
|
|
}
|
2193 |
|
|
|
2194 |
|
|
/* Look for a "known" name in this group */
|
2195 |
|
|
for (i = 0; i <= or32_spr_group_last[group]; i++)
|
2196 |
|
|
{
|
2197 |
|
|
char *s = or32_spr_register_name (group, i, spr_name);
|
2198 |
|
|
|
2199 |
|
|
if (0 == strcasecmp (name, s))
|
2200 |
|
|
{
|
2201 |
|
|
return i;
|
2202 |
|
|
}
|
2203 |
|
|
}
|
2204 |
|
|
|
2205 |
|
|
/* Failure */
|
2206 |
|
|
return -1;
|
2207 |
|
|
|
2208 |
|
|
} /* or32_regnum_from_name() */
|
2209 |
|
|
|
2210 |
|
|
|
2211 |
|
|
/*----------------------------------------------------------------------------*/
|
2212 |
|
|
/*!Get the next token from a string
|
2213 |
|
|
|
2214 |
|
|
I can't believe there isn't a library argument for this, but strtok is
|
2215 |
|
|
deprecated.
|
2216 |
|
|
|
2217 |
|
|
Take a string and find the start of the next token and its length. A token
|
2218 |
|
|
is anything containing non-blank characters.
|
2219 |
|
|
|
2220 |
|
|
@param[in] str The string to look at (may be NULL).
|
2221 |
|
|
@param[out] tok Pointer to the start of the token within str. May be NULL
|
2222 |
|
|
if this result is not wanted (e.g. just the length is
|
2223 |
|
|
wanted. If no token is found will be the NULL char at the
|
2224 |
|
|
end of the string, if the original str was NULL, this will
|
2225 |
|
|
be NULL.
|
2226 |
|
|
|
2227 |
|
|
@return The length of the token found */
|
2228 |
|
|
/*----------------------------------------------------------------------------*/
|
2229 |
|
|
|
2230 |
|
|
static int
|
2231 |
|
|
or32_tokenize (char *str,
|
2232 |
|
|
char **tok)
|
2233 |
|
|
{
|
2234 |
|
|
char *ptr;
|
2235 |
|
|
int len;
|
2236 |
|
|
|
2237 |
|
|
/* Deal with NULL argument */
|
2238 |
|
|
if (NULL == str)
|
2239 |
|
|
{
|
2240 |
|
|
if (NULL != tok)
|
2241 |
|
|
{
|
2242 |
|
|
*tok = NULL;
|
2243 |
|
|
}
|
2244 |
|
|
return 0;
|
2245 |
|
|
}
|
2246 |
|
|
|
2247 |
|
|
/* Find the start */
|
2248 |
|
|
for (ptr = str; ISBLANK (*ptr) ; ptr++)
|
2249 |
|
|
{
|
2250 |
|
|
continue;
|
2251 |
|
|
}
|
2252 |
|
|
|
2253 |
|
|
/* Return the start pointer if requested */
|
2254 |
|
|
if (NULL != tok)
|
2255 |
|
|
{
|
2256 |
|
|
*tok = ptr;
|
2257 |
|
|
}
|
2258 |
|
|
|
2259 |
|
|
/* Find the end and put in EOS */
|
2260 |
|
|
for (len = 0; ('\0' != ptr[len]) && (!ISBLANK (ptr[len])); len++)
|
2261 |
|
|
{
|
2262 |
|
|
continue;
|
2263 |
|
|
}
|
2264 |
|
|
|
2265 |
|
|
return len;
|
2266 |
|
|
|
2267 |
|
|
} /* or32_tokenize() */
|
2268 |
|
|
|
2269 |
|
|
|
2270 |
|
|
/*----------------------------------------------------------------------------*/
|
2271 |
|
|
/*!Parses args for spr commands
|
2272 |
|
|
|
2273 |
|
|
Determines the special purpose register (SPR) name and puts result into
|
2274 |
|
|
group and index
|
2275 |
|
|
|
2276 |
|
|
Syntax is:
|
2277 |
|
|
|
2278 |
|
|
@verbatim
|
2279 |
|
|
<spr_args> -> <group_ref> | <reg_name>
|
2280 |
|
|
<group_ref> -> <group_id> <index>
|
2281 |
|
|
<group_id> -> <group_num> | <group_name>
|
2282 |
|
|
@endverbatim
|
2283 |
|
|
|
2284 |
|
|
Where the indices/names have to be valid.
|
2285 |
|
|
|
2286 |
|
|
So to parse, we look for 1 or 2 args. If 1 it must be a unique register
|
2287 |
|
|
name. If 2, the first must be a group number or name and the second an
|
2288 |
|
|
index within that group.
|
2289 |
|
|
|
2290 |
|
|
Also responsible for providing diagnostics if the arguments do not match.
|
2291 |
|
|
|
2292 |
|
|
Rewritten for GDB 6.8 to use the new UI calls and remove assorted
|
2293 |
|
|
bugs. Syntax also slightly restricted to be more comprehensible.
|
2294 |
|
|
|
2295 |
|
|
@param[in] arg_str The argument string
|
2296 |
|
|
@param[out] group The group this SPR belongs in, or -1 to indicate
|
2297 |
|
|
failure
|
2298 |
|
|
@param[out] index Index of the register within the group, or -1 to
|
2299 |
|
|
indicate the whole group
|
2300 |
|
|
@param[in] is_set 1 (true) if we are called from the "spr" command (so
|
2301 |
|
|
there is an extra arg) rather than the "info spr"
|
2302 |
|
|
command. Needed to distinguish between the case where
|
2303 |
|
|
info is sought from a register specified as group and
|
2304 |
|
|
index and setting a uniquely identified register to a
|
2305 |
|
|
value.
|
2306 |
|
|
|
2307 |
|
|
@return A pointer to any remaining args */
|
2308 |
|
|
/*---------------------------------------------------------------------------*/
|
2309 |
|
|
|
2310 |
|
|
static char *
|
2311 |
|
|
or32_parse_spr_params (char *arg_str,
|
2312 |
|
|
int *group,
|
2313 |
|
|
int *index,
|
2314 |
|
|
int is_set)
|
2315 |
|
|
{
|
2316 |
|
|
struct {
|
2317 |
|
|
char *str;
|
2318 |
|
|
int len;
|
2319 |
|
|
unsigned long int val;
|
2320 |
|
|
int is_num;
|
2321 |
|
|
} arg[3] = {
|
2322 |
|
|
{
|
2323 |
|
|
.str = NULL,
|
2324 |
|
|
.len = 0,
|
2325 |
|
|
.val = 0,
|
2326 |
|
|
.is_num = 0,
|
2327 |
|
|
},
|
2328 |
|
|
{
|
2329 |
|
|
.str = NULL,
|
2330 |
|
|
.len = 0,
|
2331 |
|
|
.val = 0,
|
2332 |
|
|
.is_num = 0,
|
2333 |
|
|
},
|
2334 |
|
|
{
|
2335 |
|
|
.str = NULL,
|
2336 |
|
|
.len = 0,
|
2337 |
|
|
.val = 0,
|
2338 |
|
|
.is_num = 0,
|
2339 |
|
|
}
|
2340 |
|
|
};
|
2341 |
|
|
|
2342 |
|
|
int num_args;
|
2343 |
|
|
char *trailer = arg_str;
|
2344 |
|
|
char *tmp_str;
|
2345 |
|
|
int i;
|
2346 |
|
|
|
2347 |
|
|
char spr_name[32];
|
2348 |
|
|
|
2349 |
|
|
/* Break out the arguments. Note that the strings are NOT null terminated
|
2350 |
|
|
(we don't want to change arg_str), so we must rely on len. The stroul
|
2351 |
|
|
call will still work, since there is always a non-digit char (possibly EOS)
|
2352 |
|
|
after the last digit. */
|
2353 |
|
|
if (NULL == arg_str)
|
2354 |
|
|
{
|
2355 |
|
|
num_args = 0;
|
2356 |
|
|
}
|
2357 |
|
|
else
|
2358 |
|
|
{
|
2359 |
|
|
for (num_args = 0; num_args < 3; num_args++)
|
2360 |
|
|
{
|
2361 |
|
|
arg[num_args].len = or32_tokenize (trailer, &(arg[num_args].str));
|
2362 |
|
|
trailer = arg[num_args].str + arg[num_args].len;
|
2363 |
|
|
|
2364 |
|
|
if (0 == arg[num_args].len)
|
2365 |
|
|
{
|
2366 |
|
|
break;
|
2367 |
|
|
}
|
2368 |
|
|
}
|
2369 |
|
|
}
|
2370 |
|
|
|
2371 |
|
|
/* Patch nulls into the arg strings and see about values. Couldn't do this
|
2372 |
|
|
earlier, since we needed the next char clean to check later args. This
|
2373 |
|
|
means advancing trailer, UNLESS it was already at EOS */
|
2374 |
|
|
|
2375 |
|
|
if((NULL != arg_str) && ('\0' != *trailer))
|
2376 |
|
|
{
|
2377 |
|
|
trailer++;
|
2378 |
|
|
}
|
2379 |
|
|
|
2380 |
|
|
for (i = 0; i < num_args; i++)
|
2381 |
|
|
{
|
2382 |
|
|
(arg[i].str)[arg[i].len] = '\0';
|
2383 |
|
|
errno = 0;
|
2384 |
|
|
arg[i].val = strtoul (arg[i].str, &tmp_str, 0);
|
2385 |
|
|
arg[i].is_num = (0 == errno) && ('\0' == *tmp_str);
|
2386 |
|
|
}
|
2387 |
|
|
|
2388 |
|
|
/* Deal with the case where we are setting a register, so the final argument
|
2389 |
|
|
should be disregarded (it is the trailer). Do this anyway if we get a
|
2390 |
|
|
third argument */
|
2391 |
|
|
if ((is_set & (num_args > 0)) || (num_args > 2))
|
2392 |
|
|
{
|
2393 |
|
|
trailer = arg[num_args - 1].str;
|
2394 |
|
|
num_args--;
|
2395 |
|
|
}
|
2396 |
|
|
|
2397 |
|
|
/* Deal with different numbers of args */
|
2398 |
|
|
|
2399 |
|
|
switch (num_args)
|
2400 |
|
|
{
|
2401 |
|
|
|
2402 |
|
|
case 0:
|
2403 |
|
|
ui_out_message (uiout, 0,
|
2404 |
|
|
"Usage: <command> <register> |\n"
|
2405 |
|
|
" <command> <group> |\n"
|
2406 |
|
|
" <command> <group> <index>\n"
|
2407 |
|
|
"Valid groups are:\n");
|
2408 |
|
|
for (i = 0; i < OR32_NUM_SPGS; i++)
|
2409 |
|
|
{
|
2410 |
|
|
ui_out_field_string (uiout, NULL, or32_spr_group_name (i));
|
2411 |
|
|
ui_out_spaces (uiout, 1);
|
2412 |
|
|
ui_out_wrap_hint (uiout, NULL);
|
2413 |
|
|
}
|
2414 |
|
|
ui_out_field_string (uiout, NULL, "\n");
|
2415 |
|
|
|
2416 |
|
|
*index = -1;
|
2417 |
|
|
return trailer;
|
2418 |
|
|
|
2419 |
|
|
case 1:
|
2420 |
|
|
/* See if it is a numeric group */
|
2421 |
|
|
if (arg[0].is_num)
|
2422 |
|
|
{
|
2423 |
|
|
if (arg[0].val < OR32_NUM_SPGS)
|
2424 |
|
|
{
|
2425 |
|
|
*group = arg[0].val;
|
2426 |
|
|
*index = -1;
|
2427 |
|
|
return trailer;
|
2428 |
|
|
}
|
2429 |
|
|
else
|
2430 |
|
|
{
|
2431 |
|
|
ui_out_message (uiout, 0,
|
2432 |
|
|
"Group index should be in the range 0 - %d\n",
|
2433 |
|
|
OR32_NUM_SPGS);
|
2434 |
|
|
*group = -1;
|
2435 |
|
|
*index = -1;
|
2436 |
|
|
return trailer;
|
2437 |
|
|
}
|
2438 |
|
|
}
|
2439 |
|
|
|
2440 |
|
|
/* Is is it a group name? */
|
2441 |
|
|
*group = or32_groupnum_from_name (arg[0].str);
|
2442 |
|
|
if (*group >= 0)
|
2443 |
|
|
{
|
2444 |
|
|
*index = -1;
|
2445 |
|
|
return trailer;
|
2446 |
|
|
}
|
2447 |
|
|
|
2448 |
|
|
/* See if it is a valid register name in any group */
|
2449 |
|
|
for (*group = 0; *group < OR32_NUM_SPGS; (*group)++)
|
2450 |
|
|
{
|
2451 |
|
|
*index = or32_regnum_from_name (*group, arg[0].str);
|
2452 |
|
|
|
2453 |
|
|
if (*index >= 0)
|
2454 |
|
|
{
|
2455 |
|
|
return trailer;
|
2456 |
|
|
}
|
2457 |
|
|
}
|
2458 |
|
|
|
2459 |
|
|
/* Couldn't find it - print out a rude message */
|
2460 |
|
|
ui_out_message (uiout, 0,
|
2461 |
|
|
"Group or register name not recognized.\n"
|
2462 |
|
|
"Valid groups are:\n");
|
2463 |
|
|
for (i = 0; i < OR32_NUM_SPGS; i++)
|
2464 |
|
|
{
|
2465 |
|
|
ui_out_field_string (uiout, NULL, or32_spr_group_name (i));
|
2466 |
|
|
ui_out_spaces (uiout, 1);
|
2467 |
|
|
ui_out_wrap_hint (uiout, NULL);
|
2468 |
|
|
}
|
2469 |
|
|
ui_out_field_string (uiout, NULL, "\n");
|
2470 |
|
|
|
2471 |
|
|
*group = -1;
|
2472 |
|
|
*index = -1;
|
2473 |
|
|
return trailer;
|
2474 |
|
|
|
2475 |
|
|
case 2:
|
2476 |
|
|
/* See if first arg is a numeric group */
|
2477 |
|
|
if (arg[0].is_num)
|
2478 |
|
|
{
|
2479 |
|
|
if (arg[0].val < OR32_NUM_SPGS)
|
2480 |
|
|
{
|
2481 |
|
|
*group = arg[0].val;
|
2482 |
|
|
*index = -1;
|
2483 |
|
|
}
|
2484 |
|
|
else
|
2485 |
|
|
{
|
2486 |
|
|
ui_out_message (uiout, 0,
|
2487 |
|
|
"Group index should be in the range 0 - %d\n",
|
2488 |
|
|
OR32_NUM_SPGS - 1);
|
2489 |
|
|
*group = -1;
|
2490 |
|
|
*index = -1;
|
2491 |
|
|
return trailer;
|
2492 |
|
|
}
|
2493 |
|
|
}
|
2494 |
|
|
else
|
2495 |
|
|
{
|
2496 |
|
|
/* Is is it a group name? */
|
2497 |
|
|
*group = or32_groupnum_from_name (arg[0].str);
|
2498 |
|
|
if (*group >= 0)
|
2499 |
|
|
{
|
2500 |
|
|
*index = -1;
|
2501 |
|
|
}
|
2502 |
|
|
else
|
2503 |
|
|
{
|
2504 |
|
|
ui_out_message (uiout, 0,
|
2505 |
|
|
"Group name not recognized.\n"
|
2506 |
|
|
"Valid groups are:\n");
|
2507 |
|
|
for (i = 0; i < OR32_NUM_SPGS; i++)
|
2508 |
|
|
{
|
2509 |
|
|
ui_out_field_string (uiout, NULL, or32_spr_group_name (i));
|
2510 |
|
|
ui_out_spaces (uiout, 1);
|
2511 |
|
|
ui_out_wrap_hint (uiout, NULL);
|
2512 |
|
|
}
|
2513 |
|
|
ui_out_field_string (uiout, NULL, "\n");
|
2514 |
|
|
|
2515 |
|
|
*group = -1;
|
2516 |
|
|
*index = -1;
|
2517 |
|
|
return trailer;
|
2518 |
|
|
}
|
2519 |
|
|
}
|
2520 |
|
|
|
2521 |
|
|
/* Is second arg an index or name? */
|
2522 |
|
|
if (arg[1].is_num)
|
2523 |
|
|
{
|
2524 |
|
|
if (arg[1].val < OR32_SPG_SIZE)
|
2525 |
|
|
{
|
2526 |
|
|
/* Check this really is a register */
|
2527 |
|
|
if (0 != strlen (or32_spr_register_name (*group, arg[1].val,
|
2528 |
|
|
spr_name)))
|
2529 |
|
|
{
|
2530 |
|
|
*index = arg[1].val;
|
2531 |
|
|
return trailer;
|
2532 |
|
|
}
|
2533 |
|
|
else
|
2534 |
|
|
{
|
2535 |
|
|
ui_out_message (uiout, 0,
|
2536 |
|
|
"No valid register at that index in group\n");
|
2537 |
|
|
*group = -1;
|
2538 |
|
|
*index = -1;
|
2539 |
|
|
return trailer;
|
2540 |
|
|
}
|
2541 |
|
|
}
|
2542 |
|
|
else
|
2543 |
|
|
{
|
2544 |
|
|
ui_out_message (uiout, 0,
|
2545 |
|
|
"Register index should be in the range 0 - %d\n",
|
2546 |
|
|
OR32_SPG_SIZE - 1);
|
2547 |
|
|
*group = -1;
|
2548 |
|
|
*index = -1;
|
2549 |
|
|
return trailer;
|
2550 |
|
|
}
|
2551 |
|
|
}
|
2552 |
|
|
|
2553 |
|
|
/* Must be a name */
|
2554 |
|
|
*index = or32_regnum_from_name (*group, arg[1].str);
|
2555 |
|
|
|
2556 |
|
|
if (*index >= 0)
|
2557 |
|
|
{
|
2558 |
|
|
return trailer;
|
2559 |
|
|
}
|
2560 |
|
|
|
2561 |
|
|
/* Couldn't find it - print out a rude message */
|
2562 |
|
|
ui_out_message (uiout, 0, "Register name not recognized in group.\n");
|
2563 |
|
|
*group = -1;
|
2564 |
|
|
*index = -1;
|
2565 |
|
|
return trailer;
|
2566 |
|
|
|
2567 |
|
|
default:
|
2568 |
|
|
/* Anything else is an error */
|
2569 |
|
|
ui_out_message (uiout, 0, "Unable to parse arguments\n");
|
2570 |
|
|
*group = -1;
|
2571 |
|
|
*index = -1;
|
2572 |
|
|
return trailer;
|
2573 |
|
|
}
|
2574 |
|
|
} /* or32_parse_spr_params() */
|
2575 |
|
|
|
2576 |
|
|
|
2577 |
|
|
/*---------------------------------------------------------------------------*/
|
2578 |
|
|
/*!Read a special purpose register from the target
|
2579 |
|
|
|
2580 |
|
|
This has to be done using the target remote command "readspr"
|
2581 |
|
|
|
2582 |
|
|
@param[in] regnum The register to read
|
2583 |
|
|
|
2584 |
|
|
@return The value read */
|
2585 |
|
|
/*---------------------------------------------------------------------------*/
|
2586 |
|
|
|
2587 |
|
|
static ULONGEST
|
2588 |
|
|
or32_read_spr (unsigned int regnum)
|
2589 |
|
|
{
|
2590 |
|
|
struct ui_file *uibuf = mem_fileopen ();
|
2591 |
|
|
char cmd[sizeof ("readspr ffff")];
|
2592 |
|
|
unsigned long int data;
|
2593 |
|
|
char *res;
|
2594 |
|
|
long int len;
|
2595 |
|
|
|
2596 |
|
|
/* Create the command string and pass it to target remote command function */
|
2597 |
|
|
sprintf (cmd, "readspr %4x", regnum);
|
2598 |
|
|
target_rcmd (cmd, uibuf);
|
2599 |
|
|
|
2600 |
|
|
/* Get the output for the UI file as a string */
|
2601 |
|
|
res = ui_file_xstrdup (uibuf, &len);
|
2602 |
|
|
sscanf (res, "%lx", &data);
|
2603 |
|
|
|
2604 |
|
|
/* Tidy up */
|
2605 |
|
|
xfree (res);
|
2606 |
|
|
ui_file_delete (uibuf);
|
2607 |
|
|
|
2608 |
|
|
return (ULONGEST)data;
|
2609 |
|
|
|
2610 |
|
|
} /* or32_read_spr() */
|
2611 |
|
|
|
2612 |
|
|
|
2613 |
|
|
/*---------------------------------------------------------------------------*/
|
2614 |
|
|
/*!Write a special purpose register on the target
|
2615 |
|
|
|
2616 |
|
|
This has to be done using the target remote command "writespr"
|
2617 |
|
|
|
2618 |
|
|
Since the SPRs may map to GPR's or the other GDB register (PPC, NPC, SR),
|
2619 |
|
|
any register cache is flushed.
|
2620 |
|
|
|
2621 |
|
|
@param[in] regnum The register to write
|
2622 |
|
|
@param[in] data The value to write */
|
2623 |
|
|
/*---------------------------------------------------------------------------*/
|
2624 |
|
|
|
2625 |
|
|
static void
|
2626 |
|
|
or32_write_spr (unsigned int regnum,
|
2627 |
|
|
ULONGEST data)
|
2628 |
|
|
{
|
2629 |
|
|
struct ui_file *uibuf = mem_fileopen ();
|
2630 |
|
|
char cmd[sizeof ("writespr ffff ffffffff")];
|
2631 |
|
|
char *res;
|
2632 |
|
|
long int len;
|
2633 |
|
|
|
2634 |
|
|
/* Create the command string and pass it to target remote command function */
|
2635 |
|
|
sprintf (cmd, "writespr %4x %8llx", regnum, (long long unsigned int)data);
|
2636 |
|
|
target_rcmd (cmd, uibuf);
|
2637 |
|
|
|
2638 |
|
|
/* Flush the register cache */
|
2639 |
|
|
registers_changed ();
|
2640 |
|
|
|
2641 |
|
|
/* We ignore the result - Rcmd can put out its own error messages. Just
|
2642 |
|
|
tidy up */
|
2643 |
|
|
ui_file_delete (uibuf);
|
2644 |
|
|
|
2645 |
|
|
} /* or32_write_spr() */
|
2646 |
|
|
|
2647 |
|
|
|
2648 |
|
|
/*----------------------------------------------------------------------------*/
|
2649 |
|
|
/*!Show the value of a special purpose register or group
|
2650 |
|
|
|
2651 |
|
|
This is a custom extension to the GDB info command.
|
2652 |
|
|
|
2653 |
|
|
@param[in] args
|
2654 |
|
|
@param[in] from_tty True (1) if GDB is running from a TTY, false (0)
|
2655 |
|
|
otherwise. */
|
2656 |
|
|
/*---------------------------------------------------------------------------*/
|
2657 |
|
|
|
2658 |
|
|
static void
|
2659 |
|
|
or32_info_spr_command (char *args,
|
2660 |
|
|
int from_tty)
|
2661 |
|
|
{
|
2662 |
|
|
int group;
|
2663 |
|
|
int index;
|
2664 |
|
|
|
2665 |
|
|
char spr_name[32];
|
2666 |
|
|
|
2667 |
|
|
or32_parse_spr_params (args, &group, &index, 0);
|
2668 |
|
|
|
2669 |
|
|
if (group < 0)
|
2670 |
|
|
{
|
2671 |
|
|
return; /* Couldn't parse the args */
|
2672 |
|
|
}
|
2673 |
|
|
|
2674 |
|
|
if (index >= 0)
|
2675 |
|
|
{
|
2676 |
|
|
ULONGEST value = or32_read_spr (OR32_SPR (group, index));
|
2677 |
|
|
|
2678 |
|
|
ui_out_field_fmt (uiout, NULL, "%s.%s = SPR%i_%i = %llu (0x%llx)\n",
|
2679 |
|
|
or32_spr_group_name (group),
|
2680 |
|
|
or32_spr_register_name (group, index, spr_name), group,
|
2681 |
|
|
index, (long long unsigned int)value, (long long unsigned int)value);
|
2682 |
|
|
}
|
2683 |
|
|
else
|
2684 |
|
|
{
|
2685 |
|
|
/* Print all valid registers in the group */
|
2686 |
|
|
for (index = 0; index < OR32_SPG_SIZE; index++)
|
2687 |
|
|
{
|
2688 |
|
|
if (0 != strlen (or32_spr_register_name (group, index, spr_name)))
|
2689 |
|
|
{
|
2690 |
|
|
ULONGEST value = or32_read_spr (OR32_SPR (group, index));
|
2691 |
|
|
|
2692 |
|
|
ui_out_field_fmt (uiout, NULL,
|
2693 |
|
|
"%s.%s = SPR%i_%i = %llu (0x%llx)\n",
|
2694 |
|
|
or32_spr_group_name (group),
|
2695 |
|
|
or32_spr_register_name (group, index, spr_name),
|
2696 |
|
|
group, index, (long long unsigned int)value, (long long unsigned int)value);
|
2697 |
|
|
}
|
2698 |
|
|
}
|
2699 |
|
|
}
|
2700 |
|
|
} /* or32_info_spr_command() */
|
2701 |
|
|
|
2702 |
|
|
|
2703 |
|
|
/*----------------------------------------------------------------------------*/
|
2704 |
|
|
/*!Set a special purpose register
|
2705 |
|
|
|
2706 |
|
|
This is a custom command added to GDB.
|
2707 |
|
|
|
2708 |
|
|
@param[in] args
|
2709 |
|
|
@param[in] from_tty True (1) if GDB is running from a TTY, false (0)
|
2710 |
|
|
otherwise. */
|
2711 |
|
|
/*---------------------------------------------------------------------------*/
|
2712 |
|
|
|
2713 |
|
|
static void
|
2714 |
|
|
or32_spr_command (char *args,
|
2715 |
|
|
int from_tty)
|
2716 |
|
|
{
|
2717 |
|
|
int group;
|
2718 |
|
|
int index;
|
2719 |
|
|
char *tmp_str;
|
2720 |
|
|
char *nargs = or32_parse_spr_params (args, &group, &index, 1);
|
2721 |
|
|
|
2722 |
|
|
ULONGEST old_val;
|
2723 |
|
|
ULONGEST new_val;
|
2724 |
|
|
|
2725 |
|
|
char spr_name[32];
|
2726 |
|
|
|
2727 |
|
|
/* Do we have a valid register spec? */
|
2728 |
|
|
if (index < 0)
|
2729 |
|
|
{
|
2730 |
|
|
return; /* Parser will have printed the error message */
|
2731 |
|
|
}
|
2732 |
|
|
|
2733 |
|
|
/* Do we have a value to set? */
|
2734 |
|
|
|
2735 |
|
|
errno = 0;
|
2736 |
|
|
new_val = (ULONGEST)strtoul (nargs, &tmp_str, 0);
|
2737 |
|
|
|
2738 |
|
|
if((0 != errno) || ('\0' != *tmp_str))
|
2739 |
|
|
{
|
2740 |
|
|
ui_out_message (uiout, 0, "Invalid value - register not changed\n");
|
2741 |
|
|
return;
|
2742 |
|
|
}
|
2743 |
|
|
|
2744 |
|
|
old_val = or32_read_spr (OR32_SPR (group, index));
|
2745 |
|
|
|
2746 |
|
|
or32_write_spr (OR32_SPR (group, index) , new_val);
|
2747 |
|
|
|
2748 |
|
|
ui_out_field_fmt (uiout, NULL,
|
2749 |
|
|
"%s.%s (SPR%i_%i) set to %llu (0x%llx), "
|
2750 |
|
|
"was: %llu (0x%llx)\n",
|
2751 |
|
|
or32_spr_group_name (group),
|
2752 |
|
|
or32_spr_register_name (group, index, spr_name) , group,
|
2753 |
|
|
index, (long long unsigned int)new_val, (long long unsigned int)new_val, (long long unsigned int)old_val, (long long unsigned int)old_val);
|
2754 |
|
|
|
2755 |
|
|
} /* or32_spr_command() */
|
2756 |
|
|
|
2757 |
|
|
|
2758 |
|
|
/*----------------------------------------------------------------------------*/
|
2759 |
|
|
/*!Main entry point for target architecture initialization
|
2760 |
|
|
|
2761 |
|
|
In this version initializes the architecture via
|
2762 |
|
|
registers_gdbarch_init(). Add a command to set and show special purpose
|
2763 |
|
|
registers. */
|
2764 |
|
|
/*---------------------------------------------------------------------------*/
|
2765 |
|
|
|
2766 |
|
|
void
|
2767 |
|
|
_initialize_or32_tdep (void)
|
2768 |
|
|
{
|
2769 |
|
|
/* Register this architecture. We should do this for or16 and or64 when
|
2770 |
|
|
they have their BFD defined. */
|
2771 |
|
|
gdbarch_register (bfd_arch_or32, or32_gdbarch_init, or32_dump_tdep);
|
2772 |
|
|
|
2773 |
|
|
/* Initialize the automata for the assembler */
|
2774 |
|
|
build_automata();
|
2775 |
|
|
|
2776 |
|
|
/* Commands to show and set special purpose registers */
|
2777 |
|
|
add_info ("spr", or32_info_spr_command,
|
2778 |
|
|
"Show the value of a special purpose register");
|
2779 |
|
|
add_com ("spr", class_support, or32_spr_command,
|
2780 |
|
|
"Set a special purpose register");
|
2781 |
|
|
|
2782 |
|
|
} /* _initialize_or32_tdep() */
|