gem5  v22.1.0.0
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
 
BaseCPUgetCpuPtr () 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...
 
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 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. More...
 
void quiesceTick (Tick resume)
 Quiesce, suspend, and schedule activate at resume. More...
 
virtual void regStats (const std::string &name)
 
void pcState (Addr addr)
 
virtual int exit ()
 

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 67 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 145 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 233 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 setReg().

◆ contextId()

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

Implements gem5::ThreadContext.

Definition at line 129 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 136 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 124 of file thread_context.hh.

References cpu, and gem5::BaseCPU::cpuId().

◆ descheduleInstCountEvent()

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

◆ 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

◆ getDecoderPtr()

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

◆ getHtmCheckpointPtr()

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

Implements gem5::ThreadContext.

Definition at line 225 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 109 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 104 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 141 of file thread_context.hh.

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

◆ getReg() [1/2]

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

◆ getReg() [2/2]

void gem5::o3::ThreadContext::getReg ( 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 138 of file thread_context.hh.

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

◆ getWritableReg()

void * gem5::o3::ThreadContext::getWritableReg ( 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 180 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 183 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 124 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 130 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 200 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 192 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 215 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 131 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 231 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 207 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 143 of file thread_context.hh.

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

◆ setReg() [1/2]

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

◆ setReg() [2/2]

void gem5::o3::ThreadContext::setReg ( 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 150 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 222 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 135 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 127 of file thread_context.hh.

References cpu, and gem5::BaseCPU::socketId().

◆ 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 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 134 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 Wed Dec 21 2022 10:24:18 for gem5 by doxygen 1.9.1