50#include "debug/Context.hh"
51#include "debug/Quiesce.hh"
53#include "params/BaseCPU.hh"
63 const auto ®Classes = one->getIsaPtr()->regClasses();
65 DPRINTF(Context,
"Comparing thread contexts\n");
72 panic(
"Int reg idx %d doesn't match, one: %#x, two: %#x",
81 panic(
"Float reg idx %d doesn't match, one: %#x, two: %#x",
90 one->getReg(
id, vec1.data());
91 two->
getReg(
id, vec2.data());
93 panic(
"Vec reg idx %d doesn't match, one: %#x, two: %#x",
94 id.
index(), vec_class->valString(vec1.data()),
95 vec_class->valString(vec2.data()));
104 one->getReg(
id, pred1.data());
105 two->
getReg(
id, pred2.data());
106 if (pred1 != pred2) {
107 panic(
"Pred reg idx %d doesn't match, one: %s, two: %s",
108 id.
index(), vec_pred_class->valString(pred1.data()),
109 vec_pred_class->valString(pred2.data()));
114 const auto *mat_class = regClasses.at(
MatRegClass);
118 one->getReg(
id, mat1.data());
119 two->
getReg(
id, mat2.data());
121 panic(
"Mat reg idx %d doesn't match, one: %#x, two: %#x",
122 id.
index(), mat_class->valString(mat1.data()),
123 mat_class->valString(mat2.data()));
131 panic(
"Misc reg idx %d doesn't match, one: %#x, two: %#x",
140 panic(
"CC reg idx %d doesn't match, one: %#x, two: %#x",
143 if (one->pcState() != two->
pcState())
144 panic(
"PC state doesn't match.");
145 int id1 = one->cpuId();
146 int id2 = two->
cpuId();
148 panic(
"CPU ids don't match, one: %d, two: %d", id1, id2);
153 panic(
"Context ids don't match, one: %d, two: %d", id1, id2);
164 port->sendFunctional(pkt);
202 const size_t reg_bytes = reg_class->regBytes();
203 const size_t reg_count = reg_class->numRegs();
204 const size_t array_bytes = reg_bytes * reg_count;
206 auto regs = std::make_unique<uint8_t[]>(array_bytes);
207 auto *reg_ptr = regs.get();
208 for (
const auto &
id: *reg_class) {
210 reg_ptr += reg_bytes;
213 arrayParamOut(
cp, std::string(
"regs.") + reg_class->name(), regs.get(),
230 const size_t reg_bytes = reg_class->regBytes();
231 const size_t reg_count = reg_class->numRegs();
232 const size_t array_bytes = reg_bytes * reg_count;
234 auto regs = std::make_unique<uint8_t[]>(array_bytes);
235 arrayParamIn(
cp, std::string(
"regs.") + reg_class->name(), regs.get(),
238 auto *reg_ptr = regs.get();
239 for (
const auto &
id: *reg_class) {
241 reg_ptr += reg_bytes;
245 std::unique_ptr<PCStateBase> pc_state(tc.
pcState().
clone());
246 pc_state->unserialize(
cp);
virtual Port & getDataPort()=0
Purely virtual method that returns a reference to the data port.
const RegClasses & regClasses() const
void serialize(CheckpointOut &cp) const override
Serialize an object.
virtual PCStateBase * clone() const =0
Register ID: describe an architectural register with its class and index.
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
void quiesceTick(ContextID id, Tick when)
void quiesce(ContextID id)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void setStatus(Status new_status)=0
virtual RegVal getReg(const RegId ®) const
virtual System * getSystemPtr()=0
virtual void copyArchRegs(ThreadContext *tc)=0
static void compare(ThreadContext *one, ThreadContext *two)
function to compare two thread contexts (for debugging)
virtual BaseISA * getIsaPtr() const =0
virtual BaseCPU * getCpuPtr()=0
void quiesceTick(Tick resume)
Quiesce, suspend, and schedule activate at resume.
virtual void setReg(const RegId ®, RegVal val)
void quiesce()
Quiesce thread context.
@ Halted
Permanently shut down.
virtual const PCStateBase & pcState() const =0
virtual int threadId() const =0
virtual Status status() const =0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
virtual Process * getProcessPtr()=0
virtual ContextID contextId() const =0
virtual void sendFunctional(PacketPtr pkt)
virtual void setThreadId(int id)=0
virtual void setContextId(ContextID id)=0
virtual int cpuId() const =0
#define panic(...)
This implements a cprintf based panic() function.
Copyright (c) 2024 Arm Limited All rights reserved.
std::ostream CheckpointOut
void unserialize(ThreadContext &tc, CheckpointIn &cp)
void arrayParamOut(CheckpointOut &cp, const std::string &name, const CircleBuf< T > ¶m)
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
uint64_t Tick
Tick count type.
void takeOverFrom(ThreadContext &ntc, ThreadContext &otc)
Copy state between thread contexts in preparation for CPU handover.
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
int ContextID
Globally unique thread context ID.
void arrayParamIn(CheckpointIn &cp, const std::string &name, CircleBuf< T > ¶m)
@ MatRegClass
Matrix Register.
@ FloatRegClass
Floating-point register.
@ CCRegClass
Condition-code register.
@ VecRegClass
Vector Register.
@ IntRegClass
Integer register.
@ MiscRegClass
Control (misc) register.