gem5  v22.1.0.0
remote_gdb.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Huawei International
3  * Copyright (c) 2017 The University of Virginia
4  * Copyright 2015 LabWare
5  * Copyright 2014 Google, Inc.
6  * Copyright (c) 2007 The Regents of The University of Michigan
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are
11  * met: redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer;
13  * redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution;
16  * neither the name of the copyright holders nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef __ARCH_RISCV_REMOTE_GDB_HH__
34 #define __ARCH_RISCV_REMOTE_GDB_HH__
35 
36 #include <string>
37 
38 #include "arch/riscv/regs/float.hh"
39 #include "arch/riscv/regs/int.hh"
40 #include "base/remote_gdb.hh"
41 
42 namespace gem5
43 {
44 
45 class System;
46 class ThreadContext;
47 
48 namespace RiscvISA
49 {
50 
51 class RemoteGDB : public BaseRemoteGDB
52 {
53  protected:
54  static const int NumGDBRegs = 4162;
55  static const int NumCSRs = 4096;
56 
57  bool acc(Addr addr, size_t len) override;
58  // A breakpoint will be 2 bytes if it is compressed and 4 if not
59  bool checkBpKind(size_t kind) override { return kind == 2 || kind == 4; }
60 
62  {
64  private:
73  struct
74  {
76  uint64_t pc;
78  uint32_t fflags;
79  uint32_t frm;
80  uint32_t fcsr;
81  // Placeholder for byte alignment
82  uint32_t placeholder;
83  uint64_t cycle;
84  uint64_t time;
85  uint64_t ustatus;
86  uint64_t uie;
87  uint64_t utvec;
88  uint64_t uscratch;
89  uint64_t uepc;
90  uint64_t ucause;
91  uint64_t utval;
92  uint64_t uip;
93  uint64_t sstatus;
94  uint64_t sedeleg;
95  uint64_t sideleg;
96  uint64_t sie;
97  uint64_t stvec;
98  uint64_t scounteren;
99  uint64_t sscratch;
100  uint64_t sepc;
101  uint64_t scause;
102  uint64_t stval;
103  uint64_t sip;
104  uint64_t satp;
105  uint64_t mvendorid;
106  uint64_t marchid;
107  uint64_t mimpid;
108  uint64_t mhartid;
109  uint64_t mstatus;
110  uint64_t misa;
111  uint64_t medeleg;
112  uint64_t mideleg;
113  uint64_t mie;
114  uint64_t mtvec;
115  uint64_t mcounteren;
116  uint64_t mscratch;
117  uint64_t mepc;
118  uint64_t mcause;
119  uint64_t mtval;
120  uint64_t mip;
121  uint64_t hstatus;
122  uint64_t hedeleg;
123  uint64_t hideleg;
124  uint64_t hie;
125  uint64_t htvec;
126  uint64_t hscratch;
127  uint64_t hepc;
128  uint64_t hcause;
129  uint64_t hbadaddr;
130  uint64_t hip;
131  } r;
132  public:
133  char *data() const { return (char *)&r; }
134  size_t size() const { return sizeof(r); }
135  void getRegs(ThreadContext*);
136  void setRegs(ThreadContext*) const;
137 
138  const std::string
139  name() const
140  {
141  return gdb->name() + ".RiscvGdbRegCache";
142  }
143  };
144 
146 
147  public:
148  RemoteGDB(System *_system, int _port);
155  availableFeatures() const override
156  {
157  return {"qXfer:features:read+"};
158  };
162  bool getXferFeaturesRead(const std::string &annex,
163  std::string &output) override;
164 };
165 
166 } // namespace RiscvISA
167 } // namespace gem5
168 
169 #endif /* __ARCH_RISCV_REMOTE_GDB_H__ */
Concrete subclasses of this abstract class represent how the register values are transmitted on the w...
Definition: remote_gdb.hh:86
BaseRemoteGDB * gdb
Definition: remote_gdb.hh:140
const std::string name() const
Return the name to use in places like DPRINTF.
Definition: remote_gdb.hh:139
uint64_t gpr[int_reg::NumArchRegs]
Definition: remote_gdb.hh:75
void setRegs(ThreadContext *) const
Set the ThreadContext's registers from the values in the raw buffer.
Definition: remote_gdb.cc:297
struct gem5::RiscvISA::RemoteGDB::RiscvGdbRegCache::@21 r
RISC-V Register Cache Order and sizes of registers found in ext/gdb-xml/riscv.xml To add support for ...
size_t size() const
Return the size of the raw buffer, in bytes (i.e., half of the number of digits in the g/G packet).
Definition: remote_gdb.hh:134
void getRegs(ThreadContext *)
Fill the raw buffer from the registers in the ThreadContext.
Definition: remote_gdb.cc:189
char * data() const
Return the pointer to the raw bytes buffer containing the register values.
Definition: remote_gdb.hh:133
uint64_t fpu[float_reg::NumRegs]
Definition: remote_gdb.hh:77
static const int NumCSRs
Definition: remote_gdb.hh:55
std::vector< std::string > availableFeatures() const override
Informs GDB remote serial protocol that XML features are supported GDB then queries for xml blobs usi...
Definition: remote_gdb.hh:155
bool getXferFeaturesRead(const std::string &annex, std::string &output) override
Reply to qXfer:features:read:xxx.xml qeuries.
BaseGdbRegCache * gdbRegs() override
bool acc(Addr addr, size_t len) override
static const int NumGDBRegs
Definition: remote_gdb.hh:54
bool checkBpKind(size_t kind) override
Definition: remote_gdb.hh:59
RemoteGDB(System *_system, int _port)
RiscvGdbRegCache regCache
Definition: remote_gdb.hh:145
ThreadContext is the external interface to all thread state for anything outside of the CPU.
BaseGdbRegCache(BaseRemoteGDB *g)
Definition: remote_gdb.hh:134
std::string name()
Definition: remote_gdb.cc:407
uint16_t len
Definition: helpers.cc:62
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
static void output(const char *filename)
Definition: debug.cc:60

Generated on Wed Dec 21 2022 10:22:25 for gem5 by doxygen 1.9.1