1 /* Ravenscar RISC-V target support.
3 Copyright (C) 2019-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/>. */
23 #include "riscv-tdep.h"
25 #include "ravenscar-thread.h"
26 #include "riscv-ravenscar-thread.h"
28 #define LAST_REGISTER (RISCV_FIRST_FP_REGNUM + 14)
30 struct riscv_ravenscar_ops
: public ravenscar_arch_ops
32 int reg_offsets
[LAST_REGISTER
+ 1];
34 riscv_ravenscar_ops (struct gdbarch
*arch
);
37 riscv_ravenscar_ops::riscv_ravenscar_ops (struct gdbarch
*arch
)
38 : ravenscar_arch_ops (gdb::make_array_view (reg_offsets
, LAST_REGISTER
+ 1))
40 int reg_size
= riscv_isa_xlen (arch
);
42 for (int regnum
= 0; regnum
<= LAST_REGISTER
; ++regnum
)
45 if (regnum
== RISCV_RA_REGNUM
|| regnum
== RISCV_PC_REGNUM
)
47 else if (regnum
== RISCV_SP_REGNUM
)
49 else if (regnum
== RISCV_ZERO_REGNUM
+ 8) /* S0 */
51 else if (regnum
== RISCV_ZERO_REGNUM
+ 9) /* S1 */
53 else if (regnum
>= RISCV_ZERO_REGNUM
+ 19
54 && regnum
<= RISCV_ZERO_REGNUM
+ 27) /* S2..S11 */
55 offset
= regnum
- (RISCV_ZERO_REGNUM
+ 19) + 4;
56 else if (regnum
>= RISCV_FIRST_FP_REGNUM
57 && regnum
<= RISCV_FIRST_FP_REGNUM
+ 11)
58 offset
= regnum
- RISCV_FIRST_FP_REGNUM
+ 14; /* FS0..FS11 */
65 reg_offsets
[regnum
] = offset
;
69 /* Register riscv_ravenscar_ops in GDBARCH. */
72 register_riscv_ravenscar_ops (struct gdbarch
*gdbarch
)
74 set_gdbarch_ravenscar_ops (gdbarch
, new riscv_ravenscar_ops (gdbarch
));