46 #ifndef __CPU_BASE_HH__ 47 #define __CPU_BASE_HH__ 53 #include "config/the_isa.hh" 54 #if THE_ISA == NULL_ISA 58 #include "arch/isa_traits.hh" 59 #include "arch/microcode_rom.hh" 68 #include "debug/Mwait.hh" 106 virtual const char *description()
const;
161 virtual Port &getDataPort() = 0;
169 auto port =
dynamic_cast<MasterPort *
>(&getDataPort());
171 return [port](
PacketPtr pkt)->
void { port->sendFunctional(pkt); };
180 virtual Port &getInstPort() = 0;
183 int cpuId()
const {
return _cpuId; }
203 Port &getPort(
const std::string &if_name,
207 uint32_t
taskId()
const {
return _taskId; }
212 void setPid(uint32_t pid) { _pid = pid; }
228 if (interrupts.empty())
231 assert(interrupts.size() > tid);
232 return interrupts[tid];
235 virtual void wakeup(
ThreadID tid) = 0;
240 interrupts[tid]->post(int_num, index);
248 interrupts[tid]->clear(int_num, index);
254 interrupts[tid]->clearAll();
263 void processProfileEvent();
276 static const uint32_t invldPid = std::numeric_limits<uint32_t>::max();
285 virtual void activateContext(
ThreadID thread_num);
289 virtual void suspendContext(
ThreadID thread_num);
292 virtual void haltContext(
ThreadID thread_num);
302 return static_cast<unsigned>(threadContexts.size());
307 {
return static_cast<ThreadID>(cid - threadContexts[0]->contextId()); }
312 {
return reinterpret_cast<const Params *
>(_params); }
313 BaseCPU(Params *params,
bool is_checker =
false);
316 void init()
override;
317 void startup()
override;
318 void regStats()
override;
320 void regProbePoints()
override;
322 void registerThreadContexts();
326 void deschedulePowerGatingEvent();
327 void schedulePowerGatingEvent();
336 virtual void switchOut();
433 virtual Counter totalInsts()
const = 0;
435 virtual Counter totalOps()
const = 0;
459 uint64_t getCurrentInstCount(
ThreadID tid);
534 uint32_t delta = curCycle() - previousCycle;
536 if (previousState == CPU_STATE_ON) {
537 ppActiveCycles->notify(delta);
542 case CPU_STATE_WAKEUP:
543 ppSleeping->
notify(
false);
545 case CPU_STATE_SLEEP:
552 ppAllCycles->notify(delta);
554 previousCycle = curCycle();
555 previousState = state;
565 void enableFunctionTrace();
566 void traceFunctionsInternal(
Addr pc);
574 if (functionTracingEnabled)
575 traceFunctionsInternal(pc);
583 int size = cpuList.size();
584 for (
int i = 0;
i < size; ++
i)
585 total += cpuList[
i]->totalInsts();
594 int size = cpuList.size();
595 for (
int i = 0;
i < size; ++
i)
596 total += cpuList[
i]->totalOps();
616 assert(tid < numThreads);
617 return &addressMonitor[tid];
620 bool waitForRemoteGDB()
const;
626 void enterPwrGating();
633 #endif // THE_ISA == NULL_ISA 635 #endif // __CPU_BASE_HH__ A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
uint32_t taskId() const
Get cpu task id.
virtual void unserializeThread(CheckpointIn &cp, ThreadID tid)
Unserialize one thread.
MasterID _dataMasterId
data side request id that must be placed in all requests
Ports are used to interface objects to each other.
Cycles is a wrapper class for representing cycle counts, i.e.
AddressMonitor * getCpuAddrMonitor(ThreadID tid)
ProbePoints::PMUUPtr ppRetiredStores
Retired store instructions.
const std::string & name()
const PortID InvalidPortID
Trace::InstTracer * getTracer()
Provide access to the tracer pointer.
void traceFunctions(Addr pc)
const unsigned int _cacheLineSize
Cache the cache line size that we get from the system.
Tick instCnt
Instruction count used for SPARC misc register.
std::vector< BaseInterrupts * > interrupts
void takeOverFrom(ThreadContext &ntc, ThreadContext &otc)
Copy state between thread contexts in preparation for CPU handover.
void notify(const Arg &arg)
called at the ProbePoint call site, passes arg to each listener.
Stats::Scalar numWorkItemsCompleted
EventFunctionWrapper enterPwrGatingEvent
MasterID _instMasterId
instruction side request id that must be placed in all requests
void clearInterrupt(ThreadID tid, int int_num, int index)
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
bool switchedOut() const
Determine if the CPU is switched out.
bool _switchedOut
Is the CPU switched out or active?
void clearInterrupts(ThreadID tid)
unsigned numContexts()
Get the number of thread contexts available.
int cpuId() const
Reads this CPU's ID.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
static Counter numSimulatedInsts()
static Counter numSimulatedOps()
const uint32_t _socketId
Each cpu will have a socket ID that corresponds to its physical location in the system.
virtual void serializeThread(CheckpointOut &cp, ThreadID tid) const
Serialize a single thread.
void taskId(uint32_t id)
Set cpu task id.
ProbePoints::PMUUPtr ppActiveCycles
CPU cycle counter, only counts if any thread contexts is active.
std::vector< ThreadContext * > threadContexts
std::unique_ptr< PMU > PMUUPtr
MasterID dataMasterId() const
Reads this CPU's unique data requestor ID.
uint64_t Tick
Tick count type.
static int numSimulatedCPUs()
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
ProbePointArg< bool > * ppSleeping
ProbePoint that signals transitions of threadContexts sets.
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
EventFunctionWrapper * profileEvent
bool checkInterrupts(ThreadContext *tc) const
virtual PortProxy::SendFunctionalFunc getSendFunctional()
Returns a sendFunctional delegate for use with port proxies.
TheISA::MicrocodeRom microcodeRom
ClockedObject declaration and implementation.
bool doMonitor(PacketPtr pkt)
ProbePoints::PMUUPtr ppRetiredInstsPC
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Cycles syscallRetryLatency
std::vector< AddressMonitor > addressMonitor
bool functionTracingEnabled
virtual void verifyMemoryMode() const
Verify that the system is in a memory mode supported by the CPU.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint32_t _pid
The current OS process ID that is executing on this processor.
int64_t Counter
Statistics counter type.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
const FlagsType total
Print the total.
void repeatEvent(bool repeat)
ProbePoints::PMUUPtr ppAllCycles
CPU cycle counter even if any thread Context is suspended.
const bool powerGatingOnIdle
int16_t ThreadID
Thread index/ID type.
unsigned int cacheLineSize() const
Get the cache line size of the system.
static std::vector< BaseCPU * > cpuList
Static global cpu list.
std::function< void(PacketPtr pkt)> SendFunctionalFunc
std::ostream CheckpointOut
ProbePoints::PMUUPtr ppRetiredBranches
Retired branches (any type)
virtual int threadId() const =0
uint32_t socketId() const
Reads this CPU's Socket ID.
ThreadID contextToThread(ContextID cid)
Convert ContextID to threadID.
virtual ThreadContext * getContext(int tn)
Given a thread num get tho thread context for it.
ProbePoints::PMUUPtr ppRetiredLoads
Retired load instructions.
BaseInterrupts * getInterruptController(ThreadID tid)
uint32_t _taskId
An intrenal representation of a task identifier within gem5.
Trace::InstTracer * tracer
void unserialize(ThreadContext &tc, CheckpointIn &cp)
const Cycles pwrGatingLatency
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
void setPid(uint32_t pid)
const Params * params() const
void postInterrupt(ThreadID tid, int int_num, int index)
ProbePoints::PMUUPtr ppRetiredInsts
Instruction commit probe point.
int ContextID
Globally unique thread context ID.
std::ostream * functionTraceStream
const FlagsType init
This Stat is Initialized.
MasterID instMasterId() const
Reads this CPU's unique instruction requestor ID.
Stats::Scalar numWorkItemsStarted
Addr currentFunctionStart