38#ifndef __ARCH_ARM_PMU_HH__
39#define __ARCH_ARM_PMU_HH__
49#include "debug/PMUVerbose.hh"
99 PMU(
const ArmPMUParams &
p);
186 typedef
unsigned int CounterId;
354 panic_if(!
object,
"malformed probe-point"
355 " definition with name %s\n",
name);
411 std::shared_ptr<PMUEvent>
getEvent(uint64_t eventId);
417 const bool is_64_bit)
432 uint64_t
add(uint64_t delta);
446 void attach(
const std::shared_ptr<PMUEvent> &
event);
499 template <
typename ...Args>
502 std::string userString =
csprintf(mainString, args...);
504 warn(
"[counterId = %d, eventId = %d, sourceEvent = 0x%x] %s",
634 std::map<EventTypeId, std::shared_ptr<PMUEvent>>
eventMap;
Base class for devices that use the MiscReg interfaces.
void enable() override
Enable the current event.
void disable() override
Disable the current event.
void write(uint64_t val)
write on the sw increment register inducing an increment of the counters with this event selected acc...
Model of an ARM PMU version 3.
BitUnion32(PMCR_t) Bitfield< 0 > e
void regProbeListeners() override
Register probe listeners for this object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void setControlReg(PMCR_t val)
PMCR write handling.
void raiseInterrupt()
Deliver a PMU interrupt to the GIC.
PMCR_t reg_pmcr_conf
Constant (configuration-dependent) part of the PMCR.
RegVal readMiscReg(int misc_reg) override
Read a register within the PMU.
RegVal reg_pmcnten
Performance Monitor Count Enable Register.
std::shared_ptr< PMUEvent > getEvent(uint64_t eventId)
Obtain the event of a given id.
void clearInterrupt()
Clear a PMU interrupt.
const uint64_t cycleCounterEventId
The id of the counter hardwired to the cpu cycle counter.
uint64_t maximumCounterCount
The number of regular event counters.
static const RegVal reg_pmcr_wr_mask
PMCR write mask when accessed from the guest.
bool isFiltered(const CounterState &ctr) const
Check if a counter's settings allow it to be counted.
PMEVTYPER_t getCounterTypeRegister(CounterId id) const
Get the type and filter settings of a counter (PMEVTYPER)
unsigned clock_remainder
Remainder part when the clock counter is divided by 64.
void updateAllCounters()
Call updateCounter() for each counter in the PMU if the counter's state has changed.
void resetEventCounts()
Reset all event counters excluding the cycle counter to zero.
void registerEvent(uint32_t id)
void setOverflowStatus(RegVal new_val)
Used for writing the Overflow Flag Status Register (SET/CLR)
PMSELR_t reg_pmselr
Performance Monitor Selection Register.
std::map< EventTypeId, std::shared_ptr< PMUEvent > > eventMap
List of event types supported by this PMU.
static const CounterId PMCCNTR
Cycle Count Register Number.
void setThreadContext(ThreadContext *tc) override
std::vector< CounterState > counters
State of all general-purpose counters supported by PMU.
void setCounterTypeRegister(CounterId id, PMEVTYPER_t type)
Set the type and filter settings of a performance counter (PMEVTYPER)
void drainResume() override
Resume execution after a successful drain.
PMU(const ArmPMUParams &p)
RegVal readMiscRegInt(int misc_reg)
void setMiscReg(int misc_reg, RegVal val) override
Set a register within the PMU.
CounterState cycleCounter
State of the cycle counter.
uint64_t reg_pmceid0
Performance counter ID register.
bool isValidCounter(CounterId id) const
Is this a valid counter ID?
PMCR_t reg_pmcr
Performance Monitor Control Register.
Bitfield< 23, 16 > idcode
RegVal reg_pmovsr
Performance Monitor Overflow Status Register.
ArmInterruptPin * interrupt
Performance monitor interrupt number.
void addSoftwareIncrementEvent(unsigned int id)
CounterState & getCounter(CounterId id)
Return the state of a counter.
bool use64bitCounters
Determine whether to use 64-bit or 32-bit counters.
std::shared_ptr< SWIncrementEvent > swIncrementEvent
The event that implements the software increment.
uint64_t getCounterValue(CounterId id) const
Get the value of a performance counter.
bool exitOnPMUInterrupt
Exit simloop on PMU interrupt.
unsigned int EventTypeId
Event type ID.
void setCounterValue(CounterId id, uint64_t val)
Set the value of a performance counter.
EndBitUnion(PMCR_t) BitUnion32(PMSELR_t) Bitfield< 4
RegVal reg_pminten
Performance Monitor Interrupt Enable Register.
void updateCounter(CounterState &ctr)
Depending on counter configuration, add or remove the probes driving the counter.
void serialize(CheckpointOut &cp) const override
Serialize an object.
const CounterState & getCounter(CounterId id) const
Return the state of a counter.
const bool exitOnPMUControl
Exit simloop on PMU reset or disable.
void addEventProbe(unsigned int id, SimObject *obj, const char *name)
Generic representation of an Arm interrupt pin.
virtual std::string name() const
ProbeListenerArgBase is used to define the base interface to a ProbeListenerArg (i....
Basic support for object serialization.
Abstract superclass for simulation objects.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
ProbeManager * getProbeManager()
Get the probe manager for this object.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::ostream CheckpointOut
std::string csprintf(const char *format, const Args &...args)
State of a counter within the PMU.
bool resetValue
Flag keeping track if the counter has been reset.
void attach(const std::shared_ptr< PMUEvent > &event)
Attach this counter to an event.
PMEVTYPER_t filter
Filtering settings (evtCount is unused)
uint64_t value
Current value of the counter.
bool overflow64
Is this a 64-bit counter?
uint64_t counterId
id of the counter instance
void detach()
Detach the counter from its event.
EventTypeId eventId
Counter event ID.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
CounterState(PMU &pmuReference, uint64_t counter_id, const bool is_64_bit)
uint64_t getCounterId() const
Obtain the counter id.
uint64_t getValue() const
rReturn the counter value
std::shared_ptr< PMUEvent > sourceEvent
PmuEvent currently in use (if any)
bool enabled
Is the counter enabled?
uint64_t add(uint64_t delta)
Add an event count to the counter and check for overflow.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void debugCounter(const char *mainString, Args &...args) const
void setValue(uint64_t val)
overwrite the value of the counter
Event definition base class.
void attachEvent(PMU::CounterState *user)
attach this event to a given counter
virtual void enable()=0
Enable the current event.
virtual void disable()=0
Disable the current event.
std::set< PMU::CounterState * > userCounters
set of counters using this event
virtual void updateAttachedCounters()
Method called immediately before a counter access in order for the associated event to update its sta...
void detachEvent(PMU::CounterState *user)
detach this event from a given counter
virtual void increment(const uint64_t val)
notify an event increment of val units, all the attached counters' value is incremented by val units.
void notify(const uint64_t &val)
RegularEvent * parentEvent
RegularProbe(RegularEvent *parent, SimObject *obj, std::string name)
std::set< EventTypeEntry > microArchitectureEventSet
The set of events driving the event value.
void enable() override
Enable the current event.
std::vector< std::unique_ptr< RegularProbe > > attachedProbePointList
Set of probe listeners tapping onto each of the input micro-arch events which compose this pmu event.
void disable() override
Disable the current event.
void addMicroarchitectureProbe(SimObject *object, std::string name)
std::pair< SimObject *, std::string > EventTypeEntry