summaryrefslogtreecommitdiff
path: root/src/arch/riscv
diff options
context:
space:
mode:
authorAlec Roelke <alec.roelke@gmail.com>2019-08-06 18:11:33 -0400
committerAlec Roelke <alec.roelke@gmail.com>2019-08-23 23:13:40 +0000
commit579c2cd54b1b29e8283f789a5bb221edb53e6f83 (patch)
tree06fcc2a3cc7a786ffa62bed947e69a10da795a88 /src/arch/riscv
parent41f38a559b6b6ed50d821f16b742575d1487d1cf (diff)
downloadgem5-579c2cd54b1b29e8283f789a5bb221edb53e6f83.tar.xz
arch-riscv: fix GDB register cache
Fixes the definition of the RISC-V GDB register cache. The latest version, of RISC-V gdb, commit c3eb4078520dad8234ffd7fbf893ac0da23ad3c8, appears to only accept the 32 integer registers + the PC in the 'g' packet. This functions with the Linux toolchain (riscv64-unknown-linux-gnu-*), but works best with the Newlib toolchain (riscv64-unknown-elf-*). Change-Id: Ie35ea89a45870fb634e6c68236261bde27c86e41 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20028 Reviewed-by: Alec Roelke <alec.roelke@gmail.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Alec Roelke <alec.roelke@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/arch/riscv')
-rw-r--r--src/arch/riscv/remote_gdb.cc18
-rw-r--r--src/arch/riscv/remote_gdb.hh14
2 files changed, 5 insertions, 27 deletions
diff --git a/src/arch/riscv/remote_gdb.cc b/src/arch/riscv/remote_gdb.cc
index fe339ffc8..15d47e265 100644
--- a/src/arch/riscv/remote_gdb.cc
+++ b/src/arch/riscv/remote_gdb.cc
@@ -167,15 +167,6 @@ RemoteGDB::RiscvGdbRegCache::getRegs(ThreadContext *context)
for (int i = 0; i < NumIntArchRegs; i++)
r.gpr[i] = context->readIntReg(i);
r.pc = context->pcState().pc();
- for (int i = 0; i < NumFloatRegs; i++)
- r.fpr[i] = context->readFloatReg(i);
-
- r.csr_base = context->readMiscReg(0);
- r.fflags = context->readMiscReg(CSR_FFLAGS);
- r.frm = context->readMiscReg(CSR_FRM);
- r.fcsr = context->readMiscReg(CSR_FCSR);
- for (int i = ExplicitCSRs; i < NumMiscRegs; i++)
- r.csr[i - ExplicitCSRs] = context->readMiscReg(i);
}
void
@@ -185,15 +176,6 @@ RemoteGDB::RiscvGdbRegCache::setRegs(ThreadContext *context) const
for (int i = 0; i < NumIntArchRegs; i++)
context->setIntReg(i, r.gpr[i]);
context->pcState(r.pc);
- for (int i = 0; i < NumFloatRegs; i++)
- context->setFloatReg(i, r.fpr[i]);
-
- context->setMiscReg(0, r.csr_base);
- context->setMiscReg(CSR_FFLAGS, r.fflags);
- context->setMiscReg(CSR_FRM, r.frm);
- context->setMiscReg(CSR_FCSR, r.fcsr);
- for (int i = ExplicitCSRs; i < NumMiscRegs; i++)
- context->setMiscReg(i, r.csr[i - ExplicitCSRs]);
}
BaseGdbRegCache*
diff --git a/src/arch/riscv/remote_gdb.hh b/src/arch/riscv/remote_gdb.hh
index 7fcb28dbf..02f68d2b2 100644
--- a/src/arch/riscv/remote_gdb.hh
+++ b/src/arch/riscv/remote_gdb.hh
@@ -50,9 +50,12 @@ namespace RiscvISA
class RemoteGDB : public BaseRemoteGDB
{
protected:
- static const int ExplicitCSRs = 4;
+ static const int NumGDBRegs = 4162;
+ static const int NumCSRs = 4096;
bool acc(Addr addr, size_t len);
+ // A breakpoint will be 2 bytes if it is compressed and 4 if not
+ bool checkBpLen(size_t len) override { return len == 2 || len == 4; }
class RiscvGdbRegCache : public BaseGdbRegCache
{
@@ -61,14 +64,7 @@ class RemoteGDB : public BaseRemoteGDB
struct {
uint64_t gpr[NumIntArchRegs];
uint64_t pc;
- uint64_t fpr[NumFloatRegs];
-
- uint64_t csr_base;
- uint32_t fflags;
- uint32_t frm;
- uint32_t fcsr;
- uint64_t csr[NumMiscRegs - ExplicitCSRs];
- } __attribute__((__packed__)) r;
+ } r;
public:
char *data() const { return (char *)&r; }
size_t size() const { return sizeof(r); }