gem5  v22.0.0.1
Public Member Functions | Public Attributes | List of all members
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. More...
 
CheckerCPUgetCheckerCpuPtr () override
 
BaseISAgetIsaPtr () const override
 
InstDecodergetDecoderPtr () override
 
BaseCPU * getCpuPtr () override
 Returns a pointer to this CPU. More...
 
int cpuId () const override
 Reads this CPU's ID. More...
 
uint32_t socketId () const override
 Reads this CPU's Socket ID. More...
 
ContextID contextId () const override
 
void setContextId (ContextID id) override
 
int threadId () const override
 Returns this thread's ID number. More...
 
void setThreadId (int id) override
 
SystemgetSystemPtr () override
 Returns a pointer to the system. More...
 
ProcessgetProcessPtr () override
 Returns a pointer to this thread's process. More...
 
void setProcessPtr (Process *p) override
 
Status status () const override
 Returns this thread's status. More...
 
void setStatus (Status new_status) override
 Sets this thread's status. More...
 
void activate () override
 Set the status to Active. More...
 
void suspend () override
 Set the status to Suspended. More...
 
void halt () override
 Set the status to Halted. More...
 
void takeOverFrom (gem5::ThreadContext *old_context) override
 Takes over execution of a thread from another CPU. More...
 
Tick readLastActivate () override
 Reads the last tick that this thread was activated on. More...
 
Tick readLastSuspend () override
 Reads the last tick that this thread was suspended on. More...
 
void copyArchRegs (gem5::ThreadContext *tc) override
 Copies the architectural registers from another TC into this TC. More...
 
void clearArchRegs () override
 Resets all architectural registers to 0. More...
 
const PCStateBasepcState () const override
 Reads this thread's PC state. More...
 
void pcState (const PCStateBase &val) override
 Sets this thread's PC state. More...
 
void pcStateNoRecord (const PCStateBase &val) override
 
RegVal readMiscRegNoEffect (RegIndex misc_reg) const override
 Reads a miscellaneous register. More...
 
RegVal readMiscReg (RegIndex misc_reg) override
 Reads a misc. More...
 
void setMiscRegNoEffect (RegIndex misc_reg, RegVal val) override
 Sets a misc. More...
 
void setMiscReg (RegIndex misc_reg, RegVal val) override
 Sets a misc. More...
 
RegId flattenRegId (const RegId &regId) const override
 
unsigned readStCondFailures () const override
 Returns the number of consecutive store conditional failures. More...
 
void setStCondFailures (unsigned sc_failures) override
 Sets the number of consecutive store conditional failures. More...
 
void conditionalSquash ()
 check if the cpu is currently in state update mode and squash if not. More...
 
RegVal getRegFlat (const RegId &reg) const override
 Flat register interfaces. More...
 
void getRegFlat (const RegId &reg, void *val) const override
 
void * getWritableRegFlat (const RegId &reg) override
 
void setRegFlat (const RegId &reg, RegVal val) override
 
void setRegFlat (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. More...
 
void quiesceTick (Tick resume)
 Quiesce, suspend, and schedule activate at resume. More...
 
virtual void regStats (const std::string &name)
 
virtual RegVal getReg (const RegId &reg) const
 
virtual void getReg (const RegId &reg, void *val) const
 
virtual void * getWritableReg (const RegId &reg)
 
virtual void setReg (const RegId &reg, RegVal val)
 
virtual void setReg (const RegId &reg, const void *val)
 
RegVal readIntReg (RegIndex reg_idx) const
 
RegVal readFloatReg (RegIndex reg_idx) const
 
TheISA::VecRegContainer readVecReg (const RegId &reg) const
 
TheISA::VecRegContainer & getWritableVecReg (const RegId &reg)
 
RegVal readVecElem (const RegId &reg) const
 
RegVal readCCReg (RegIndex reg_idx) const
 
void setIntReg (RegIndex reg_idx, RegVal val)
 
void setFloatReg (RegIndex reg_idx, RegVal val)
 
void setVecReg (const RegId &reg, const TheISA::VecRegContainer &val)
 
void setVecElem (const RegId &reg, RegVal val)
 
void setCCReg (RegIndex reg_idx, RegVal val)
 
void pcState (Addr addr)
 
virtual int exit ()
 
RegVal readIntRegFlat (RegIndex idx) const
 
void setIntRegFlat (RegIndex idx, RegVal val)
 
RegVal readFloatRegFlat (RegIndex idx) const
 
void setFloatRegFlat (RegIndex idx, RegVal val)
 
TheISA::VecRegContainer readVecRegFlat (RegIndex idx) const
 
TheISA::VecRegContainer & getWritableVecRegFlat (RegIndex idx)
 
void setVecRegFlat (RegIndex idx, const TheISA::VecRegContainer &val)
 
RegVal readVecElemFlat (RegIndex idx) const
 
void setVecElemFlat (RegIndex idx, RegVal val)
 
RegVal readCCRegFlat (RegIndex idx) const
 
void setCCRegFlat (RegIndex idx, RegVal val)
 

Public Attributes

CPUcpu
 Pointer to the CPU. More...
 
ThreadStatethread
 Pointer to the thread state that this TC corrseponds to. More...
 
- 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) More...
 
