1 /* Copyright (C) 2020-2024 Free Software Foundation, Inc.
3 This file is part of GDB.
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.
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.
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/>. */
18 #include <sys/types.h>
19 #include <sys/ptrace.h>
22 #include "netbsd-low.h"
23 #include "arch/aarch64.h"
24 #include "arch/aarch64-insn.h"
27 /* The fill_function for the general-purpose register set. */
30 netbsd_aarch64_fill_gregset (struct regcache
*regcache
, char *buf
)
32 struct reg
*r
= (struct reg
*) buf
;
34 #define netbsd_aarch64_collect_gp(regnum, fld) do { \
35 collect_register (regcache, regnum, &r->fld); \
38 for (size_t i
= 0; i
< ARRAY_SIZE (r
->r_reg
); i
++)
39 netbsd_aarch64_collect_gp (AARCH64_X0_REGNUM
+ i
, r_reg
[i
]);
41 netbsd_aarch64_collect_gp (AARCH64_SP_REGNUM
, r_sp
);
42 netbsd_aarch64_collect_gp (AARCH64_PC_REGNUM
, r_pc
);
45 /* The store_function for the general-purpose register set. */
48 netbsd_aarch64_store_gregset (struct regcache
*regcache
, const char *buf
)
50 struct reg
*r
= (struct reg
*) buf
;
52 #define netbsd_aarch64_supply_gp(regnum, fld) do { \
53 supply_register (regcache, regnum, &r->fld); \
56 for (size_t i
= 0; i
< ARRAY_SIZE (r
->r_reg
); i
++)
57 netbsd_aarch64_supply_gp (AARCH64_X0_REGNUM
+ i
, r_reg
[i
]);
59 netbsd_aarch64_supply_gp (AARCH64_SP_REGNUM
, r_sp
);
60 netbsd_aarch64_supply_gp (AARCH64_PC_REGNUM
, r_pc
);
63 /* Description of all the aarch64-netbsd register sets. */
65 static const struct netbsd_regset_info netbsd_target_regsets
[] =
67 /* General Purpose Registers. */
68 {PT_GETREGS
, PT_SETREGS
, sizeof (struct reg
),
69 netbsd_aarch64_fill_gregset
, netbsd_aarch64_store_gregset
},
70 /* End of list marker. */
71 {0, 0, -1, NULL
, NULL
}
74 /* NetBSD target op definitions for the aarch64 architecture. */
76 class netbsd_aarch64_target
: public netbsd_process_target
79 const netbsd_regset_info
*get_regs_info () override
;
81 void low_arch_setup () override
;
84 /* Return the information to access registers. */
86 const netbsd_regset_info
*
87 netbsd_aarch64_target::get_regs_info ()
89 return netbsd_target_regsets
;
92 /* Architecture-specific setup for the current process. */
95 netbsd_aarch64_target::low_arch_setup ()
98 = aarch64_create_target_description ({});
100 static const char *expedite_regs_aarch64
[] = { "x29", "sp", "pc", NULL
};
101 init_target_desc (tdesc
, expedite_regs_aarch64
, GDB_OSABI_NETBSD
);
103 current_process ()->tdesc
= tdesc
;
106 /* The singleton target ops object. */
108 static netbsd_aarch64_target the_netbsd_aarch64_target
;
110 /* The NetBSD target ops object. */
112 netbsd_process_target
*the_netbsd_target
= &the_netbsd_aarch64_target
;