Commit | Line | Data |
---|---|---|
42a4f53d | 1 | /* Copyright (C) 1999-2019 Free Software Foundation, Inc. |
f1b67888 YQ |
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 "defs.h" | |
19 | ||
d55e5aa6 | 20 | #include "regcache.h" |
4de283e4 TT |
21 | #include "arm-tdep.h" |
22 | #include "arm-linux-tdep.h" | |
23 | #include "arch/arm-linux.h" | |
24 | ||
25 | #include "aarch32-linux-nat.h" | |
f1b67888 YQ |
26 | |
27 | /* Supply GP registers contents, stored in REGS, to REGCACHE. ARM_APCS_32 | |
28 | is true if the 32-bit mode is in use, otherwise, it is false. */ | |
29 | ||
30 | void | |
31 | aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs, | |
32 | int arm_apcs_32) | |
33 | { | |
34 | int regno; | |
35 | ||
36 | for (regno = ARM_A1_REGNUM; regno < ARM_PC_REGNUM; regno++) | |
73e1c03f | 37 | regcache->raw_supply (regno, ®s[regno]); |
f1b67888 YQ |
38 | |
39 | if (arm_apcs_32) | |
3539aa13 YQ |
40 | { |
41 | /* Clear reserved bits bit 20 to bit 23. */ | |
42 | regs[ARM_CPSR_GREGNUM] &= 0xff0fffff; | |
73e1c03f | 43 | regcache->raw_supply (ARM_PS_REGNUM, ®s[ARM_CPSR_GREGNUM]); |
3539aa13 | 44 | } |
f1b67888 | 45 | else |
73e1c03f | 46 | regcache->raw_supply (ARM_PS_REGNUM, ®s[ARM_PC_REGNUM]); |
f1b67888 YQ |
47 | |
48 | regs[ARM_PC_REGNUM] = gdbarch_addr_bits_remove | |
ac7936df | 49 | (regcache->arch (), regs[ARM_PC_REGNUM]); |
73e1c03f | 50 | regcache->raw_supply (ARM_PC_REGNUM, ®s[ARM_PC_REGNUM]); |
f1b67888 YQ |
51 | } |
52 | ||
53 | /* Collect GP registers from REGCACHE to buffer REGS. ARM_APCS_32 is | |
54 | true if the 32-bit mode is in use, otherwise, it is false. */ | |
55 | ||
56 | void | |
57 | aarch32_gp_regcache_collect (const struct regcache *regcache, uint32_t *regs, | |
58 | int arm_apcs_32) | |
59 | { | |
60 | int regno; | |
61 | ||
62 | for (regno = ARM_A1_REGNUM; regno <= ARM_PC_REGNUM; regno++) | |
63 | { | |
0ec9f114 | 64 | if (REG_VALID == regcache->get_register_status (regno)) |
34a79281 | 65 | regcache->raw_collect (regno, ®s[regno]); |
f1b67888 YQ |
66 | } |
67 | ||
68 | if (arm_apcs_32 | |
0ec9f114 | 69 | && REG_VALID == regcache->get_register_status (ARM_PS_REGNUM)) |
fc6cda2e YQ |
70 | { |
71 | uint32_t cpsr = regs[ARM_CPSR_GREGNUM]; | |
72 | ||
34a79281 | 73 | regcache->raw_collect (ARM_PS_REGNUM, ®s[ARM_CPSR_GREGNUM]); |
fc6cda2e YQ |
74 | /* Keep reserved bits bit 20 to bit 23. */ |
75 | regs[ARM_CPSR_GREGNUM] = ((regs[ARM_CPSR_GREGNUM] & 0xff0fffff) | |
76 | | (cpsr & 0x00f00000)); | |
77 | } | |
f1b67888 YQ |
78 | } |
79 | ||
80 | /* Supply VFP registers contents, stored in REGS, to REGCACHE. | |
81 | VFP_REGISTER_COUNT is the number of VFP registers. */ | |
82 | ||
83 | void | |
84 | aarch32_vfp_regcache_supply (struct regcache *regcache, gdb_byte *regs, | |
85 | const int vfp_register_count) | |
86 | { | |
87 | int regno; | |
88 | ||
89 | for (regno = 0; regno < vfp_register_count; regno++) | |
73e1c03f | 90 | regcache->raw_supply (regno + ARM_D0_REGNUM, regs + regno * 8); |
f1b67888 | 91 | |
73e1c03f | 92 | regcache->raw_supply (ARM_FPSCR_REGNUM, regs + 32 * 8); |
f1b67888 YQ |
93 | } |
94 | ||
95 | /* Collect VFP registers from REGCACHE to buffer REGS. | |
96 | VFP_REGISTER_COUNT is the number VFP registers. */ | |
97 | ||
98 | void | |
99 | aarch32_vfp_regcache_collect (const struct regcache *regcache, gdb_byte *regs, | |
100 | const int vfp_register_count) | |
101 | { | |
102 | int regno; | |
103 | ||
104 | for (regno = 0; regno < vfp_register_count; regno++) | |
34a79281 | 105 | regcache->raw_collect (regno + ARM_D0_REGNUM, regs + regno * 8); |
f1b67888 | 106 | |
34a79281 | 107 | regcache->raw_collect (ARM_FPSCR_REGNUM, regs + 32 * 8); |
f1b67888 | 108 | } |