gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
gem5::o3::ThreadContext Class Reference

Derived ThreadContext class for use with the O3CPU. More...

#include <thread_context.hh>

Inheritance diagram for gem5::o3::ThreadContext:
gem5::ThreadContext gem5::PCEventScope

Public Member Functions

bool schedule (PCEvent *e) override
 
bool remove (PCEvent *e) override
 
void scheduleInstCountEvent (Event *event, Tick count) override
 
void descheduleInstCountEvent (Event *event) override
 
Tick getCurrentInstCount () override
 
BaseMMUgetMMUPtr () override
 Returns a pointer to the MMU.
 
CheckerCPUgetCheckerCpuPtr () override
 
BaseISAgetIsaPtr () const override
 
InstDecodergetDecoderPtr () override
 
BaseCPUgetCpuPtr () override
 Returns a pointer to this CPU.
 
int cpuId () const override
 Reads this CPU's ID.
 
uint32_t socketId () const override
 Reads this CPU's Socket ID.
 
ContextID contextId () const override
 
void setContextId (ContextID id) override
 
int threadId () const override
 Returns this thread's ID number.
 
void setThreadId (int id) override
 
SystemgetSystemPtr () override
 Returns a pointer to the system.
 
ProcessgetProcessPtr () override
 Returns a pointer to this thread's process.
 
void setProcessPtr (Process *p) override
 
Status status () const override
 Returns this thread's status.
 
void setStatus (Status new_status) override
 Sets this thread's status.
 
void activate () override
 Set the status to Active.
 
void suspend () override
 Set the status to Suspended.
 
void halt () override
 Set the status to Halted.
 
void takeOverFrom (gem5::ThreadContext *old_context) override
 Takes over execution of a thread from another CPU.
 
Tick readLastActivate () override
 Reads the last tick that this thread was activated on.
 
Tick readLastSuspend () override
 Reads the last tick that this thread was suspended on.
 
void copyArchRegs (gem5::ThreadContext *tc) override
 Copies the architectural registers from another TC into this TC.
 
void clearArchRegs () override
 Resets all architectural registers to 0.
 
const PCStateBasepcState () const override
 Reads this thread's PC state.
 
void pcState (const PCStateBase &val) override
 Sets this thread's PC state.
 
void pcStateNoRecord (const PCStateBase &val) override
 
RegVal readMiscRegNoEffect (RegIndex misc_reg) const override
 Reads a miscellaneous register.
 
RegVal readMiscReg (RegIndex misc_reg) override
 Reads a misc.
 
void setMiscRegNoEffect (RegIndex misc_reg, RegVal val) override
 Sets a misc.
 
void setMiscReg (RegIndex misc_reg, RegVal val) override
 Sets a misc.
 
unsigned readStCondFailures () const override
 Returns the number of consecutive store conditional failures.
 
void setStCondFailures (unsigned sc_failures) override
 Sets the number of consecutive store conditional failures.
 
void conditionalSquash ()
 check if the cpu is currently in state update mode and squash if not.
 
RegVal getReg (const RegId &reg) const override
 
void getReg (const RegId &reg, void *val) const override
 
void * getWritableReg (const RegId &reg) override
 
void setReg (const RegId &reg, RegVal val) override
 
void setReg (const RegId &reg, const void *val) override
 
void htmAbortTransaction (uint64_t htm_uid, HtmFailureFaultCause cause) override
 
BaseHTMCheckpointPtrgetHtmCheckpointPtr () override
 
void setHtmCheckpointPtr (BaseHTMCheckpointPtr new_cpt) override
 
- Public Member Functions inherited from gem5::ThreadContext
bool getUseForClone ()
 
void setUseForClone (bool new_val)
 
virtual ~ThreadContext ()
 
virtual void sendFunctional (PacketPtr pkt)
 
void quiesce ()
 Quiesce thread context.
 
void quiesceTick (Tick resume)
 Quiesce, suspend, and schedule activate at resume.
 
virtual void regStats (const std::string &name)
 
void pcState (Addr addr)
 
virtual int exit ()
 

Public Attributes

CPUcpu
 Pointer to the CPU.
 
ThreadStatethread
 Pointer to the thread state that this TC corrseponds to.
 
- Public Attributes inherited from gem5::ThreadContext
int intResult = DefaultIntResult
 
double floatResult = DefaultFloatResult
 
int intOffset = 0
 

Additional Inherited Members

- Public Types inherited from gem5::ThreadContext
enum  Status { Active , Suspended , Halting , Halted }
 
- Static Public Member Functions inherited from gem5::ThreadContext
static void compare (ThreadContext *one, ThreadContext *two)
 function to compare two thread contexts (for debugging)
 
