42 #ifndef __DEV_ARM_GENERIC_TIMER_HH__ 43 #define __DEV_ARM_GENERIC_TIMER_HH__ 58 class GenericTimerParams;
59 class GenericTimerMemParams;
129 const std::string _name;
149 void updateCounter();
152 void counterLimitReached();
164 std::string
name()
const {
return _name; }
169 void setCompareValue(uint64_t
val);
174 void setTimerValue(uint32_t val);
178 void setControl(uint32_t val);
180 uint64_t
offset()
const {
return _offset; }
181 void setOffset(uint64_t val);
184 uint64_t
value()
const;
192 void drainResume()
override;
210 :
ArchTimer(name, parent, sysctr, interrupt), system(system) {}
224 const GenericTimerParams * params()
const;
232 void setMiscReg(
int misc_reg,
unsigned cpu,
RegVal val);
233 RegVal readMiscReg(
int misc_reg,
unsigned cpu);
240 : irqPhysS(_irqPhysS),
241 irqPhysNS(_irqPhysNS),
244 physS(
csprintf(
"%s.phys_s_timer%d", parent.
name(), cpu),
245 system, parent, parent.systemCounter,
250 system, parent, parent.systemCounter,
253 system, parent, parent.systemCounter,
256 system, parent, parent.systemCounter,
276 void createTimers(
unsigned cpus);
293 : parent(_parent), cpu(_cpu) {}
295 void setMiscReg(
int misc_reg,
RegVal val)
override;
296 RegVal readMiscReg(
int misc_reg)
override;
317 uint64_t ctrlRead(
Addr addr,
size_t size)
const;
318 void ctrlWrite(
Addr addr,
size_t size, uint64_t
value);
320 uint64_t timerRead(
Addr addr,
size_t size)
const;
321 void timerWrite(
Addr addr,
size_t size, uint64_t value);
324 static const Addr CTRL_CNTFRQ = 0x000;
325 static const Addr CTRL_CNTNSAR = 0x004;
326 static const Addr CTRL_CNTTIDR = 0x008;
327 static const Addr CTRL_CNTACR_BASE = 0x040;
328 static const Addr CTRL_CNTVOFF_LO_BASE = 0x080;
329 static const Addr CTRL_CNTVOFF_HI_BASE = 0x084;
331 static const Addr TIMER_CNTPCT_LO = 0x000;
332 static const Addr TIMER_CNTPCT_HI = 0x004;
333 static const Addr TIMER_CNTVCT_LO = 0x008;
334 static const Addr TIMER_CNTVCT_HI = 0x00C;
335 static const Addr TIMER_CNTFRQ = 0x010;
336 static const Addr TIMER_CNTEL0ACR = 0x014;
337 static const Addr TIMER_CNTVOFF_LO = 0x018;
338 static const Addr TIMER_CNTVOFF_HI = 0x01C;
339 static const Addr TIMER_CNTP_CVAL_LO = 0x020;
340 static const Addr TIMER_CNTP_CVAL_HI = 0x024;
341 static const Addr TIMER_CNTP_TVAL = 0x028;
342 static const Addr TIMER_CNTP_CTL = 0x02C;
343 static const Addr TIMER_CNTV_CVAL_LO = 0x030;
344 static const Addr TIMER_CNTV_CVAL_HI = 0x034;
345 static const Addr TIMER_CNTV_TVAL = 0x038;
346 static const Addr TIMER_CNTV_CTL = 0x03C;
360 #endif // __DEV_ARM_GENERIC_TIMER_HH__
EventFunctionWrapper _counterLimitReachedEvent
void setFreq(uint32_t freq)
Sets the counter frequency.
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
uint64_t _counterLimit
Programmed limit value for the upcounter ({CNTP/CNTHP/CNTV}_CVAL).
std::vector< uint32_t > _freqTable
Frequency modes table with all possible frequencies for the counter.
const std::string & name()
EndBitUnion(UserDescFlags) struct UserDesc32
ArmInterruptPin const * irqHyp
DrainState
Object drain/handover states.
Per-CPU architected timer.
CoreTimers(GenericTimer &parent, ArmSystem &system, unsigned cpu, ArmInterruptPin *_irqPhysS, ArmInterruptPin *_irqPhysNS, ArmInterruptPin *_irqVirt, ArmInterruptPin *_irqHyp)
uint32_t _regCntkctl
Kernel event stream control register.
SystemCounter(std::vector< uint32_t > &freqs)
Base class for devices that use the MiscReg interfaces.
uint32_t freq() const
Returns the counter frequency.
const AddrRangeList addrRanges
uint64_t value() const
Returns the current value of the physical counter.
ArmSystem & system
ARM system containing this timer.
ArchTimerCtrl _control
Value of the control register ({CNTP/CNTHP/CNTV}_CTL).
Tick _resetTick
Tick when the counter was reset.
Tick _period
Cached copy of the counter period (inverse of the frequency).
Interface for objects that might require draining before checkpointing.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Tick curTick()
The current simulated tick.
std::string csprintf(const char *format, const Args &...args)
bool scheduleEvents() override
const AddrRange ctrlRange
uint64_t Tick
Tick count type.
SystemCounter systemCounter
System counter.
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
ArmInterruptPin const * irqPhysS
uint32_t getKernelControl()
static constexpr size_t MAX_FREQ_ENTRIES
Maximum architectural number of frequency table entries.
uint32_t _regCnthctl
Hypervisor event stream control register.
void setKernelControl(uint32_t val)
uint32_t timerValue() const
Returns the TimerValue view of the timer.
This device is the base class which all devices senstive to an address range inherit from...
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual bool scheduleEvents()
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Basic support for object serialization.
ArmInterruptPin const * irqPhysNS
bool validKvmEnvironment() const
Verify gem5 configuration will support KVM emulation.
std::string name() const
Returns the timer name.
Base class for ARM GIC implementations.
ArmInterruptPin const * irqVirt
std::ostream CheckpointOut
void serialize(CheckpointOut &cp) const override
Serialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t compareValue() const
Returns the CompareValue view of the timer.
SystemCounter systemCounter
System counter.
void setHypControl(uint32_t val)
ArmInterruptPin *const _interrupt
GenericTimerISA(GenericTimer &_parent, unsigned _cpu)
std::vector< std::unique_ptr< CoreTimers > > timers
Per-CPU physical architected timers.
const AddrRange timerRange
BitUnion32(UserDescFlags) Bitfield< 0 > seg_32bit
SystemCounter & _systemCounter
ArchTimerKvm(const std::string &name, ArmSystem &system, SimObject &parent, SystemCounter &sysctr, ArmInterruptPin *interrupt)
uint32_t control() const
Sets the control register.
Generic representation of an Arm interrupt pin.
Tick period() const
Returns the counter period.
Abstract superclass for simulation objects.
uint32_t _freq
Counter frequency (as specified by CNTFRQ).
uint64_t _offset
Offset relative to the physical timer (CNTVOFF)
EndBitUnion(ArchTimerCtrl) const std SimObject & _parent
Name of this timer.