Commit | Line | Data |
---|---|---|
af5ca30d NH |
1 | /* Target-dependent code for OpenBSD/hppa |
2 | ||
b811d2c2 | 3 | Copyright (C) 2004-2020 Free Software Foundation, Inc. |
af5ca30d NH |
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 | |
5b1ba0e5 | 9 | the Free Software Foundation; either version 3 of the License, or |
af5ca30d NH |
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 | |
5b1ba0e5 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
af5ca30d NH |
19 | |
20 | #include "defs.h" | |
21 | #include "osabi.h" | |
22 | #include "regcache.h" | |
23 | #include "regset.h" | |
24 | ||
af5ca30d | 25 | #include "hppa-tdep.h" |
03b62bbb | 26 | #include "hppa-bsd-tdep.h" |
0d12e84c | 27 | #include "gdbarch.h" |
af5ca30d NH |
28 | |
29 | /* Core file support. */ | |
30 | ||
31 | /* Sizeof `struct reg' in <machine/reg.h>. */ | |
cbb6aada MK |
32 | #define HPPAOBSD_SIZEOF_GREGS (34 * 4) /* OpenBSD 5.1 and earlier. */ |
33 | #define HPPANBSD_SIZEOF_GREGS (46 * 4) /* NetBSD and OpenBSD 5.2 and later. */ | |
7c54a108 MK |
34 | |
35 | /* Sizeof `struct fpreg' in <machine/reg.h>. */ | |
36 | #define HPPAOBSD_SIZEOF_FPREGS (32 * 8) | |
af5ca30d NH |
37 | |
38 | /* Supply register REGNUM from the buffer specified by GREGS and LEN | |
39 | in the general-purpose register set REGSET to register cache | |
40 | REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ | |
41 | ||
42 | static void | |
7c54a108 MK |
43 | hppaobsd_supply_gregset (const struct regset *regset, |
44 | struct regcache *regcache, | |
45 | int regnum, const void *gregs, size_t len) | |
af5ca30d | 46 | { |
cbb6aada | 47 | gdb_byte zero[4] = { 0 }; |
9a3c8263 | 48 | const gdb_byte *regs = (const gdb_byte *) gregs; |
af5ca30d NH |
49 | size_t offset; |
50 | int i; | |
51 | ||
7c54a108 | 52 | gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS); |
af5ca30d | 53 | |
cbb6aada | 54 | if (regnum == -1 || regnum == HPPA_R0_REGNUM) |
73e1c03f | 55 | regcache->raw_supply (HPPA_R0_REGNUM, &zero); |
af5ca30d NH |
56 | for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4) |
57 | { | |
58 | if (regnum == -1 || regnum == i) | |
73e1c03f | 59 | regcache->raw_supply (i, regs + offset); |
af5ca30d NH |
60 | } |
61 | ||
cbb6aada MK |
62 | if (len >= HPPANBSD_SIZEOF_GREGS) |
63 | { | |
64 | if (regnum == -1 || regnum == HPPA_IPSW_REGNUM) | |
73e1c03f | 65 | regcache->raw_supply (HPPA_IPSW_REGNUM, regs); |
cbb6aada | 66 | if (regnum == -1 || regnum == HPPA_SAR_REGNUM) |
73e1c03f | 67 | regcache->raw_supply (HPPA_SAR_REGNUM, regs + 32 * 4); |
cbb6aada | 68 | if (regnum == -1 || regnum == HPPA_PCSQ_HEAD_REGNUM) |
73e1c03f | 69 | regcache->raw_supply (HPPA_PCSQ_HEAD_REGNUM, regs + 33 * 4); |
cbb6aada | 70 | if (regnum == -1 || regnum == HPPA_PCSQ_TAIL_REGNUM) |
73e1c03f | 71 | regcache->raw_supply (HPPA_PCSQ_TAIL_REGNUM, regs + 34 * 4); |
cbb6aada | 72 | if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM) |
73e1c03f | 73 | regcache->raw_supply (HPPA_PCOQ_HEAD_REGNUM, regs + 35 * 4); |
cbb6aada | 74 | if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM) |
73e1c03f | 75 | regcache->raw_supply (HPPA_PCOQ_TAIL_REGNUM, regs + 36 * 4); |
cbb6aada | 76 | if (regnum == -1 || regnum == HPPA_SR0_REGNUM) |
73e1c03f | 77 | regcache->raw_supply (HPPA_SR0_REGNUM, regs + 37 * 4); |
cbb6aada | 78 | if (regnum == -1 || regnum == HPPA_SR1_REGNUM) |
73e1c03f | 79 | regcache->raw_supply (HPPA_SR1_REGNUM, regs + 38 * 4); |
cbb6aada | 80 | if (regnum == -1 || regnum == HPPA_SR2_REGNUM) |
73e1c03f | 81 | regcache->raw_supply (HPPA_SR2_REGNUM, regs + 39 * 4); |
cbb6aada | 82 | if (regnum == -1 || regnum == HPPA_SR3_REGNUM) |
73e1c03f | 83 | regcache->raw_supply (HPPA_SR3_REGNUM, regs + 40 * 4); |
cbb6aada | 84 | if (regnum == -1 || regnum == HPPA_SR4_REGNUM) |
73e1c03f | 85 | regcache->raw_supply (HPPA_SR4_REGNUM, regs + 41 * 4); |
cbb6aada | 86 | if (regnum == -1 || regnum == HPPA_SR5_REGNUM) |
73e1c03f | 87 | regcache->raw_supply (HPPA_SR5_REGNUM, regs + 42 * 4); |
cbb6aada | 88 | if (regnum == -1 || regnum == HPPA_SR6_REGNUM) |
73e1c03f | 89 | regcache->raw_supply (HPPA_SR6_REGNUM, regs + 43 * 4); |
cbb6aada | 90 | if (regnum == -1 || regnum == HPPA_SR7_REGNUM) |
73e1c03f | 91 | regcache->raw_supply (HPPA_SR7_REGNUM, regs + 44 * 4); |
cbb6aada | 92 | if (regnum == -1 || regnum == HPPA_CR26_REGNUM) |
73e1c03f | 93 | regcache->raw_supply (HPPA_CR26_REGNUM, regs + 45 * 4); |
cbb6aada | 94 | if (regnum == -1 || regnum == HPPA_CR27_REGNUM) |
73e1c03f | 95 | regcache->raw_supply (HPPA_CR27_REGNUM, regs + 46 * 4); |
cbb6aada MK |
96 | } |
97 | else | |
98 | { | |
99 | if (regnum == -1 || regnum == HPPA_SAR_REGNUM) | |
73e1c03f | 100 | regcache->raw_supply (HPPA_SAR_REGNUM, regs); |
cbb6aada | 101 | if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM) |
73e1c03f | 102 | regcache->raw_supply (HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4); |
cbb6aada | 103 | if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM) |
73e1c03f | 104 | regcache->raw_supply (HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4); |
cbb6aada | 105 | } |
af5ca30d NH |
106 | } |
107 | ||
7c54a108 MK |
108 | /* Supply register REGNUM from the buffer specified by FPREGS and LEN |
109 | in the floating-point register set REGSET to register cache | |
110 | REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ | |
111 | ||
112 | static void | |
113 | hppaobsd_supply_fpregset (const struct regset *regset, | |
114 | struct regcache *regcache, | |
115 | int regnum, const void *fpregs, size_t len) | |
116 | { | |
9a3c8263 | 117 | const gdb_byte *regs = (const gdb_byte *) fpregs; |
7c54a108 MK |
118 | int i; |
119 | ||
120 | gdb_assert (len >= HPPAOBSD_SIZEOF_FPREGS); | |
121 | ||
122 | for (i = HPPA_FP0_REGNUM; i <= HPPA_FP31R_REGNUM; i++) | |
123 | { | |
124 | if (regnum == i || regnum == -1) | |
73e1c03f | 125 | regcache->raw_supply (i, regs + (i - HPPA_FP0_REGNUM) * 4); |
7c54a108 MK |
126 | } |
127 | } | |
128 | ||
129 | /* OpenBSD/hppa register sets. */ | |
af5ca30d | 130 | |
3ca7dae4 | 131 | static const struct regset hppaobsd_gregset = |
af5ca30d NH |
132 | { |
133 | NULL, | |
f962539a AA |
134 | hppaobsd_supply_gregset, |
135 | NULL, | |
136 | REGSET_VARIABLE_SIZE | |
7c54a108 MK |
137 | }; |
138 | ||
3ca7dae4 | 139 | static const struct regset hppaobsd_fpregset = |
7c54a108 MK |
140 | { |
141 | NULL, | |
142 | hppaobsd_supply_fpregset | |
af5ca30d NH |
143 | }; |
144 | ||
50c5eb53 | 145 | /* Iterate over supported core file register note sections. */ |
af5ca30d | 146 | |
50c5eb53 AA |
147 | static void |
148 | hppaobsd_iterate_over_regset_sections (struct gdbarch *gdbarch, | |
149 | iterate_over_regset_sections_cb *cb, | |
150 | void *cb_data, | |
151 | const struct regcache *regcache) | |
af5ca30d | 152 | { |
a616bb94 AH |
153 | cb (".reg", HPPAOBSD_SIZEOF_GREGS, HPPAOBSD_SIZEOF_GREGS, &hppaobsd_gregset, |
154 | NULL, cb_data); | |
155 | cb (".reg2", HPPAOBSD_SIZEOF_FPREGS, HPPAOBSD_SIZEOF_FPREGS, | |
156 | &hppaobsd_fpregset, NULL, cb_data); | |
af5ca30d NH |
157 | } |
158 | \f | |
159 | ||
63807e1d | 160 | static void |
af5ca30d NH |
161 | hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
162 | { | |
163 | /* Obviously OpenBSD is BSD-based. */ | |
164 | hppabsd_init_abi (info, gdbarch); | |
165 | ||
166 | /* Core file support. */ | |
50c5eb53 AA |
167 | set_gdbarch_iterate_over_regset_sections |
168 | (gdbarch, hppaobsd_iterate_over_regset_sections); | |
af5ca30d | 169 | } |
af5ca30d | 170 | |
6c265988 | 171 | void _initialize_hppabsd_tdep (); |
af5ca30d | 172 | void |
6c265988 | 173 | _initialize_hppabsd_tdep () |
af5ca30d | 174 | { |
1736a7bd | 175 | gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD, |
af5ca30d NH |
176 | hppaobsd_init_abi); |
177 | } |