Commit | Line | Data |
---|---|---|
0a30fbc4 | 1 | /* GNU/Linux/SH specific low level interface, for the remote server for GDB. |
b811d2c2 | 2 | Copyright (C) 1995-2020 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 | |
ef0478f6 TBA |
22 | /* Linux target op definitions for the SH architecture. */ |
23 | ||
24 | class sh_target : public linux_process_target | |
25 | { | |
26 | public: | |
27 | ||
aa8d21c9 TBA |
28 | const regs_info *get_regs_info () override; |
29 | ||
797bcff5 TBA |
30 | protected: |
31 | ||
32 | void low_arch_setup () override; | |
daca57a7 TBA |
33 | |
34 | bool low_cannot_fetch_register (int regno) override; | |
35 | ||
36 | bool low_cannot_store_register (int regno) override; | |
ef0478f6 TBA |
37 | }; |
38 | ||
39 | /* The singleton target ops object. */ | |
40 | ||
41 | static sh_target the_sh_target; | |
42 | ||
d05b4ac3 UW |
43 | /* Defined in auto-generated file reg-sh.c. */ |
44 | void init_registers_sh (void); | |
3aee8918 | 45 | extern const struct target_desc *tdesc_sh; |
d05b4ac3 | 46 | |
0a30fbc4 DJ |
47 | #ifdef HAVE_SYS_REG_H |
48 | #include <sys/reg.h> | |
49 | #endif | |
50 | ||
51 | #include <asm/ptrace.h> | |
52 | ||
2ec06d2e | 53 | #define sh_num_regs 41 |
0a30fbc4 DJ |
54 | |
55 | /* Currently, don't check/send MQ. */ | |
2ec06d2e | 56 | static int sh_regmap[] = { |
0a30fbc4 DJ |
57 | 0, 4, 8, 12, 16, 20, 24, 28, |
58 | 32, 36, 40, 44, 48, 52, 56, 60, | |
59 | ||
60 | REG_PC*4, REG_PR*4, REG_GBR*4, -1, | |
61 | REG_MACH*4, REG_MACL*4, REG_SR*4, | |
62 | REG_FPUL*4, REG_FPSCR*4, | |
63 | ||
c8a86edf DJ |
64 | REG_FPREG0*4+0, REG_FPREG0*4+4, REG_FPREG0*4+8, REG_FPREG0*4+12, |
65 | REG_FPREG0*4+16, REG_FPREG0*4+20, REG_FPREG0*4+24, REG_FPREG0*4+28, | |
66 | REG_FPREG0*4+32, REG_FPREG0*4+36, REG_FPREG0*4+40, REG_FPREG0*4+44, | |
67 | REG_FPREG0*4+48, REG_FPREG0*4+52, REG_FPREG0*4+56, REG_FPREG0*4+60, | |
0a30fbc4 DJ |
68 | }; |
69 | ||
daca57a7 TBA |
70 | bool |
71 | sh_target::low_cannot_store_register (int regno) | |
0a30fbc4 | 72 | { |
daca57a7 | 73 | return false; |
0a30fbc4 DJ |
74 | } |
75 | ||
daca57a7 TBA |
76 | bool |
77 | sh_target::low_cannot_fetch_register (int regno) | |
0a30fbc4 | 78 | { |
daca57a7 | 79 | return false; |
0a30fbc4 DJ |
80 | } |
81 | ||
0d62e5e8 DJ |
82 | /* Correct in either endianness, obviously. */ |
83 | static const unsigned short sh_breakpoint = 0xc3c3; | |
84 | #define sh_breakpoint_len 2 | |
85 | ||
dd373349 AT |
86 | /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */ |
87 | ||
88 | static const gdb_byte * | |
89 | sh_sw_breakpoint_from_kind (int kind, int *size) | |
90 | { | |
91 | *size = sh_breakpoint_len; | |
92 | return (const gdb_byte *) &sh_breakpoint; | |
93 | } | |
94 | ||
0d62e5e8 DJ |
95 | static int |
96 | sh_breakpoint_at (CORE_ADDR where) | |
97 | { | |
98 | unsigned short insn; | |
99 | ||
52405d85 | 100 | the_target->read_memory (where, (unsigned char *) &insn, 2); |
0d62e5e8 DJ |
101 | if (insn == sh_breakpoint) |
102 | return 1; | |
103 | ||
104 | /* If necessary, recognize more trap instructions here. GDB only uses the | |
105 | one. */ | |
106 | return 0; | |
107 | } | |
108 | ||
7d00775e AT |
109 | /* Support for hardware single step. */ |
110 | ||
111 | static int | |
112 | sh_supports_hardware_single_step (void) | |
113 | { | |
114 | return 1; | |
115 | } | |
116 | ||
0d37add9 DJ |
117 | /* Provide only a fill function for the general register set. ps_lgetregs |
118 | will use this for NPTL support. */ | |
119 | ||
442ea881 | 120 | static void sh_fill_gregset (struct regcache *regcache, void *buf) |
0d37add9 DJ |
121 | { |
122 | int i; | |
123 | ||
124 | for (i = 0; i < 23; i++) | |
125 | if (sh_regmap[i] != -1) | |
442ea881 | 126 | collect_register (regcache, i, (char *) buf + sh_regmap[i]); |
0d37add9 DJ |
127 | } |
128 | ||
3aee8918 | 129 | static struct regset_info sh_regsets[] = { |
1570b33e | 130 | { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL }, |
50bc912a | 131 | NULL_REGSET |
0d37add9 DJ |
132 | }; |
133 | ||
3aee8918 PA |
134 | static struct regsets_info sh_regsets_info = |
135 | { | |
136 | sh_regsets, /* regsets */ | |
137 | 0, /* num_regsets */ | |
138 | NULL, /* disabled_regsets */ | |
139 | }; | |
140 | ||
141 | static struct usrregs_info sh_usrregs_info = | |
142 | { | |
143 | sh_num_regs, | |
144 | sh_regmap, | |
145 | }; | |
146 | ||
aa8d21c9 | 147 | static struct regs_info myregs_info = |
3aee8918 PA |
148 | { |
149 | NULL, /* regset_bitmap */ | |
150 | &sh_usrregs_info, | |
151 | &sh_regsets_info | |
152 | }; | |
153 | ||
aa8d21c9 TBA |
154 | const regs_info * |
155 | sh_target::get_regs_info () | |
3aee8918 | 156 | { |
aa8d21c9 | 157 | return &myregs_info; |
3aee8918 PA |
158 | } |
159 | ||
797bcff5 TBA |
160 | void |
161 | sh_target::low_arch_setup () | |
3aee8918 PA |
162 | { |
163 | current_process ()->tdesc = tdesc_sh; | |
164 | } | |
165 | ||
2ec06d2e | 166 | struct linux_target_ops the_low_target = { |
c14dfd32 | 167 | NULL, /* fetch_register */ |
276d4552 YQ |
168 | linux_get_pc_32bit, |
169 | linux_set_pc_32bit, | |
dd373349 AT |
170 | NULL, /* breakpoint_kind_from_pc */ |
171 | sh_sw_breakpoint_from_kind, | |
0d62e5e8 DJ |
172 | NULL, |
173 | 0, | |
174 | sh_breakpoint_at, | |
7d00775e AT |
175 | NULL, /* supports_z_point_type */ |
176 | NULL, /* insert_point */ | |
177 | NULL, /* remove_point */ | |
178 | NULL, /* stopped_by_watchpoint */ | |
179 | NULL, /* stopped_data_address */ | |
180 | NULL, /* collect_ptrace_register */ | |
181 | NULL, /* supply_ptrace_register */ | |
182 | NULL, /* siginfo_fixup */ | |
183 | NULL, /* new_process */ | |
04ec7890 | 184 | NULL, /* delete_process */ |
7d00775e | 185 | NULL, /* new_thread */ |
466eecee | 186 | NULL, /* delete_thread */ |
7d00775e AT |
187 | NULL, /* new_fork */ |
188 | NULL, /* prepare_to_resume */ | |
189 | NULL, /* process_qsupported */ | |
190 | NULL, /* supports_tracepoints */ | |
191 | NULL, /* get_thread_area */ | |
192 | NULL, /* install_fast_tracepoint_jump_pad */ | |
193 | NULL, /* emit_ops */ | |
194 | NULL, /* get_min_fast_tracepoint_insn_len */ | |
195 | NULL, /* supports_range_stepping */ | |
196 | NULL, /* breakpoint_kind_from_current_state */ | |
197 | sh_supports_hardware_single_step, | |
2ec06d2e | 198 | }; |
3aee8918 | 199 | |
ef0478f6 TBA |
200 | /* The linux target ops object. */ |
201 | ||
202 | linux_process_target *the_linux_target = &the_sh_target; | |
203 | ||
3aee8918 PA |
204 | void |
205 | initialize_low_arch (void) | |
206 | { | |
207 | init_registers_sh (); | |
208 | ||
209 | initialize_regsets_info (&sh_regsets_info); | |
210 | } |