- 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 68 of file thread_context.hh.

Member Function Documentation

◆ activate()

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

◆ clearArchRegs()

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

Resets all architectural registers to 0.

Implements gem5::ThreadContext.

Definition at line 147 of file thread_context.cc.

References cpu, gem5::o3::CPU::isa, thread, and gem5::ThreadState::threadId().

◆ 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 236 of file thread_context.hh.

References cpu, gem5::o3::ThreadState::noSquashFromTC, gem5::o3::CPU::squashFromTC(), thread, gem5::ThreadState::threadId(), and gem5::o3::ThreadState::trapPending.

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

◆ contextId()

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

Implements gem5::ThreadContext.

Definition at line 130 of file thread_context.hh.

References gem5::ThreadState::contextId(), and 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 138 of file thread_context.cc.

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

◆ cpuId()

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

Reads this CPU's ID.

Implements gem5::ThreadContext.

Definition at line 125 of file thread_context.hh.

References cpu.

◆ descheduleInstCountEvent()

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

◆ flattenRegId()

RegId gem5::o3::ThreadContext::flattenRegId ( const RegId regId) const
overridevirtual

Implements gem5::ThreadContext.

Definition at line 201 of file thread_context.cc.

References cpu, gem5::o3::CPU::isa, thread, and gem5::ThreadState::threadId().

◆ getCheckerCpuPtr()

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

Implements gem5::ThreadContext.

Definition at line 107 of file thread_context.hh.

◆ getCpuPtr()

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

Returns a pointer to this CPU.

Implements gem5::ThreadContext.

Definition at line 122 of file thread_context.hh.

References cpu.

◆ getCurrentInstCount()

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

◆ getDecoderPtr()

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

◆ getHtmCheckpointPtr()

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

Implements gem5::ThreadContext.

Definition at line 233 of file thread_context.cc.

References gem5::o3::ThreadState::htmCheckpoint, and thread.

◆ getIsaPtr()

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

Implements gem5::ThreadContext.

Definition at line 110 of file thread_context.hh.

References cpu, gem5::o3::CPU::isa, thread, and gem5::ThreadState::threadId().

Referenced by copyArchRegs(), and takeOverFrom().

◆ getMMUPtr()

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

Returns a pointer to the MMU.

Implements gem5::ThreadContext.

Definition at line 105 of file thread_context.hh.

References cpu, and gem5::o3::CPU::mmu.

◆ getProcessPtr()

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

Returns a pointer to this thread's process.

Implements gem5::ThreadContext.

Definition at line 142 of file thread_context.hh.

References gem5::ThreadState::getProcessPtr(), and thread.

◆ getRegFlat() [1/2]

RegVal gem5::o3::ThreadContext::getRegFlat ( const RegId reg) const
overridevirtual

Flat register interfaces.

Some architectures have different registers visible in different modes. Such architectures "flatten" a register (see flattenRegId()) to map it into the gem5 register file. This interface provides a flat interface to the underlying register file, which allows for example serialization code to access all registers.

Reimplemented from gem5::ThreadContext.

Definition at line 153 of file thread_context.cc.

