55#include "debug/Checkpoint.hh"
56#include "debug/LLSC.hh"
57#include "debug/MatRegs.hh"
58#include "debug/RiscvMisc.hh"
59#include "debug/VecRegs.hh"
62#include "params/RiscvISA.hh"
71[[maybe_unused]]
const std::array<const char *, NUM_MISCREGS>
MiscRegNames = {{
71[[maybe_unused]]
const std::array<const char *, NUM_MISCREGS>
MiscRegNames = { {
…};
262 _rvType(
p.riscv_type), enableRvv(
p.enable_rvv), vlen(
p.vlen), elen(
p.elen),
263 _privilegeModeSet(
p.privilege_mode_set),
264 _wfiResumeOnPending(
p.wfi_resume_on_pending), _enableZcd(
p.enable_Zcd)
276 "VLEN should be greater or equal",
277 "than ELEN. Ch. 2RISC-V vector spec.");
279 inform(
"RVV enabled, VLEN = %d bits, ELEN = %d bits",
331 misa.rvi = misa.rvm = misa.rva = misa.rvf = misa.rvd = misa.rvc = 1;
340 misa.rvu = misa.rvn = 1;
343 misa.rvs = misa.rvu = 1;
346 misa.rvs = misa.rvu = misa.rvn = 1;
349 panic(
"Privilege mode set config should not reach here");
393 if (hpmcounter < 0 || hpmcounter > 31)
394 panic(
"Illegal HPM counter %d\n", hpmcounter);
409 return (
miscRegFile[counteren] & (1ULL << (hpmcounter))) > 0;
417 DPRINTF(RiscvMisc,
"Reading MiscReg %s (%d): %#x.\n",
430 DPRINTF(RiscvMisc,
"Cycle counter at: %llu.\n",
434 warn(
"Cycle counter disabled.\n");
439 DPRINTF(RiscvMisc,
"Cycle counter at: %llu.\n",
443 warn(
"Cycle counter disabled.\n");
448 DPRINTF(RiscvMisc,
"Wall-clock counter at: %llu.\n",
452 warn(
"Wall clock disabled.\n");
457 DPRINTF(RiscvMisc,
"Wall-clock counter at: %llu.\n",
461 warn(
"Wall clock disabled.\n");
466 DPRINTF(RiscvMisc,
"Instruction counter at: %llu.\n",
470 warn(
"Instruction counter disabled.\n");
475 DPRINTF(RiscvMisc,
"Instruction counter at: %llu.\n",
479 warn(
"Instruction counter disabled.\n");
618 DPRINTF(RiscvMisc,
"HPM counter %d: %llu.\n",
628 DPRINTF(RiscvMisc,
"HPM counter %d: %llu.\n",
645 DPRINTF(RiscvMisc,
"Setting MiscReg %s (%d) to %#x.\n",
693 for (
int i=0;
i < regSize;
i++) {
695 uint8_t cfg_val = (
val >> (8*
i)) & 0xff;
702 bool result = mmu->getPMP()->pmpUpdateCfg(pmp_index,cfg_val);
704 res |= ((
RegVal)cfg_val << (8*
i));
706 res |= (old_val & (0xFF << (8*
i)));
721 if (mmu->getPMP()->pmpUpdateAddr(pmp_index,
val)) {
777 if (new_val.mode != AddrXlateMode::BARE &&
778 new_val.mode != AddrXlateMode::SV39)
779 new_val.mode = cur_val.mode;
786 SENVCFG panic_mask = 0;
789 SENVCFG wpri_mask = 0;
790 wpri_mask.wpri_1 = ~wpri_mask.wpri_1;
791 wpri_mask.wpri_2 = ~wpri_mask.wpri_2;
792 wpri_mask.wpri_3 = ~wpri_mask.wpri_3;
794 if ((panic_mask &
val) != 0) {
795 panic(
"Tried to write to an unimplemented bitfield in the "
796 "senvcfg CSR!\nThe attempted write was:\n %" PRIu64
"\n",
813 MISA new_misa = (MISA)
val;
816 if (new_misa.rvc == 0 &&
819 new_misa.rvc = new_misa.rvc | cur_misa.rvc;
824 new_misa.rvn = cur_misa.rvn;
825 new_misa.rvs = cur_misa.rvs;
826 new_misa.rvu = cur_misa.rvu;
841 val &= ~STATUS_VS_MASK;
912 DPRINTF(Checkpoint,
"Serializing Riscv Misc Registers\n");
919 DPRINTF(Checkpoint,
"Unserializing Riscv Misc Registers\n");
931 DPRINTF(LLSC,
"Locked snoop on address %x.\n", snoop_addr);
932 if ((load_reservation_addr & cacheBlockMask) == snoop_addr)
942 load_reservation_addr = req->getPaddr();
943 DPRINTF(LLSC,
"[cid:%d]: Reserved address %x.\n",
944 req->contextId(), req->getPaddr());
958 DPRINTF(LLSC,
"[cid:%d]: load_reservation_addrs empty? %s.\n",
960 lr_addr_empty ?
"yes" :
"no");
961 if (!lr_addr_empty) {
962 DPRINTF(LLSC,
"[cid:%d]: addr = %x.\n", req->contextId(),
963 req->getPaddr() & cacheBlockMask);
964 DPRINTF(LLSC,
"[cid:%d]: last locked addr = %x.\n", req->contextId(),
965 load_reservation_addr & cacheBlockMask);
968 (load_reservation_addr & cacheBlockMask)
969 != ((req->getPaddr() & cacheBlockMask))) {
970 req->setExtraData(0);
974 warn(
"%i: context %d: %d consecutive SC failures.\n",
983 if (req->isUncacheable()) {
984 req->setExtraData(2);
990 DPRINTF(LLSC,
"[cid:%d]: SC success! Current locked addr = %x.\n",
991 req->contextId(), load_reservation_addr & cacheBlockMask);
1014 if (intr &&
bits(
vec, 1, 0) == 1)
1027 return os <<
"PRV_U";
1029 return os <<
"PRV_S";
1031 return os <<
"PRV_M";
1033 return os <<
"PRV_<invalid>";
BaseInterrupts * getInterruptController(ThreadID tid)
virtual Counter totalInsts() const =0
virtual void wakeup(ThreadID tid)=0
void serialize(CheckpointOut &cp) const override
Serialize an object.
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
virtual std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setMiscReg(RegIndex idx, RegVal val) override
void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override
RegVal readMiscReg(RegIndex idx) override
void globalClearExclusive() override
void serialize(CheckpointOut &cp) const override
Serialize an object.
void resetThread() override
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
RegVal readMiscRegNoEffect(RegIndex idx) const override
bool hpmCounterEnabled(int counter) const
void copyRegsFrom(ThreadContext *src) override
bool handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask) override
bool getEnableRvv() const
std::vector< RegVal > miscRegFile
bool inUserMode() const override
void unserialize(CheckpointIn &cp) override
Unserialize an object.
const Addr INVALID_RESERVATION_ADDR
virtual Addr getFaultHandlerAddr(RegIndex idx, uint64_t cause, bool intr) const
unsigned getVecLenInBytes()
std::unordered_map< int, Addr > load_reservation_addrs
PrivilegeModeSet getPrivilegeModeSet()
void handleLockedRead(const RequestPtr &req) override
void invoke(ThreadContext *tc, const StaticInstPtr &inst=nullStaticInstPtr) override
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal getReg(const RegId ®) const
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
virtual BaseCPU * getCpuPtr()=0
virtual void setReg(const RegId ®, RegVal val)
virtual void setStCondFailures(unsigned sc_failures)=0
virtual unsigned readStCondFailures() const =0
virtual const PCStateBase & pcState() const =0
virtual int threadId() const =0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
virtual BaseMMU * getMMUPtr()=0
virtual ContextID contextId() const =0
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
constexpr T mbits(T val, unsigned first, unsigned last)
Mask off the given bits in place like bits() but without shifting.
#define panic(...)
This implements a cprintf based panic() function.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
#define UNSERIALIZE_CONTAINER(member)
#define SERIALIZE_CONTAINER(member)
constexpr RegClass matRegClass
constexpr RegClass vecElemClass
constexpr RegClass intRegClass
constexpr RegClass vecPredRegClass
constexpr RegClass ccRegClass
constexpr RegClass miscRegClass
const RegVal UI_MASK[enums::Num_PrivilegeModeSet]
const RegVal SI_MASK[enums::Num_PrivilegeModeSet]
constexpr enums::RiscvType RV32
const RegVal SSTATUS_MASKS[enums::Num_RiscvType][enums::Num_PrivilegeModeSet]
const RegVal STATUS_SXL_MASK
const RegVal STATUS_UXL_MASK
const RegVal USTATUS_MASKS[enums::Num_RiscvType][enums::Num_PrivilegeModeSet]
const std::array< const char *, NUM_MISCREGS > MiscRegNames
constexpr RegClass vecRegClass
constexpr enums::RiscvType RV64
const RegVal MI_MASK[enums::Num_PrivilegeModeSet]
const RegVal MSTATUS_MASKS[enums::Num_RiscvType][enums::Num_PrivilegeModeSet]
constexpr RegClass floatRegClass
Copyright (c) 2024 Arm Limited All rights reserved.
std::shared_ptr< Request > RequestPtr
constexpr char CCRegClassName[]
constexpr char VecPredRegClassName[]
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
constexpr char MatRegClassName[]
@ MatRegClass
Matrix Register.
@ CCRegClass
Condition-code register.
@ VecElemClass
Vector Register Native Elem lane.
constexpr char VecElemClassName[]
Declaration of the Packet class.
Declaration of a request, the overall memory request consisting of the parts of the request that are ...