1 /* Copyright (C) 2020-2022 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>
23 #include "netbsd-low.h"
24 #include "arch/aarch64.h"
25 #include "arch/aarch64-insn.h"
28 /* The fill_function for the general-purpose register set. */
31 netbsd_aarch64_fill_gregset (struct regcache
*regcache
, char *buf
)
33 struct reg
*r
= (struct reg
*) buf
;
35 #define netbsd_aarch64_collect_gp(regnum, fld) do { \
36 collect_register (regcache, regnum, &r->fld); \
39 for (size_t i
= 0; i
< ARRAY_SIZE (r
->r_reg
); i
++)
40 netbsd_aarch64_collect_gp (AARCH64_X0_REGNUM
+ i
, r_reg
[i
]);
42 netbsd_aarch64_collect_gp (AARCH64_SP_REGNUM
, r_sp
);
43 netbsd_aarch64_collect_gp (AARCH64_PC_REGNUM
, r_pc
);
46 /* The store_function for the general-purpose register set. */
49 netbsd_aarch64_store_gregset (struct regcache
*regcache
, const char *buf
)
51 struct reg
*r
= (struct reg
*) buf
;
53 #define netbsd_aarch64_supply_gp(regnum, fld) do { \
54 supply_register (regcache, regnum, &r->fld); \
57 for (size_t i
= 0; i
< ARRAY_SIZE (r
->r_reg
); i
++)
58 netbsd_aarch64_supply_gp (AARCH64_X0_REGNUM
+ i
, r_reg
[i
]);
60 netbsd_aarch64_supply_gp (AARCH64_SP_REGNUM
, r_sp
);
61 netbsd_aarch64_supply_gp (AARCH64_PC_REGNUM
, r_pc
);
64 /* Description of all the aarch64-netbsd register sets. */
66 static const struct netbsd_regset_info netbsd_target_regsets
[] =
68 /* General Purpose Registers. */
69 {PT_GETREGS
, PT_SETREGS
, sizeof (struct reg
),
70 netbsd_aarch64_fill_gregset
, netbsd_aarch64_store_gregset
},
71 /* End of list marker. */
72 {0, 0, -1, NULL
, NULL
}
75 /* NetBSD target op definitions for the aarch64 architecture. */
77 class netbsd_aarch64_target
: public netbsd_process_target
80 const netbsd_regset_info
*get_regs_info () override
;
82 void low_arch_setup () override
;
85 /* Return the information to access registers. */
87 const netbsd_regset_info
*
88 netbsd_aarch64_target::get_regs_info ()
90 return netbsd_target_regsets
;
93 /* Architecture-specific setup for the current process. */
96 netbsd_aarch64_target::low_arch_setup ()
99 = aarch64_create_target_description ({});
101 static const char *expedite_regs_aarch64
[] = { "x29", "sp", "pc", NULL
};
102 init_target_desc (tdesc
, expedite_regs_aarch64
);
104 current_process ()->tdesc
= tdesc
;
107 /* The singleton target ops object. */
109 static netbsd_aarch64_target the_netbsd_aarch64_target
;
111 /* The NetBSD target ops object. */
113 netbsd_process_target
*the_netbsd_target
= &the_netbsd_aarch64_target
;