References cpu, gem5::o3::CPU::getArchReg(), gem5::X86ISA::reg, thread, and gem5::ThreadState::threadId().

◆ getRegFlat() [2/2]

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

◆ getSystemPtr()

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

Returns a pointer to the system.

Implements gem5::ThreadContext.

Definition at line 139 of file thread_context.hh.

References cpu, and gem5::o3::CPU::system.

◆ getWritableRegFlat()

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

◆ halt()

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

◆ htmAbortTransaction()

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

◆ pcState() [1/2]

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

Reads this thread's PC state.

Implements gem5::ThreadContext.

Definition at line 181 of file thread_context.hh.

References cpu, gem5::o3::CPU::pcState(), thread, and gem5::ThreadState::threadId().

◆ pcState() [2/2]

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

Sets this thread's PC state.

Implements gem5::ThreadContext.

Definition at line 185 of file thread_context.cc.

References conditionalSquash(), cpu, gem5::o3::CPU::pcState(), thread, gem5::ThreadState::threadId(), and gem5::X86ISA::val.

◆ pcStateNoRecord()

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

◆ readLastActivate()

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

Reads the last tick that this thread was activated on.

Implements gem5::ThreadContext.

Definition at line 126 of file thread_context.cc.

References gem5::ThreadState::lastActivate, and thread.

◆ readLastSuspend()

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

Reads the last tick that this thread was suspended on.

Implements gem5::ThreadContext.

Definition at line 132 of file thread_context.cc.

References gem5::ThreadState::lastSuspend, and 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 201 of file thread_context.hh.

References cpu, gem5::o3::CPU::readMiscReg(), thread, and gem5::ThreadState::threadId().

◆ readMiscRegNoEffect()

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

Reads a miscellaneous register.

Implements gem5::ThreadContext.

Definition at line 193 of file thread_context.hh.

References cpu, gem5::o3::CPU::readMiscRegNoEffect(), thread, and gem5::ThreadState::threadId().

◆ readStCondFailures()

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

Returns the number of consecutive store conditional failures.

Implements gem5::ThreadContext.

Definition at line 218 of file thread_context.hh.

References gem5::ThreadState::storeCondFailures, and thread.

◆ remove()

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

◆ schedule()

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

◆ scheduleInstCountEvent()

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

◆ setContextId()

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

Implements gem5::ThreadContext.

Definition at line 132 of file thread_context.hh.

References gem5::ThreadState::setContextId(), and thread.

◆ setHtmCheckpointPtr()

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

Implements gem5::ThreadContext.

Definition at line 239 of file thread_context.cc.

References gem5::o3::ThreadState::htmCheckpoint, and 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 215 of file thread_context.cc.

References conditionalSquash(), cpu, gem5::o3::CPU::setMiscReg(), thread, gem5::ThreadState::threadId(), and gem5::X86ISA::val.

◆ setMiscRegNoEffect()

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

◆ setProcessPtr()

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

Implements gem5::ThreadContext.

Definition at line 144 of file thread_context.hh.

References gem5::VegaISA::p, gem5::ThreadState::setProcessPtr(), and thread.

◆ setRegFlat() [1/2]

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

◆ setRegFlat() [2/2]

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

◆ setStatus()

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

Sets this thread's status.

Implements gem5::ThreadContext.

Definition at line 151 of file thread_context.hh.

References gem5::ThreadState::setStatus(), and 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 225 of file thread_context.hh.

References gem5::ThreadState::storeCondFailures, and thread.

◆ setThreadId()

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

Implements gem5::ThreadContext.

Definition at line 136 of file thread_context.hh.

References gem5::ThreadState::setThreadId(), and thread.

◆ socketId()

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

Reads this CPU's Socket ID.

Implements gem5::ThreadContext.

Definition at line 128 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 147 of file thread_context.hh.

References gem5::ThreadState::status(), and thread.

◆ suspend()

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

◆ 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 135 of file thread_context.hh.

References thread, and gem5::ThreadState::threadId().

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

Member Data Documentation

◆ cpu

CPU* gem5::o3::ThreadContext::cpu

◆ thread

ThreadState* gem5::o3::ThreadContext::thread

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

Generated on Sat Jun 18 2022 08:14:28 for gem5 by doxygen 1.8.17