138#include "arch/riscv/gdb-xml/gdb_xml_riscv_32bit_cpu.hh"
139#include "arch/riscv/gdb-xml/gdb_xml_riscv_32bit_csr.hh"
140#include "arch/riscv/gdb-xml/gdb_xml_riscv_32bit_fpu.hh"
141#include "arch/riscv/gdb-xml/gdb_xml_riscv_32bit_target.hh"
142#include "arch/riscv/gdb-xml/gdb_xml_riscv_64bit_cpu.hh"
143#include "arch/riscv/gdb-xml/gdb_xml_riscv_64bit_csr.hh"
144#include "arch/riscv/gdb-xml/gdb_xml_riscv_64bit_fpu.hh"
145#include "arch/riscv/gdb-xml/gdb_xml_riscv_64bit_target.hh"
153#include "debug/GDBAcc.hh"
160using namespace RiscvISA;
166 panic_if(!isa,
"Cannot derive rv_type from non-riscv isa");
167 return isa->rvType();
174 panic_if(!isa,
"Cannot derive rv_type from non-riscv isa");
175 return isa->getPrivilegeModeSet();
178template <
typename x
int>
187 newVal = (oldVal & ~mask) | (
val &
mask);
191template <
typename x
int>
200 newVal = (oldVal & ~mask) | (
val &
mask);
205 : BaseRemoteGDB(_system, _listen_config),
206 regCache32(this), regCache64(this)
211RemoteGDB::acc(Addr va,
size_t len)
215 MMU *mmu =
static_cast<MMU *
>(context()->getMMUPtr());
219 PrivilegeMode pmode = mmu->getMemPriv(context(), BaseMMU::Read);
220 SATP satp = context()->readMiscReg(MISCREG_SATP);
221 MISA misa = tc->readMiscRegNoEffect(MISCREG_ISA);
222 if (misa.rvs && pmode != PrivilegeMode::PRV_M &&
223 satp.mode != AddrXlateMode::BARE) {
224 Walker *walker = mmu->getDataWalker();
225 Fault fault = walker->startFunctional(
226 context(), paddr, logBytes, BaseMMU::Read);
227 if (fault != NoFault)
233 return context()->getProcessPtr()->pTable->lookup(va) !=
nullptr;
239 DPRINTF(GDBAcc,
"getregs in remotegdb, size %lu\n", size());
244 for (
int i = 0;
i < int_reg::NumArchRegs;
i++) {
250 for (
int i = 0;
i < float_reg::NumRegs;
i++)
354 DPRINTF(GDBAcc,
"setregs in remotegdb \n");
356 for (
int i = 0;
i < int_reg::NumArchRegs;
i++)
361 for (
int i = 0;
i < float_reg::NumRegs;
i++)
436 DPRINTF(GDBAcc,
"getregs in remotegdb, size %lu\n", size());
441 for (
int i = 0;
i < int_reg::NumArchRegs;
i++) {
447 for (
int i = 0;
i < float_reg::NumRegs;
i++)
545 DPRINTF(GDBAcc,
"setregs in remotegdb \n");
547 for (
int i = 0;
i < int_reg::NumArchRegs;
i++)
552 for (
int i = 0;
i < float_reg::NumRegs;
i++)
627RemoteGDB::getXferFeaturesRead(
const std::string &annex, std::string &output)
635#define GDB_XML(x, s) \
637 x, std::string(reinterpret_cast<const char *>(Blobs::s), \
640 static const std::map<std::string, std::string> annexMaps[enums::Num_RiscvType] = {
641 [
RV32] = {
GDB_XML(
"target.xml", gdb_xml_riscv_32bit_target),
642 GDB_XML(
"riscv-32bit-cpu.xml", gdb_xml_riscv_32bit_cpu),
643 GDB_XML(
"riscv-32bit-fpu.xml", gdb_xml_riscv_32bit_fpu),
644 GDB_XML(
"riscv-32bit-csr.xml", gdb_xml_riscv_32bit_csr)},
645 [
RV64] = {
GDB_XML(
"target.xml", gdb_xml_riscv_64bit_target),
646 GDB_XML(
"riscv-64bit-cpu.xml", gdb_xml_riscv_64bit_cpu),
647 GDB_XML(
"riscv-64bit-fpu.xml", gdb_xml_riscv_64bit_fpu),
648 GDB_XML(
"riscv-64bit-csr.xml", gdb_xml_riscv_64bit_csr)},
650 auto& annexMap = annexMaps[getRvType(context())];
651 auto it = annexMap.find(annex);
652 if (it == annexMap.end())
661 BaseGdbRegCache* regs[enums::Num_RiscvType] = {
662 [
RV32] = ®Cache32,
663 [
RV64] = ®Cache64,
RemoteGDB(System *_system, ListenSocketConfig _listen_config)
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
virtual RegVal getReg(const RegId ®) const
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
virtual BaseISA * getIsaPtr() const =0
virtual void setReg(const RegId ®, RegVal val)
virtual const PCStateBase & pcState() const =0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
virtual ContextID contextId() const =0
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
constexpr RegClass intRegClass
constexpr enums::RiscvType RV32
enums::PrivilegeModeSet PrivilegeModeSet
enums::RiscvType RiscvType
const std::unordered_map< int, CSRMetadata > CSRData
const std::unordered_map< int, RegVal > CSRMasks[enums::Num_RiscvType][enums::Num_PrivilegeModeSet]
constexpr enums::RiscvType RV64
constexpr RegClass floatRegClass
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< FaultBase > Fault
static void setRegNoEffectWithMask(ThreadContext *context, RiscvType type, PrivilegeModeSet pms, CSRIndex idx, xint val)
static PrivilegeModeSet getPrivilegeModeSet(ThreadContext *tc)
static void setRegWithMask(ThreadContext *context, RiscvType type, PrivilegeModeSet pms, CSRIndex idx, xint val)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
static RiscvType getRvType(ThreadContext *tc)
Declarations of a non-full system Page Table.