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