29#ifndef __ARCH_MIPS_MT_HH__
30#define __ARCH_MIPS_MT_HH__
67 switch (
reg.classValue()) {
75 panic(
"Unexpected reg class! (%s)",
reg.className());
89 switch (
reg.classValue()) {
97 panic(
"Unexpected reg class! (%s)",
reg.className());
120 return tcbind.curVPE;
128 return vpeCtrl.targTC;
135 if (tc->status() == TC::Active) {
144 warn(
"%i: Halting thread %i in %s @ PC %x, setting restart PC to %x",
145 curTick(), tc->threadId(), tc->getCpuPtr()->name(),
154 if (tc->status() != TC::Active) {
159 tc->pcState(restartPC);
162 warn(
"%i: Restoring thread %i in %s @ PC %x",
163 curTick(), tc->threadId(), tc->getCpuPtr()->name(), restartPC);
172 int num_threads = mvpConf.ptc + 1;
175 for (
ThreadID tid = 0; tid < num_threads && success == 0; tid++) {
176 TCBindReg tidTCBind =
180 if (tidTCBind.curVPE == tcBind.curVPE) {
182 TCStatusReg tidTCStatus =
185 TCHaltReg tidTCHalt =
188 if (tidTCStatus.da == 1 && tidTCHalt.h == 0 &&
189 tidTCStatus.a == 0 && success == 0) {
199 tidTCStatus.rnst = 0;
207 tidTCStatus.tksu =
status.ksu;
209 tidTCStatus.asid = tcStatus.asid;
219 std::cerr <<
"Bad VPEs" << std::endl;
224 VPEControlReg vpeControl =
226 vpeControl.excpt = 1;
228 fault = std::make_shared<ThreadFault>();
239 ThreadID num_threads = mvpConf0.ptc + 1;
246 for (
ThreadID tid = 0; tid < num_threads; tid++) {
247 TCStatusReg tidTCStatus =
249 TCHaltReg tidTCHalt =
251 TCBindReg tidTCBind =
254 if (tidTCBind.curVPE == tcBind.curVPE &&
255 tidTCBind.curTC == tcBind.curTC &&
256 tidTCStatus.da == 1 &&
258 tidTCStatus.a == 1) {
267 warn(
"%i: Deactivating Hardware Thread Context #%i",
270 }
else if (src_reg > 0) {
271 if ((src_reg & ~yield_mask) != 0) {
273 vpeControl.excpt = 2;
275 fault = std::make_shared<ThreadFault>();
278 }
else if (src_reg != -2) {
280 VPEControlReg vpeControl =
283 if (vpeControl.ysi == 1 && tcStatus.dt == 1 ) {
284 vpeControl.excpt = 4;
285 fault = std::make_shared<ThreadFault>();
290 return src_reg & yield_mask;
307 status.ksu = tcStatus.tksu;
325 tcStatus.tksu =
status.ksu;
virtual ThreadContext * getContext(int tn)
Given a thread num get tho thread context for it.
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
Register ID: describe an architectural register with its class and index.
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 BaseCPU * getCpuPtr()=0
virtual void setReg(const RegId ®, RegVal val)
#define panic(...)
This implements a cprintf based panic() function.
constexpr RegClass intRegClass
constexpr RegClass miscRegClass
void restoreThread(TC *tc)
unsigned getTargetThread(TC *tc)
unsigned getVirtProcNum(TC *tc)
void updateTCStatusView(TC *tc)
static RegVal readRegOtherThread(ThreadContext *tc, const RegId ®, ThreadID tid=InvalidThreadID)
int yieldThread(TC *tc, Fault &fault, int src_reg, uint32_t yield_mask)
void forkThread(TC *tc, Fault &fault, int Rd_bits, int Rs, int Rt)
static void setRegOtherThread(ThreadContext *tc, const RegId ®, RegVal val, ThreadID tid=InvalidThreadID)
void updateStatusView(TC *tc)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< FaultBase > Fault
int16_t ThreadID
Thread index/ID type.
const ThreadID InvalidThreadID
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
@ FloatRegClass
Floating-point register.
@ IntRegClass
Integer register.
@ MiscRegClass
Control (misc) register.