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

Subversion Repositories openrisc_2011-10-31

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

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

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

powered by: WebSVN 2.1.0

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