Add translations for various sub-directories
[binutils-gdb.git] / gdb / hppa-obsd-tdep.c
blobfed96372e69a028d8bf8aab62a624f69d5635cac
1 /* Target-dependent code for OpenBSD/hppa
3 Copyright (C) 2004-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "osabi.h"
21 #include "regcache.h"
22 #include "regset.h"
24 #include "hppa-tdep.h"
25 #include "hppa-bsd-tdep.h"
26 #include "gdbarch.h"
28 /* Core file support. */
30 /* Sizeof `struct reg' in <machine/reg.h>. */
31 #define HPPAOBSD_SIZEOF_GREGS (34 * 4) /* OpenBSD 5.1 and earlier. */
32 #define HPPANBSD_SIZEOF_GREGS (46 * 4) /* NetBSD and OpenBSD 5.2 and later. */
34 /* Sizeof `struct fpreg' in <machine/reg.h>. */
35 #define HPPAOBSD_SIZEOF_FPREGS (32 * 8)
37 /* Supply register REGNUM from the buffer specified by GREGS and LEN
38 in the general-purpose register set REGSET to register cache
39 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
41 static void
42 hppaobsd_supply_gregset (const struct regset *regset,
43 struct regcache *regcache,
44 int regnum, const void *gregs, size_t len)
46 const gdb_byte *regs = (const gdb_byte *) gregs;
47 size_t offset;
48 int i;
50 gdb_assert (len >= HPPAOBSD_SIZEOF_GREGS);
52 if (regnum == -1 || regnum == HPPA_R0_REGNUM)
53 regcache->raw_supply_zeroed (HPPA_R0_REGNUM);
54 for (i = HPPA_R1_REGNUM, offset = 4; i <= HPPA_R31_REGNUM; i++, offset += 4)
56 if (regnum == -1 || regnum == i)
57 regcache->raw_supply (i, regs + offset);
60 if (len >= HPPANBSD_SIZEOF_GREGS)
62 if (regnum == -1 || regnum == HPPA_IPSW_REGNUM)
63 regcache->raw_supply (HPPA_IPSW_REGNUM, regs);
64 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
65 regcache->raw_supply (HPPA_SAR_REGNUM, regs + 32 * 4);
66 if (regnum == -1 || regnum == HPPA_PCSQ_HEAD_REGNUM)
67 regcache->raw_supply (HPPA_PCSQ_HEAD_REGNUM, regs + 33 * 4);
68 if (regnum == -1 || regnum == HPPA_PCSQ_TAIL_REGNUM)
69 regcache->raw_supply (HPPA_PCSQ_TAIL_REGNUM, regs + 34 * 4);
70 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
71 regcache->raw_supply (HPPA_PCOQ_HEAD_REGNUM, regs + 35 * 4);
72 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
73 regcache->raw_supply (HPPA_PCOQ_TAIL_REGNUM, regs + 36 * 4);
74 if (regnum == -1 || regnum == HPPA_SR0_REGNUM)
75 regcache->raw_supply (HPPA_SR0_REGNUM, regs + 37 * 4);
76 if (regnum == -1 || regnum == HPPA_SR1_REGNUM)
77 regcache->raw_supply (HPPA_SR1_REGNUM, regs + 38 * 4);
78 if (regnum == -1 || regnum == HPPA_SR2_REGNUM)
79 regcache->raw_supply (HPPA_SR2_REGNUM, regs + 39 * 4);
80 if (regnum == -1 || regnum == HPPA_SR3_REGNUM)
81 regcache->raw_supply (HPPA_SR3_REGNUM, regs + 40 * 4);
82 if (regnum == -1 || regnum == HPPA_SR4_REGNUM)
83 regcache->raw_supply (HPPA_SR4_REGNUM, regs + 41 * 4);
84 if (regnum == -1 || regnum == HPPA_SR5_REGNUM)
85 regcache->raw_supply (HPPA_SR5_REGNUM, regs + 42 * 4);
86 if (regnum == -1 || regnum == HPPA_SR6_REGNUM)
87 regcache->raw_supply (HPPA_SR6_REGNUM, regs + 43 * 4);
88 if (regnum == -1 || regnum == HPPA_SR7_REGNUM)
89 regcache->raw_supply (HPPA_SR7_REGNUM, regs + 44 * 4);
90 if (regnum == -1 || regnum == HPPA_CR26_REGNUM)
91 regcache->raw_supply (HPPA_CR26_REGNUM, regs + 45 * 4);
92 if (regnum == -1 || regnum == HPPA_CR27_REGNUM)
93 regcache->raw_supply (HPPA_CR27_REGNUM, regs + 46 * 4);
95 else
97 if (regnum == -1 || regnum == HPPA_SAR_REGNUM)
98 regcache->raw_supply (HPPA_SAR_REGNUM, regs);
99 if (regnum == -1 || regnum == HPPA_PCOQ_HEAD_REGNUM)
100 regcache->raw_supply (HPPA_PCOQ_HEAD_REGNUM, regs + 32 * 4);
101 if (regnum == -1 || regnum == HPPA_PCOQ_TAIL_REGNUM)
102 regcache->raw_supply (HPPA_PCOQ_TAIL_REGNUM, regs + 33 * 4);
106 /* Supply register REGNUM from the buffer specified by FPREGS and LEN
107 in the floating-point register set REGSET to register cache
108 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
110 static void
111 hppaobsd_supply_fpregset (const struct regset *regset,
112 struct regcache *regcache,
113 int regnum, const void *fpregs, size_t len)
115 const gdb_byte *regs = (const gdb_byte *) fpregs;
116 int i;
118 gdb_assert (len >= HPPAOBSD_SIZEOF_FPREGS);
120 for (i = HPPA_FP0_REGNUM; i <= HPPA_FP31R_REGNUM; i++)
122 if (regnum == i || regnum == -1)
123 regcache->raw_supply (i, regs + (i - HPPA_FP0_REGNUM) * 4);
127 /* OpenBSD/hppa register sets. */
129 static const struct regset hppaobsd_gregset =
131 NULL,
132 hppaobsd_supply_gregset,
133 NULL,
134 REGSET_VARIABLE_SIZE
137 static const struct regset hppaobsd_fpregset =
139 NULL,
140 hppaobsd_supply_fpregset
143 /* Iterate over supported core file register note sections. */
145 static void
146 hppaobsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
147 iterate_over_regset_sections_cb *cb,
148 void *cb_data,
149 const struct regcache *regcache)
151 cb (".reg", HPPAOBSD_SIZEOF_GREGS, HPPAOBSD_SIZEOF_GREGS, &hppaobsd_gregset,
152 NULL, cb_data);
153 cb (".reg2", HPPAOBSD_SIZEOF_FPREGS, HPPAOBSD_SIZEOF_FPREGS,
154 &hppaobsd_fpregset, NULL, cb_data);
158 static void
159 hppaobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
161 /* Obviously OpenBSD is BSD-based. */
162 hppabsd_init_abi (info, gdbarch);
164 /* Core file support. */
165 set_gdbarch_iterate_over_regset_sections
166 (gdbarch, hppaobsd_iterate_over_regset_sections);
169 void _initialize_hppabsd_tdep ();
170 void
171 _initialize_hppabsd_tdep ()
173 gdbarch_register_osabi (bfd_arch_hppa, 0, GDB_OSABI_OPENBSD,
174 hppaobsd_init_abi);