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