1 /* Ravenscar RISC-V target support.
3 Copyright (C) 2019-2022 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/>. */
24 #include "riscv-tdep.h"
26 #include "ravenscar-thread.h"
27 #include "riscv-ravenscar-thread.h"
29 #define LAST_REGISTER (RISCV_FIRST_FP_REGNUM + 14)
31 struct riscv_ravenscar_ops
: public ravenscar_arch_ops
33 int reg_offsets
[LAST_REGISTER
+ 1];
35 riscv_ravenscar_ops (struct gdbarch
*arch
);
38 riscv_ravenscar_ops::riscv_ravenscar_ops (struct gdbarch
*arch
)
39 : ravenscar_arch_ops (gdb::make_array_view (reg_offsets
, LAST_REGISTER
+ 1))
41 int reg_size
= riscv_isa_xlen (arch
);
43 for (int regnum
= 0; regnum
<= LAST_REGISTER
; ++regnum
)
46 if (regnum
== RISCV_RA_REGNUM
|| regnum
== RISCV_PC_REGNUM
)
48 else if (regnum
== RISCV_SP_REGNUM
)
50 else if (regnum
== RISCV_ZERO_REGNUM
+ 8) /* S0 */
52 else if (regnum
== RISCV_ZERO_REGNUM
+ 9) /* S1 */
54 else if (regnum
>= RISCV_ZERO_REGNUM
+ 19
55 && regnum
<= RISCV_ZERO_REGNUM
+ 27) /* S2..S11 */
56 offset
= regnum
- (RISCV_ZERO_REGNUM
+ 19) + 4;
57 else if (regnum
>= RISCV_FIRST_FP_REGNUM
58 && regnum
<= RISCV_FIRST_FP_REGNUM
+ 11)
59 offset
= regnum
- RISCV_FIRST_FP_REGNUM
+ 14; /* FS0..FS11 */
66 reg_offsets
[regnum
] = offset
;
70 /* Register riscv_ravenscar_ops in GDBARCH. */
73 register_riscv_ravenscar_ops (struct gdbarch
*gdbarch
)
75 set_gdbarch_ravenscar_ops (gdbarch
, new riscv_ravenscar_ops (gdbarch
));