- Static Public Attributes inherited from gem5::ThreadContext
static const int ints []
 
static const double floats []
 
static const int DefaultIntResult = 0
 
static const double DefaultFloatResult = 0.0
 
- Protected Attributes inherited from gem5::ThreadContext
bool useForClone = false
 

Detailed Description

Derived ThreadContext class for use with the O3CPU.

It provides the interface for any external objects to access a single thread's state and some general CPU state. Any time external objects try to update state through this interface, the CPU will create an event to squash all in-flight instructions in order to ensure state is maintained correctly. It must be defined specifically for the O3CPU because not all architectural state is located within the ThreadState (such as the commit PC, and registers), and specific actions must be taken when using this interface (such as squashing all in-flight instructions when doing a write to this interface).

Definition at line 67 of file thread_context.hh.

Member Function Documentation

◆ activate()

void gem5::o3::ThreadContext::activate ( )
overridevirtual

Set the status to Active.

Implements gem5::ThreadContext.

Definition at line 68 of file thread_context.cc.

References gem5::ThreadContext::Active, cpu, gem5::curTick(), DPRINTF, thread, and threadId().

◆ clearArchRegs()

void gem5::o3::ThreadContext::clearArchRegs ( )
overridevirtual

Resets all architectural registers to 0.

Implements gem5::ThreadContext.

Definition at line 145 of file thread_context.cc.

References cpu, and thread.

◆ conditionalSquash()

void gem5::o3::ThreadContext::conditionalSquash ( )
inline

check if the cpu is currently in state update mode and squash if not.

This function will return true if a trap is pending or if a fault or similar is currently writing to the thread context and doesn't want reset all the state (see noSquashFromTC).

Definition at line 233 of file thread_context.hh.

References cpu, and thread.

Referenced by htmAbortTransaction(), pcState(), pcStateNoRecord(), setMiscReg(), setMiscRegNoEffect(), setReg(), and setReg().

◆ contextId()

ContextID gem5::o3::ThreadContext::contextId ( ) const
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 129 of file thread_context.hh.

References thread.

◆ copyArchRegs()

void gem5::o3::ThreadContext::copyArchRegs ( gem5::ThreadContext * tc)
overridevirtual

Copies the architectural registers from another TC into this TC.

Implements gem5::ThreadContext.

Definition at line 136 of file thread_context.cc.

References gem5::BaseISA::copyRegsFrom(), getIsaPtr(), and thread.

◆ cpuId()

int gem5::o3::ThreadContext::cpuId ( ) const
inlineoverridevirtual

Reads this CPU's ID.

Implements gem5::ThreadContext.

Definition at line 124 of file thread_context.hh.

References cpu.

◆ descheduleInstCountEvent()

void gem5::o3::ThreadContext::descheduleInstCountEvent ( Event * event)
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 90 of file thread_context.hh.

References gem5::MipsISA::event, and thread.

◆ getCheckerCpuPtr()

CheckerCPU * gem5::o3::ThreadContext::getCheckerCpuPtr ( )
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 106 of file thread_context.hh.

◆ getCpuPtr()

BaseCPU * gem5::o3::ThreadContext::getCpuPtr ( )
inlineoverridevirtual

Returns a pointer to this CPU.

Implements gem5::ThreadContext.

Definition at line 121 of file thread_context.hh.

References cpu.

◆ getCurrentInstCount()

Tick gem5::o3::ThreadContext::getCurrentInstCount ( )
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 95 of file thread_context.hh.

References thread.

◆ getDecoderPtr()

InstDecoder * gem5::o3::ThreadContext::getDecoderPtr ( )
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 115 of file thread_context.hh.

References cpu, and thread.

Referenced by takeOverFrom().

◆ getHtmCheckpointPtr()

BaseHTMCheckpointPtr & gem5::o3::ThreadContext::getHtmCheckpointPtr ( )
overridevirtual

Implements gem5::ThreadContext.

Definition at line 225 of file thread_context.cc.

References thread.

◆ getIsaPtr()

BaseISA * gem5::o3::ThreadContext::getIsaPtr ( ) const
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 109 of file thread_context.hh.

References cpu, and thread.

Referenced by copyArchRegs(), and takeOverFrom().

◆ getMMUPtr()

BaseMMU * gem5::o3::ThreadContext::getMMUPtr ( )
inlineoverridevirtual

Returns a pointer to the MMU.

Implements gem5::ThreadContext.

Definition at line 104 of file thread_context.hh.

References cpu.

◆ getProcessPtr()

Process * gem5::o3::ThreadContext::getProcessPtr ( )
inlineoverridevirtual

