Commit | Line | Data |
---|---|---|
bd9e6534 YQ |
1 | /* Copyright (C) 1995-2015 Free Software Foundation, Inc. |
2 | ||
3 | This file is part of GDB. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | #include "server.h" | |
19 | #include "arch/arm.h" | |
20 | #include "linux-low.h" | |
21 | #include "linux-aarch32-low.h" | |
22 | ||
23 | #include <sys/ptrace.h> | |
24 | /* Don't include elf.h if linux/elf.h got included by gdb_proc_service.h. | |
25 | On Bionic elf.h and linux/elf.h have conflicting definitions. */ | |
26 | #ifndef ELFMAG0 | |
27 | #include <elf.h> | |
28 | #endif | |
29 | ||
16d5f642 JB |
30 | /* Some older versions of GNU/Linux and Android do not define |
31 | the following macros. */ | |
32 | #ifndef NT_ARM_VFP | |
33 | #define NT_ARM_VFP 0x400 | |
34 | #endif | |
35 | ||
bd9e6534 YQ |
36 | /* Collect GP registers from REGCACHE to buffer BUF. */ |
37 | ||
38 | void | |
39 | arm_fill_gregset (struct regcache *regcache, void *buf) | |
40 | { | |
41 | int i; | |
42 | uint32_t *regs = buf; | |
43 | ||
44 | for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++) | |
45 | collect_register (regcache, i, ®s[i]); | |
46 | ||
47 | collect_register (regcache, ARM_PS_REGNUM, ®s[16]); | |
48 | } | |
49 | ||
50 | /* Supply GP registers contents, stored in BUF, to REGCACHE. */ | |
51 | ||
52 | void | |
53 | arm_store_gregset (struct regcache *regcache, const void *buf) | |
54 | { | |
55 | int i; | |
56 | char zerobuf[8]; | |
57 | const uint32_t *regs = buf; | |
58 | ||
59 | memset (zerobuf, 0, 8); | |
60 | for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++) | |
61 | supply_register (regcache, i, ®s[i]); | |
62 | ||
63 | for (; i < ARM_PS_REGNUM; i++) | |
64 | supply_register (regcache, i, zerobuf); | |
65 | ||
66 | supply_register (regcache, ARM_PS_REGNUM, ®s[16]); | |
67 | } | |
68 | ||
69 | /* Collect NUM number of VFP registers from REGCACHE to buffer BUF. */ | |
70 | ||
71 | void | |
72 | arm_fill_vfpregset_num (struct regcache *regcache, void *buf, int num) | |
73 | { | |
74 | int i, base; | |
75 | ||
76 | gdb_assert (num == 16 || num == 32); | |
77 | ||
78 | base = find_regno (regcache->tdesc, "d0"); | |
79 | for (i = 0; i < num; i++) | |
80 | collect_register (regcache, base + i, (char *) buf + i * 8); | |
81 | ||
82 | collect_register_by_name (regcache, "fpscr", (char *) buf + 32 * 8); | |
83 | } | |
84 | ||
85 | /* Supply NUM number of VFP registers contents, stored in BUF, to | |
86 | REGCACHE. */ | |
87 | ||
88 | void | |
89 | arm_store_vfpregset_num (struct regcache *regcache, const void *buf, int num) | |
90 | { | |
91 | int i, base; | |
92 | ||
93 | gdb_assert (num == 16 || num == 32); | |
94 | ||
95 | base = find_regno (regcache->tdesc, "d0"); | |
96 | for (i = 0; i < num; i++) | |
97 | supply_register (regcache, base + i, (char *) buf + i * 8); | |
98 | ||
99 | supply_register_by_name (regcache, "fpscr", (char *) buf + 32 * 8); | |
100 | } | |
101 | ||
102 | static void | |
103 | arm_fill_vfpregset (struct regcache *regcache, void *buf) | |
104 | { | |
105 | arm_fill_vfpregset_num (regcache, buf, 32); | |
106 | } | |
107 | ||
108 | static void | |
109 | arm_store_vfpregset (struct regcache *regcache, const void *buf) | |
110 | { | |
111 | arm_store_vfpregset_num (regcache, buf, 32); | |
112 | } | |
113 | ||
114 | /* Register sets with using PTRACE_GETREGSET. */ | |
115 | ||
116 | static struct regset_info aarch32_regsets[] = { | |
117 | { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, 18 * 4, | |
118 | GENERAL_REGS, | |
119 | arm_fill_gregset, arm_store_gregset }, | |
120 | { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_VFP, 32 * 8 + 4, | |
121 | EXTENDED_REGS, | |
122 | arm_fill_vfpregset, arm_store_vfpregset }, | |
123 | { 0, 0, 0, -1, -1, NULL, NULL } | |
124 | }; | |
125 | ||
126 | static struct regsets_info aarch32_regsets_info = | |
127 | { | |
128 | aarch32_regsets, /* regsets */ | |
129 | 0, /* num_regsets */ | |
130 | NULL, /* disabled_regsets */ | |
131 | }; | |
132 | ||
133 | struct regs_info regs_info_aarch32 = | |
134 | { | |
135 | NULL, /* regset_bitmap */ | |
136 | NULL, /* usrregs */ | |
137 | &aarch32_regsets_info | |
138 | }; | |
139 | ||
140 | void | |
141 | initialize_low_arch_aarch32 (void) | |
142 | { | |
143 | init_registers_arm_with_neon (); | |
144 | ||
145 | initialize_regsets_info (&aarch32_regsets_info); | |
146 | } |