Commit | Line | Data |
---|---|---|
0a30fbc4 | 1 | /* GNU/Linux/SH specific low level interface, for the remote server for GDB. |
9b254dd1 | 2 | Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, |
4c38e0a4 | 3 | 2008, 2009, 2010 Free Software Foundation, Inc. |
0a30fbc4 DJ |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
0a30fbc4 DJ |
10 | (at your option) any later version. |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
0a30fbc4 DJ |
19 | |
20 | #include "server.h" | |
58caa3dc | 21 | #include "linux-low.h" |
0a30fbc4 | 22 | |
d05b4ac3 UW |
23 | /* Defined in auto-generated file reg-sh.c. */ |
24 | void init_registers_sh (void); | |
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 | ||
80 | static int | |
81 | sh_breakpoint_at (CORE_ADDR where) | |
82 | { | |
83 | unsigned short insn; | |
84 | ||
f450004a | 85 | (*the_target->read_memory) (where, (unsigned char *) &insn, 2); |
0d62e5e8 DJ |
86 | if (insn == sh_breakpoint) |
87 | return 1; | |
88 | ||
89 | /* If necessary, recognize more trap instructions here. GDB only uses the | |
90 | one. */ | |
91 | return 0; | |
92 | } | |
93 | ||
0d37add9 DJ |
94 | /* Provide only a fill function for the general register set. ps_lgetregs |
95 | will use this for NPTL support. */ | |
96 | ||
442ea881 | 97 | static void sh_fill_gregset (struct regcache *regcache, void *buf) |
0d37add9 DJ |
98 | { |
99 | int i; | |
100 | ||
101 | for (i = 0; i < 23; i++) | |
102 | if (sh_regmap[i] != -1) | |
442ea881 | 103 | collect_register (regcache, i, (char *) buf + sh_regmap[i]); |
0d37add9 DJ |
104 | } |
105 | ||
106 | struct regset_info target_regsets[] = { | |
1570b33e L |
107 | { 0, 0, 0, 0, GENERAL_REGS, sh_fill_gregset, NULL }, |
108 | { 0, 0, 0, -1, -1, NULL, NULL } | |
0d37add9 DJ |
109 | }; |
110 | ||
2ec06d2e | 111 | struct linux_target_ops the_low_target = { |
d05b4ac3 | 112 | init_registers_sh, |
2ec06d2e DJ |
113 | sh_num_regs, |
114 | sh_regmap, | |
115 | sh_cannot_fetch_register, | |
116 | sh_cannot_store_register, | |
0d62e5e8 DJ |
117 | sh_get_pc, |
118 | sh_set_pc, | |
f450004a | 119 | (const unsigned char *) &sh_breakpoint, |
0d62e5e8 DJ |
120 | sh_breakpoint_len, |
121 | NULL, | |
122 | 0, | |
123 | sh_breakpoint_at, | |
2ec06d2e | 124 | }; |