Returns a pointer to this thread's process.

Implements gem5::ThreadContext.

Definition at line 141 of file thread_context.hh.

References thread.

◆ getReg() [1/2]

RegVal gem5::o3::ThreadContext::getReg ( const RegId & reg) const
overridevirtual

Reimplemented from gem5::ThreadContext.

Definition at line 151 of file thread_context.cc.

References cpu, gem5::X86ISA::reg, and thread.

◆ getReg() [2/2]

void gem5::o3::ThreadContext::getReg ( const RegId & reg,
void * val ) const
overridevirtual

Implements gem5::ThreadContext.

Definition at line 163 of file thread_context.cc.

References cpu, gem5::X86ISA::reg, thread, and gem5::X86ISA::val.

◆ getSystemPtr()

System * gem5::o3::ThreadContext::getSystemPtr ( )
inlineoverridevirtual

Returns a pointer to the system.

Implements gem5::ThreadContext.

Definition at line 138 of file thread_context.hh.

References cpu.

◆ getWritableReg()

void * gem5::o3::ThreadContext::getWritableReg ( const RegId & reg)
overridevirtual

Implements gem5::ThreadContext.

Definition at line 157 of file thread_context.cc.

References cpu, gem5::X86ISA::reg, and thread.

◆ halt()

void gem5::o3::ThreadContext::halt ( )
overridevirtual

Set the status to Halted.

Implements gem5::ThreadContext.

Definition at line 105 of file thread_context.cc.

References cpu, DPRINTF, gem5::ThreadContext::Halted, gem5::ThreadContext::Halting, thread, and threadId().

◆ htmAbortTransaction()

void gem5::o3::ThreadContext::htmAbortTransaction ( uint64_t htm_uid,
HtmFailureFaultCause cause )
overridevirtual

Implements gem5::ThreadContext.

Definition at line 216 of file thread_context.cc.

References conditionalSquash(), cpu, and thread.

◆ pcState() [1/2]

const PCStateBase & gem5::o3::ThreadContext::pcState ( ) const
inlineoverridevirtual

Reads this thread's PC state.

Implements gem5::ThreadContext.

Definition at line 180 of file thread_context.hh.

References cpu, and thread.

◆ pcState() [2/2]

void gem5::o3::ThreadContext::pcState ( const PCStateBase & val)
overridevirtual

Sets this thread's PC state.

Implements gem5::ThreadContext.

Definition at line 183 of file thread_context.cc.

References conditionalSquash(), cpu, thread, and gem5::X86ISA::val.

◆ pcStateNoRecord()

void gem5::o3::ThreadContext::pcStateNoRecord ( const PCStateBase & val)
overridevirtual

Implements gem5::ThreadContext.

Definition at line 191 of file thread_context.cc.

References conditionalSquash(), cpu, thread, and gem5::X86ISA::val.

◆ readLastActivate()

Tick gem5::o3::ThreadContext::readLastActivate ( )
overridevirtual

Reads the last tick that this thread was activated on.

Implements gem5::ThreadContext.

Definition at line 124 of file thread_context.cc.

References thread.

◆ readLastSuspend()

Tick gem5::o3::ThreadContext::readLastSuspend ( )
overridevirtual

Reads the last tick that this thread was suspended on.

Implements gem5::ThreadContext.

Definition at line 130 of file thread_context.cc.

References thread.

◆ readMiscReg()

RegVal gem5::o3::ThreadContext::readMiscReg ( RegIndex misc_reg)
inlineoverridevirtual

Reads a misc.

register, including any side-effects the read might have as defined by the architecture.

Implements gem5::ThreadContext.

Definition at line 200 of file thread_context.hh.

References cpu, and thread.

◆ readMiscRegNoEffect()

RegVal gem5::o3::ThreadContext::readMiscRegNoEffect ( RegIndex misc_reg) const
inlineoverridevirtual

Reads a miscellaneous register.

Implements gem5::ThreadContext.

Definition at line 192 of file thread_context.hh.

References cpu, and thread.

◆ readStCondFailures()

unsigned gem5::o3::ThreadContext::readStCondFailures ( ) const
inlineoverridevirtual

Returns the number of consecutive store conditional failures.

Implements gem5::ThreadContext.

Definition at line 215 of file thread_context.hh.

References thread.

◆ remove()

bool gem5::o3::ThreadContext::remove ( PCEvent * e)
inlineoverridevirtual

Implements gem5::PCEventScope.

Definition at line 79 of file thread_context.hh.

References gem5::ArmISA::e, and thread.

◆ schedule()

bool gem5::o3::ThreadContext::schedule ( PCEvent * e)
inlineoverridevirtual

