]> Git Repo - binutils.git/blob - gdb/riscv-ravenscar-thread.c
Automatic date update in version.in
[binutils.git] / gdb / riscv-ravenscar-thread.c
1 /* Ravenscar RISC-V target support.
2
3    Copyright (C) 2019-2022 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
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.
11
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.
16
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/>.  */
19
20 #include "defs.h"
21 #include "gdbarch.h"
22 #include "gdbcore.h"
23 #include "regcache.h"
24 #include "riscv-tdep.h"
25 #include "inferior.h"
26 #include "ravenscar-thread.h"
27 #include "riscv-ravenscar-thread.h"
28
29 #define LAST_REGISTER (RISCV_FIRST_FP_REGNUM + 14)
30
31 struct riscv_ravenscar_ops : public ravenscar_arch_ops
32 {
33   int reg_offsets[LAST_REGISTER + 1];
34
35   riscv_ravenscar_ops (struct gdbarch *arch);
36 };
37
38 riscv_ravenscar_ops::riscv_ravenscar_ops (struct gdbarch *arch)
39   : ravenscar_arch_ops (gdb::make_array_view (reg_offsets, LAST_REGISTER + 1))
40 {
41   int reg_size = riscv_isa_xlen (arch);
42
43   for (int regnum = 0; regnum <= LAST_REGISTER; ++regnum)
44     {
45       int offset;
46       if (regnum == RISCV_RA_REGNUM || regnum == RISCV_PC_REGNUM)
47         offset = 0;
48       else if (regnum == RISCV_SP_REGNUM)
49         offset = 1;
50       else if (regnum == RISCV_ZERO_REGNUM + 8) /* S0 */
51         offset = 2;
52       else if (regnum == RISCV_ZERO_REGNUM + 9) /* S1 */
53         offset = 3;
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 */
60       else
61         offset = -1;
62
63       if (offset != -1)
64         offset *= reg_size;
65
66       reg_offsets[regnum] = offset;
67     }
68 }
69
70 /* Register riscv_ravenscar_ops in GDBARCH.  */
71
72 void
73 register_riscv_ravenscar_ops (struct gdbarch *gdbarch)
74 {
75   set_gdbarch_ravenscar_ops (gdbarch, new riscv_ravenscar_ops (gdbarch));
76 }
This page took 0.027965 seconds and 4 git commands to generate.