Go to the documentation of this file.
38 #ifndef __DEV_ARM_GENERIC_TIMER_HH__
39 #define __DEV_ARM_GENERIC_TIMER_HH__
69 struct SystemCounterParams;
70 struct GenericTimerParams;
71 struct GenericTimerFrameParams;
72 struct GenericTimerMemParams;
81 virtual void notify(
void) = 0;
191 const std::string _name;
226 std::string
name()
const {
return _name; }
246 uint64_t
value()
const;
251 void notify(
void)
override;
352 return ret_val + incr_val;
363 void notify(
void)
override;
491 AccessBits accessBits;
500 AccessBitsEl0 accessBitsEl0;
544 static const
Addr COUNTER_CTRL_CNTCR = 0x00;
592 #endif // __DEV_ARM_GENERIC_TIMER_HH__
static const Addr COUNTER_STATUS_CNTCV_LO
void unserialize(CheckpointIn &cp) override
Unserialize an object.
CoreTimers(GenericTimer &_parent, ArmSystem &system, unsigned cpu, ArmInterruptPin *_irqPhysS, ArmInterruptPin *_irqPhysNS, ArmInterruptPin *_irqVirt, ArmInterruptPin *_irqHyp)
void counterCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec)
Tick period() const
Returns the counter period.
GenericTimer & parent
Generic Timer parent reference.
void notifyListeners(void) const
Notifies counting speed changes to listeners.
const ArmInterruptPin * irqPhysNS
const AddrRange timerRange
void virtEventStreamCallback()
bool hasNonSecureAccess() const
Indicates if non-secure accesses are allowed to this frame.
GenericTimerMem(const GenericTimerMemParams &p)
ArchTimerCtrl _control
Value of the control register ({CNTP/CNTHP/CNTV}_CTL).
This device is the base class which all devices senstive to an address range inherit from.
uint64_t _increment
Value increment in each counter cycle.
static const Addr TIMER_CNTV_CVAL_LO
GenericTimer(const Params &p)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static const Addr TIMER_CNTP_CVAL_LO
EndBitUnion(AccessBits) AccessBits accessBits
static const Addr TIMER_CTRL_CNTTIDR
std::string name() const
Returns the timer name.
void freqUpdateCallback()
Callback for the frequency update.
static const Addr TIMER_CNTVOFF_LO
GenericTimerISA(GenericTimer &_parent, unsigned _cpu)
static const Addr COUNTER_CTRL_CNTCV_LO
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
const AddrRange counterStatusRange
ArchTimer(const std::string &name, SimObject &parent, SystemCounter &sysctr, ArmInterruptPin *interrupt)
static const Addr COUNTER_CTRL_CNTFID
static const Addr TIMER_CNTP_TVAL
BitUnion16(AccessBitsEl0) Bitfield< 9 > pten
static const Addr TIMER_CNTVOFF_HI
virtual bool scheduleEvents()
static const Addr TIMER_CNTV_CVAL_HI
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
const ArmInterruptPin * irqPhysS
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t counterCtrlRead(Addr addr, size_t size, bool is_sec) const
CNTControlBase (System counter control frame)
void updateCounter()
Timer settings or the offset has changed, re-evaluate trigger condition and raise interrupt if necess...
uint64_t counterStatusRead(Addr addr, size_t size) const
CNTReadBase (System counter status frame)
void setOffset(uint64_t val)
bool _enabled
Indicates if the counter is enabled.
void timerWrite(Addr addr, size_t size, uint64_t data, bool is_sec, bool to_el0)
constexpr T mbits(T val, unsigned first, unsigned last)
Mask off the given bits in place like bits() but without shifting.
static const Addr TIMER_CNTPCT_HI
BitUnion32(ArchTimerCtrl) Bitfield< 0 > enable
Control register.
void registerListener(SystemCounterListener *listener)
Called from System Counter Listeners to register.
void serialize(CheckpointOut &cp) const override
Serialize an object.
Tick _period
Cached copy of the counter period (inverse of the frequency).
AddrRangeList addrRanges
All MMIO ranges GenericTimerFrame responds to.
void setVirtOffset(uint64_t new_offset)
Sets the virtual offset for this frame's virtual timer after a write to CNTVOFF.
static const Addr TIMER_CNTVCT_LO
static const Addr TIMER_CTRL_CNTVOFF_HI
uint32_t control() const
Sets the control register.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const Addr COUNTER_CTRL_CNTSR
static const Addr TIMER_CNTPCT_LO
static const Addr TIMER_CNTVCT_HI
const ArmInterruptPin * irqHyp
BitUnion8(AccessBits) Bitfield< 5 > rwpt
Reports access properties of the CNTBase register frame elements.
void setControl(uint32_t val)
const AddrRangeList addrRanges
All MMIO ranges GenericTimerMem responds to.
Basic support for object serialization.
DrainState
Object drain/handover states.
static const Addr COUNTER_STATUS_CNTCV_HI
const AddrRange counterCtrlRange
SystemCounter & systemCounter
System counter reference.
ArmISA::CNTHCTL cnthctl
Hypervisor control register.
uint64_t eventTargetValue(uint64_t val) const
void serialize(CheckpointOut &cp) const override
Serialize an object.
Tick whenValue(uint64_t target_val)
Returns the tick at which a certain counter value is reached.
uint32_t _freq
Counter frequency (as specified by CNTFRQ).
CoreTimers & getTimers(int cpu_id)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
static const Addr TIMER_CNTEL0ACR
Abstract class for elements whose events depend on the counting speed of the System Counter.
size_t activeFreqEntry() const
Returns the currently active frequency table entry.
GenericTimerFrame(const GenericTimerFrameParams &p)
bool hasReadableVoff() const
Indicates if CNTVOFF is readable for this frame.
EventFunctionWrapper event
SystemCounter & _systemCounter
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
RegVal readMiscReg(int misc_reg) override
Read a system register belonging to this device.
EndBitUnion(PciCommandRegister) union PCIConfig
void notify(void) override
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
uint32_t freq() const
Returns the counter frequency.
void counterStatusWrite(Addr addr, size_t size, uint64_t data)
size_t _activeFreqEntry
Currently selected entry in the table, its contents should match _freq.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
uint64_t Tick
Tick count type.
static const Addr TIMER_CNTV_CTL
static const Addr TIMER_CNTP_CTL
std::vector< GenericTimerFrame * > frames
Timer frame references.
ThreadContext * threadContext
Thread (HW) context associated to this PE implementation.
bool hasEl0View() const
Indicates if this frame implements a second EL0 view.
void counterLimitReached()
Called when the upcounter reaches the programmed value.
Tick whenValue(uint64_t target_val)
void setValue(uint64_t new_value)
Sets the value explicitly from writes to CNTCR.CNTCV.
uint64_t increment() const
Returns the value increment.
static bool validateAccessPerm(ArmSystem &sys, bool is_sec)
Validates an MMIO access permissions.
EndBitUnion(ArchTimerCtrl) const std SimObject & _parent
Name of this timer.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Abstract superclass for simulation objects.
RegVal readMiscReg(int misc_reg, unsigned cpu)
void updateTick(void)
Updates the update tick, normalizes to the lower cycle start tick.
EventFunctionWrapper _counterLimitReachedEvent
static const Addr TIMER_CNTV_TVAL
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
static void validateFrameRange(const AddrRange &range)
Validates a Generic Timer register frame address range.
ArmSystem & system
ARM system containing this timer.
bool nonSecureAccess
Reports whether non-secure accesses are allowed to this frame.
const AddrRange timerCtrlRange
void setAccessBits(uint8_t data)
Updates the access bits after a write to CNTCTLBase.CNTACR.
uint64_t _offset
Offset relative to the physical timer (CNTVOFF)
static const Addr COUNTER_CTRL_CNTSCR
void setTimerValue(uint32_t val)
Sets the TimerValue view of the timer.
static const Addr TIMER_CTRL_CNTNSAR
std::vector< uint32_t > & freqTable()
Returns a reference to the frequency modes table.
uint32_t cnttidr
ID register for reporting features of implemented timer frames.
uint64_t timerRead(Addr addr, size_t size, bool is_sec, bool to_el0) const
CNTBase/CNTEL0Base (Memory-mapped timer frame)
void setNonSecureAccess()
Allows non-secure accesses after an enabling write to CNTCTLBase.CNTNSAR.
std::vector< SystemCounterListener * > _listeners
Listeners to changes in counting speed.
void timerCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec)
uint64_t value() const
Returns the value of the counter which this timer relies on.
ArmISA::CNTKCTL cntkctl
Kernel control register.
ArchTimer physTimer
Physical and virtual timers.
std::vector< uint32_t > _freqTable
Frequency modes table with all possible frequencies for the counter.
uint64_t value()
Updates and returns the counter value.
void updateValue(void)
Updates the counter value.
uint64_t _value
Counter value (as specified in CNTCV).
static constexpr size_t MAX_FREQ_ENTRIES
Maximum architectural number of frequency table entries.
SystemCounter(const SystemCounterParams &p)
static const Addr TIMER_CTRL_CNTFRQ
SystemCounter & systemCounter
System counter reference.
Overload hash function for BasicBlockRange type.
static const Addr COUNTER_CTRL_CNTID
void setMiscReg(int misc_reg, unsigned cpu, RegVal val)
ArmInterruptPin *const _interrupt
SystemCounter & systemCounter
System counter reference.
static void validateCounterRef(SystemCounter *sys_cnt)
Validates a System Counter reference.
ArchTimerKvm(const std::string &name, ArmSystem &system, SimObject &parent, SystemCounter &sysctr, ArmInterruptPin *interrupt)
bool enabled() const
Indicates if the counter is enabled.
static const Addr TIMER_CNTFRQ
uint32_t cntfrq
System counter frequency as visible from this core.
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Interface for objects that might require draining before checkpointing.
void disable()
Disables the counter after a CNTCR.EN == 0.
EventFunctionWrapper _freqUpdateEvent
Frequency update event handling.
const ArmInterruptPin * irqVirt
void freqUpdateSchedule(size_t new_freq_entry)
Schedules a counter frequency update after a CNTCR.FCREQ == 1 This complies with frequency transition...
bool validKvmEnvironment() const
Verify gem5 configuration will support KVM emulation.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void eventStreamCallback() const
EndBitUnion(CNTCR) BitUnion32(CNTSR) Bitfield< 31
uint32_t timerValue() const
Returns the TimerValue view of the timer.
Generic representation of an Arm interrupt pin.
std::ostream CheckpointOut
static constexpr size_t MAX_TIMER_FRAMES
Maximum architectural number of memory-mapped timer frames.
bool scheduleEvents() override
static const Addr TIMER_CNTP_CVAL_HI
static const Addr TIMER_CTRL_CNTACR
Per-CPU architected timer.
void schedNextEvent(EventStream &ev_stream, ArchTimer &timer)
uint64_t _counterLimit
Programmed limit value for the upcounter ({CNTP/CNTHP/CNTV}_CVAL).
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void notify(void) override
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
static const Addr TIMER_CTRL_CNTVOFF_LO
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
virtual void notify(void)=0
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
BitUnion32(CNTCR) Bitfield< 17
void setCompareValue(uint64_t val)
Sets the CompareValue view of the timer.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void drainResume() override
Resume execution after a successful drain.
void setMiscReg(int misc_reg, RegVal val) override
Write to a system register belonging to this device.
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::vector< std::unique_ptr< CoreTimers > > timers
Per-CPU physical architected timers.
void handleStream(CoreTimers::EventStream *ev_stream, ArchTimer *timer, RegVal old_cnt_ctl, RegVal cnt_ctl)
bool hasVirtualTimer() const
Indicates if this frame implements a virtual timer.
void createTimers(unsigned cpus)
static const Addr COUNTER_CTRL_CNTCV_HI
void physEventStreamCallback()
uint64_t compareValue() const
Returns the CompareValue view of the timer.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void enable()
Enables the counter after a CNTCR.EN == 1.
uint64_t timerCtrlRead(Addr addr, size_t size, bool is_sec) const
CNTCTLBase (Memory-mapped timer global control frame)
uint8_t getAccessBits() const
Returns the access bits for this frame.
Base class for devices that use the MiscReg interfaces.
Tick _updateTick
Counter cycle start Tick when the counter status affecting its value has been updated.
uint64_t getVirtOffset() const
Returns the virtual offset for this frame if a virtual timer is implemented.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Generated on Tue Sep 21 2021 12:25:10 for gem5 by doxygen 1.8.17