return zero in arm_linux_can_use_hw_breakpoint if HW point isn't supported
[deliverable/binutils-gdb.git] / gdb / gdbserver / linux-xtensa-low.c
CommitLineData
1525d545 1/* GNU/Linux/Xtensa specific low level interface, for the remote server for GDB.
32d0add0 2 Copyright (C) 2007-2015 Free Software Foundation, Inc.
1525d545
MG
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19
20#include "server.h"
21#include "linux-low.h"
22
d05b4ac3
UW
23/* Defined in auto-generated file reg-xtensa.c. */
24void init_registers_xtensa (void);
3aee8918 25extern const struct target_desc *tdesc_xtensa;
d05b4ac3 26
e671835b 27#include <asm/ptrace.h>
1525d545
MG
28#include <xtensa-config.h>
29
30#include "xtensa-xtregs.c"
31
32enum regnum {
33 R_PC=0, R_PS,
34 R_LBEG, R_LEND, R_LCOUNT,
35 R_SAR,
36 R_WS, R_WB,
1b3f6016 37 R_A0 = 64
1525d545
MG
38};
39
40static void
442ea881 41xtensa_fill_gregset (struct regcache *regcache, void *buf)
1525d545
MG
42{
43 elf_greg_t* rset = (elf_greg_t*)buf;
3aee8918 44 const struct target_desc *tdesc = regcache->tdesc;
1525d545
MG
45 int ar0_regnum;
46 char *ptr;
47 int i;
48
49 /* Take care of AR registers. */
50
3aee8918 51 ar0_regnum = find_regno (tdesc, "ar0");
1525d545
MG
52 ptr = (char*)&rset[R_A0];
53
54 for (i = ar0_regnum; i < ar0_regnum + XCHAL_NUM_AREGS; i++)
55 {
442ea881 56 collect_register (regcache, i, ptr);
3aee8918 57 ptr += register_size (tdesc, i);
1525d545
MG
58 }
59
60 /* Loop registers, if hardware has it. */
61
62#if XCHAL_HAVE_LOOP
442ea881
PA
63 collect_register_by_name (regcache, "lbeg", (char*)&rset[R_LBEG]);
64 collect_register_by_name (regcache, "lend", (char*)&rset[R_LEND]);
65 collect_register_by_name (regcache, "lcount", (char*)&rset[R_LCOUNT]);
1525d545
MG
66#endif
67
442ea881
PA
68 collect_register_by_name (regcache, "sar", (char*)&rset[R_SAR]);
69 collect_register_by_name (regcache, "pc", (char*)&rset[R_PC]);
70 collect_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
71 collect_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
72 collect_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
1525d545
MG
73}
74
75static void
442ea881 76xtensa_store_gregset (struct regcache *regcache, const void *buf)
1525d545
MG
77{
78 const elf_greg_t* rset = (const elf_greg_t*)buf;
3aee8918 79 const struct target_desc *tdesc = regcache->tdesc;
1525d545
MG
80 int ar0_regnum;
81 char *ptr;
82 int i;
83
84 /* Take care of AR registers. */
85
3aee8918 86 ar0_regnum = find_regno (tdesc, "ar0");
1525d545
MG
87 ptr = (char *)&rset[R_A0];
88
89 for (i = ar0_regnum; i < ar0_regnum + XCHAL_NUM_AREGS; i++)
90 {
442ea881 91 supply_register (regcache, i, ptr);
3aee8918 92 ptr += register_size (tdesc, i);
1525d545
MG
93 }
94
95 /* Loop registers, if hardware has it. */
96
97#if XCHAL_HAVE_LOOP
442ea881
PA
98 supply_register_by_name (regcache, "lbeg", (char*)&rset[R_LBEG]);
99 supply_register_by_name (regcache, "lend", (char*)&rset[R_LEND]);
100 supply_register_by_name (regcache, "lcount", (char*)&rset[R_LCOUNT]);
1525d545
MG
101#endif
102
442ea881
PA
103 supply_register_by_name (regcache, "sar", (char*)&rset[R_SAR]);
104 supply_register_by_name (regcache, "pc", (char*)&rset[R_PC]);
105 supply_register_by_name (regcache, "ps", (char*)&rset[R_PS]);
106 supply_register_by_name (regcache, "windowbase", (char*)&rset[R_WB]);
107 supply_register_by_name (regcache, "windowstart", (char*)&rset[R_WS]);
1525d545
MG
108}
109
110/* Xtensa GNU/Linux PTRACE interface includes extended register set. */
111
112static void
442ea881 113xtensa_fill_xtregset (struct regcache *regcache, void *buf)
1525d545
MG
114{
115 const xtensa_regtable_t *ptr;
116
117 for (ptr = xtensa_regmap_table; ptr->name; ptr++)
118 {
442ea881 119 collect_register_by_name (regcache, ptr->name,
1525d545
MG
120 (char*)buf + ptr->ptrace_offset);
121 }
122}
123
124static void
442ea881 125xtensa_store_xtregset (struct regcache *regcache, const void *buf)
1525d545
MG
126{
127 const xtensa_regtable_t *ptr;
128
129 for (ptr = xtensa_regmap_table; ptr->name; ptr++)
130 {
442ea881 131 supply_register_by_name (regcache, ptr->name,
1525d545
MG
132 (char*)buf + ptr->ptrace_offset);
133 }
134}
135
3aee8918 136static struct regset_info xtensa_regsets[] = {
1570b33e 137 { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t),
1525d545
MG
138 GENERAL_REGS,
139 xtensa_fill_gregset, xtensa_store_gregset },
1570b33e 140 { PTRACE_GETXTREGS, PTRACE_SETXTREGS, 0, XTENSA_ELF_XTREG_SIZE,
1525d545
MG
141 EXTENDED_REGS,
142 xtensa_fill_xtregset, xtensa_store_xtregset },
1570b33e 143 { 0, 0, 0, -1, -1, NULL, NULL }
1525d545
MG
144};
145
146#if XCHAL_HAVE_BE
147#define XTENSA_BREAKPOINT {0xd2,0x0f}
148#else
149#define XTENSA_BREAKPOINT {0x2d,0xf0}
150#endif
151
152static const unsigned char xtensa_breakpoint[] = XTENSA_BREAKPOINT;
153#define xtensa_breakpoint_len 2
154
155static CORE_ADDR
442ea881 156xtensa_get_pc (struct regcache *regcache)
1525d545
MG
157{
158 unsigned long pc;
159
442ea881 160 collect_register_by_name (regcache, "pc", &pc);
1525d545
MG
161 return pc;
162}
163
164static void
442ea881 165xtensa_set_pc (struct regcache *regcache, CORE_ADDR pc)
1525d545
MG
166{
167 unsigned long newpc = pc;
442ea881 168 supply_register_by_name (regcache, "pc", &newpc);
1525d545
MG
169}
170
171static int
172xtensa_breakpoint_at (CORE_ADDR where)
173{
174 unsigned long insn;
175
176 (*the_target->read_memory) (where, (unsigned char *) &insn,
177 xtensa_breakpoint_len);
493e2a69
MS
178 return memcmp((char *) &insn,
179 xtensa_breakpoint, xtensa_breakpoint_len) == 0;
1525d545
MG
180}
181
3aee8918
PA
182static struct regsets_info xtensa_regsets_info =
183 {
184 xtensa_regsets, /* regsets */
185 0, /* num_regsets */
186 NULL, /* disabled_regsets */
187 };
188
189static struct usrregs_info xtensa_usrregs_info =
190 {
191 xtensa_num_regs,
192 xtensa_regmap,
193 };
194
195static struct regs_info regs_info =
196 {
197 NULL, /* regset_bitmap */
198 &xtensa_usrregs_info,
199 &xtensa_regsets_info
200 };
201
202static void
203xtensa_arch_setup (void)
204{
205 current_process ()->tdesc = tdesc_xtensa;
206}
207
208static const struct regs_info *
209xtensa_regs_info (void)
210{
211 return &regs_info;
212}
213
1525d545 214struct linux_target_ops the_low_target = {
3aee8918
PA
215 xtensa_arch_setup,
216 xtensa_regs_info,
1525d545
MG
217 0,
218 0,
c14dfd32 219 NULL, /* fetch_register */
1525d545
MG
220 xtensa_get_pc,
221 xtensa_set_pc,
222 xtensa_breakpoint,
223 xtensa_breakpoint_len,
224 NULL,
225 0,
226 xtensa_breakpoint_at,
227};
3aee8918
PA
228
229
230void
231initialize_low_arch (void)
232{
233 /* Initialize the Linux target descriptions. */
234 init_registers_xtensa ();
235
236 initialize_regsets_info (&xtensa_regsets_info);
237}
This page took 0.581224 seconds and 4 git commands to generate.