Implements gem5::PCEventScope.

Definition at line 74 of file thread_context.hh.

References gem5::ArmISA::e, and thread.

◆ scheduleInstCountEvent()

void gem5::o3::ThreadContext::scheduleInstCountEvent ( Event * event,
Tick count )
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 85 of file thread_context.hh.

References gem5::X86ISA::count, gem5::MipsISA::event, and thread.

◆ setContextId()

void gem5::o3::ThreadContext::setContextId ( ContextID id)
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 131 of file thread_context.hh.

References thread.

◆ setHtmCheckpointPtr()

void gem5::o3::ThreadContext::setHtmCheckpointPtr ( BaseHTMCheckpointPtr new_cpt)
overridevirtual

Implements gem5::ThreadContext.

Definition at line 231 of file thread_context.cc.

References thread.

◆ setMiscReg()

void gem5::o3::ThreadContext::setMiscReg ( RegIndex misc_reg,
RegVal val )
overridevirtual

Sets a misc.

register, including any side-effects the write might have as defined by the architecture.

Implements gem5::ThreadContext.

Definition at line 207 of file thread_context.cc.

References conditionalSquash(), cpu, thread, and gem5::X86ISA::val.

◆ setMiscRegNoEffect()

void gem5::o3::ThreadContext::setMiscRegNoEffect ( RegIndex misc_reg,
RegVal val )
overridevirtual

Sets a misc.

register.

Implements gem5::ThreadContext.

Definition at line 199 of file thread_context.cc.

References conditionalSquash(), cpu, thread, and gem5::X86ISA::val.

◆ setProcessPtr()

void gem5::o3::ThreadContext::setProcessPtr ( Process * p)
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 143 of file thread_context.hh.

References gem5::MipsISA::p, and thread.

◆ setReg() [1/2]

void gem5::o3::ThreadContext::setReg ( const RegId & reg,
const void * val )
overridevirtual

Implements gem5::ThreadContext.

Definition at line 176 of file thread_context.cc.

References conditionalSquash(), cpu, gem5::X86ISA::reg, thread, and gem5::X86ISA::val.

◆ setReg() [2/2]

void gem5::o3::ThreadContext::setReg ( const RegId & reg,
RegVal val )
overridevirtual

Reimplemented from gem5::ThreadContext.

Definition at line 169 of file thread_context.cc.

References conditionalSquash(), cpu, gem5::X86ISA::reg, thread, and gem5::X86ISA::val.

◆ setStatus()

void gem5::o3::ThreadContext::setStatus ( Status new_status)
inlineoverridevirtual

Sets this thread's status.

Implements gem5::ThreadContext.

Definition at line 150 of file thread_context.hh.

References thread.

◆ setStCondFailures()

void gem5::o3::ThreadContext::setStCondFailures ( unsigned sc_failures)
inlineoverridevirtual

Sets the number of consecutive store conditional failures.

Implements gem5::ThreadContext.

Definition at line 222 of file thread_context.hh.

References thread.

◆ setThreadId()

void gem5::o3::ThreadContext::setThreadId ( int id)
inlineoverridevirtual

Implements gem5::ThreadContext.

Definition at line 135 of file thread_context.hh.

References thread.

◆ socketId()

uint32_t gem5::o3::ThreadContext::socketId ( ) const
inlineoverridevirtual

Reads this CPU's Socket ID.

Implements gem5::ThreadContext.

Definition at line 127 of file thread_context.hh.

References cpu.

◆ status()

Status gem5::o3::ThreadContext::status ( ) const
inlineoverridevirtual

Returns this thread's status.

Implements gem5::ThreadContext.

Definition at line 146 of file thread_context.hh.

References thread.

◆ suspend()

void gem5::o3::ThreadContext::suspend ( )
overridevirtual

Set the status to Suspended.

Implements gem5::ThreadContext.

Definition at line 84 of file thread_context.cc.

References cpu, gem5::curTick(), DPRINTF, gem5::ThreadContext::Suspended, thread, and threadId().

◆ takeOverFrom()

void gem5::o3::ThreadContext::takeOverFrom ( gem5::ThreadContext * old_context)
overridevirtual

◆ threadId()

int gem5::o3::ThreadContext::threadId ( ) const
inlineoverridevirtual

Returns this thread's ID number.

Implements gem5::ThreadContext.

Definition at line 134 of file thread_context.hh.

References thread.

Referenced by activate(), halt(), and suspend().

Member Data Documentation

◆ cpu

◆ thread


The documentation for this class was generated from the following files:

Generated on Mon May 26 2025 09:19:34 for gem5 by doxygen 1.13.2