Commit | Line | Data |
---|---|---|
0a30fbc4 | 1 | /* GNU/Linux/SH specific low level interface, for the remote server for GDB. |
32d0add0 | 2 | Copyright (C) 1995-2015 Free Software Foundation, Inc. |
0a30fbc4 DJ |
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 | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
0a30fbc4 DJ |
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 | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
0a30fbc4 DJ |
18 | |
19 | #include "server.h" | |
58caa3dc | 20 | #include "linux-low.h" |
0a30fbc4 | 21 | |
d05b4ac3 UW |
22 | /* Defined in auto-generated file reg-sh.c. */ |
23 | void init_registers_sh (void); | |
3aee8918 | 24 | extern const struct target_desc *tdesc_sh; |
d05b4ac3 | 25 | |
0a30fbc4 DJ |
26 | #ifdef HAVE_SYS_REG_H |
27 | #include <sys/reg.h> | |
28 | #endif | |
29 | ||
30 | #include <asm/ptrace.h> | |
31 | ||
2ec06d2e | 32 | #define sh_num_regs 41 |
0a30fbc4 DJ |
33 | |
34 | /* Currently, don't check/send MQ. */ | |
2ec06d2e | 35 | static int sh_regmap[] = { |
0a30fbc4 DJ |
36 | 0, 4, 8, 12, 16, 20, 24, 28, |
37 | 32, 36, 40, 44, 48, 52, 56, 60, | |
38 | ||
39 | REG_PC*4, REG_PR*4, REG_GBR*4, -1, | |
40 | REG_MACH*4, REG_MACL*4, REG_SR*4, | |
41 | REG_FPUL*4, REG_FPSCR*4, | |
42 | ||
c8a86edf DJ |
43 | REG_FPREG0*4+0, REG_FPREG0*4+4, REG_FPREG0*4+8, REG_FPREG0*4+12, |
44 | REG_FPREG0*4+16, REG_FPREG0*4+20, REG_FPREG0*4+24, REG_FPREG0*4+28, | |
45 | REG_FPREG0*4+32, REG_FPREG0*4+36, REG_FPREG0*4+40, REG_FPREG0*4+44, | |
46 | REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60, | |
0a30fbc4 DJ |
47 | }; |
48 | ||
2ec06d2e DJ |
49 | static int |
50 | sh_cannot_store_register (int regno) | |
0a30fbc4 DJ |
51 | { |
52 | return 0; | |
53 | } | |
54 | ||
2ec06d2e DJ |
55 | static int |
56 | sh_cannot_fetch_register (int regno) | |
0a30fbc4 DJ |
57 | { |
58 | return 0; | |
59 | } | |
60 | ||
0d62e5e8 | 61 | static CORE_ADDR |
442ea881 | 62 | sh_get_pc (struct regcache *regcache) |
0d62e5e8 DJ |
63 | { |
64 | unsigned long pc; | |
442ea881 | 65 | collect_register_by_name (regcache, "pc", &pc); |
0d62e5e8 DJ |
66 | return pc; |
67 | } | |
68 | ||
69 | static void | |
442ea881 | 70 | sh_set_pc (struct regcache *regcache, CORE_ADDR pc) |
0d62e5e8 DJ |
71 | { |
72 | unsigned long newpc = pc; | |
442ea881 | 73 | supply_register_by_name (regcache, "pc", &newpc); |
0d62e5e8 DJ |
74 | } |
75 | ||
76 | /* Correct in either endianness, obviously. */ | |
77 | static const unsigned short sh_breakpoint = 0xc3c3; | |
78 | #define sh_breakpoint_len 2 | |
79 | ||
dd373349 AT |
80 | /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */ |
81 | ||
82 | static const gdb_byte * | |
83 | sh_sw_breakpoint_from_kind (int kind, int *size) | |
84 | { | |
85 | *size = sh_breakpoint_len; | |
86 | return (const gdb_byte *) &sh_breakpoint; | |
87 | } | |
88 | ||
0d62e5e8 DJ |
89 | static int |
90 | sh_breakpoint_at (CORE_ADDR where) | |
91 | { | |
92 | unsigned short insn; | |
93 | ||
f450004a | 94 | (*the_target->read_memory) (where, (unsigned char *) &insn, 2); |
0d62e5e8 DJ |
95 | if (insn == sh_breakpoint) |
96 | return 1; | |
97 | ||
98 | /* If necessary, recognize more trap instructions here. GDB only uses the | |
99 | one. */ | |
100 | return 0; | |
101 | } | |
102 | ||
0d37add9 DJ |
103 | /* Provide only a fill function for the general register set. ps_lgetregs |
104 | will use this for NPTL support. */ | |
105 | ||
442ea881 | 106 | static void sh_fill_gregset (struct regcache *regcache, void *buf) |
0d37add9 DJ |
107 | { |
108 | int i; | |
109 | ||
110 | for (i = 0; i < 23; i++) | |
111 | if (sh_regmap[i] != -1) | |
442ea881 | 112 | collect_register (regcache, i, (char *) buf + sh_regmap[i]); |
0d37add9 DJ |
113 | } |
114 | ||
3aee8918 | 115 | static struct regset_info sh_regsets[] = { |
1570b33e | 116 | { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL }, |
50bc912a | 117 | NULL_REGSET |
0d37add9 DJ |
118 | }; |
119 | ||
3aee8918 PA |
120 | static struct regsets_info sh_regsets_info = |
121 | { | |
122 | sh_regsets, /* regsets */ | |
123 | 0, /* num_regsets */ | |
124 | NULL, /* disabled_regsets */ | |
125 | }; | |
126 | ||
127 | static struct usrregs_info sh_usrregs_info = | |
128 | { | |
129 | sh_num_regs, | |
130 | sh_regmap, | |
131 | }; | |
132 | ||
133 | static struct regs_info regs_info = | |
134 | { | |
135 | NULL, /* regset_bitmap */ | |
136 | &sh_usrregs_info, | |
137 | &sh_regsets_info | |
138 | }; | |
139 | ||
140 | static const struct regs_info * | |
141 | sh_regs_info (void) | |
142 | { | |
143 | return ®s_info; | |
144 | } | |
145 | ||
146 | static void | |
147 | sh_arch_setup (void) | |
148 | { | |
149 | current_process ()->tdesc = tdesc_sh; | |
150 | } | |
151 | ||
2ec06d2e | 152 | struct linux_target_ops the_low_target = { |
3aee8918 PA |
153 | sh_arch_setup, |
154 | sh_regs_info, | |
2ec06d2e DJ |
155 | sh_cannot_fetch_register, |
156 | sh_cannot_store_register, | |
c14dfd32 | 157 | NULL, /* fetch_register */ |
0d62e5e8 DJ |
158 | sh_get_pc, |
159 | sh_set_pc, | |
dd373349 AT |
160 | NULL, /* breakpoint_kind_from_pc */ |
161 | sh_sw_breakpoint_from_kind, | |
0d62e5e8 DJ |
162 | NULL, |
163 | 0, | |
164 | sh_breakpoint_at, | |
2ec06d2e | 165 | }; |
3aee8918 PA |
166 | |
167 | void | |
168 | initialize_low_arch (void) | |
169 | { | |
170 | init_registers_sh (); | |
171 | ||
172 | initialize_regsets_info (&sh_regsets_info); | |
173 | } |