45 #include "debug/Timer.hh" 48 #include "params/GenericTimer.hh" 49 #include "params/GenericTimerFrame.hh" 50 #include "params/GenericTimerMem.hh" 51 #include "params/SystemCounter.hh" 65 "frequency not provided\n");
69 "SystemCounter::SystemCounter: Architecture states a maximum of 1004 " 70 "frequency table entries, limit surpassed\n");
79 fatal_if(!sys_cnt,
"SystemCounter::validateCounterRef: No valid system " 80 "counter, can't instantiate system timers\n");
86 DPRINTF(Timer,
"SystemCounter::enable: Counter enabled\n");
94 DPRINTF(Timer,
"SystemCounter::disable: Counter disabled\n");
122 warn(
"Explicit value set with counter enabled, UNKNOWNN result\n");
132 if (target_val > cur_val) {
133 uint64_t num_cycles =
134 std::ceil((target_val - cur_val) / ((
double)
_increment));
163 if (new_freq !=
_freq) {
169 uint64_t target_val =
value();
170 target_val += target_val % std::max(
_increment, new_incr);
179 DPRINTF(Timer,
"SystemCounter::freqUpdateCallback: Changing counter " 206 DPRINTF(Timer,
"SystemCounter::serialize: Serializing\n");
216 if (pending_freq_update) {
226 DPRINTF(Timer,
"SystemCounter::unserialize: Unserializing\n");
234 bool pending_freq_update;
236 if (pending_freq_update) {
237 Tick when_freq_update;
250 : _name(name), _parent(parent), _systemCounter(sysctr),
251 _interrupt(interrupt),
252 _control(0), _counterLimit(0), _offset(0),
264 DPRINTF(Timer,
"Counter limit reached\n");
268 DPRINTF(Timer,
"Causing interrupt\n");
271 DPRINTF(Timer,
"Kvm mode; skipping simulated interrupt\n");
313 if (!old_ctl.enable && new_ctl.enable)
316 else if (old_ctl.enable && !new_ctl.enable)
378 systemCounter(*p->counter),
382 fatal_if(!p->system,
"GenericTimer::GenericTimer: No system specified, " 383 "can't instantiate architected timers\n");
387 const GenericTimerParams *
390 return dynamic_cast<const GenericTimerParams *
>(
_params);
398 for (
int i = 0;
i <
timers.size(); ++
i) {
410 static const unsigned OLD_CPU_MAX = 8;
413 warn(
"Checkpoint does not contain CPU count, assuming %i CPUs\n",
415 cpu_count = OLD_CPU_MAX;
418 for (
int i = 0;
i < cpu_count; ++
i) {
427 if (cpu_id >=
timers.size())
436 assert(
timers.size() < cpus);
437 auto p =
static_cast<const GenericTimerParams *
>(
_params);
439 const unsigned old_cpu_count(
timers.size());
441 for (
unsigned i = old_cpu_count;
i < cpus; ++
i) {
447 p->int_phys_s->get(tc),
448 p->int_phys_ns->get(tc),
449 p->int_virt->get(tc),
450 p->int_hyp->get(tc)));
459 uint64_t old_evnten =
bits(old_cnt_ctl, 2);
466 if (evnten && ((old_evnten != evnten) ||
473 }
else if (old_evnten && !evnten) {
491 "does not match the system counter freq\n");
542 warn(
"Ignoring write to read only count register: %s\n",
617 return core.
cntkctl & 0x00000000ffffffff;
620 return core.
cnthctl & 0x00000000ffffffff;
697 cntfrq(parent.
params()->cntfrq),
698 threadContext(system.getThreadContext(cpu)),
700 irqPhysNS(_irqPhysNS),
703 physS(
csprintf(
"%s.phys_s_timer%d", parent.
name(), cpu),
773 if (phys_ev_scheduled) {
782 if (virt_ev_scheduled) {
802 bool phys_ev_scheduled;
804 if (phys_ev_scheduled) {
812 bool virt_ev_scheduled;
814 if (virt_ev_scheduled) {
845 timerRange(
RangeSize(p->cnt_base, sys->getPageBytes())),
860 accessBitsEl0 = 0x303;
918 accessBits = data & 0x3f;
936 return accessBits.rvoff;
949 const size_t size = pkt->
getSize();
950 const bool is_sec = pkt->
isSecure();
952 "GenericTimerFrame::read: Invalid size %i\n", size);
963 panic(
"GenericTimerFrame::read: Invalid address: 0x%x\n", addr);
966 resp =
timerRead(offset, size, is_sec, to_el0);
968 DPRINTF(Timer,
"GenericTimerFrame::read: 0x%x<-0x%x(%i) [S = %u]\n", resp,
980 const size_t size = pkt->
getSize();
981 const bool is_sec = pkt->
isSecure();
983 "GenericTimerFrame::write: Invalid size %i\n", size);
994 panic(
"GenericTimerFrame::write: Invalid address: 0x%x\n", addr);
997 timerWrite(offset, size, data, is_sec, to_el0);
999 DPRINTF(Timer,
"GenericTimerFrame::write: 0x%x->0x%x(%i) [S = %u]\n", data,
1000 addr, size, is_sec);
1016 if (!accessBits.rpct || (to_el0 && !accessBitsEl0.pcten))
1022 if (!accessBits.rpct || (to_el0 && !accessBitsEl0.pcten))
1028 if ((!accessBits.rfrq) ||
1029 (to_el0 && (!accessBitsEl0.pcten && !accessBitsEl0.vcten)))
1038 return accessBitsEl0;
1041 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1047 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1053 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1058 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1064 if (!accessBits.rvct || (to_el0 && !accessBitsEl0.vcten))
1070 if (!accessBits.rvct || (to_el0 && !accessBitsEl0.vcten))
1076 if (!accessBits.rvoff || (to_el0))
1082 if (!accessBits.rvoff || (to_el0))
1088 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1094 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1100 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1106 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1112 warn(
"GenericTimerFrame::timerRead: Unexpected address (0x%x:%i), " 1113 "assuming RAZ\n", addr, size);
1120 bool is_sec,
bool to_el0)
1128 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTPCT]\n",
1133 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTFRQ]\n",
1146 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1149 31, 0,
data) : data;
1154 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1161 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1167 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1173 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTVCT]\n",
1177 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTVOFF]\n",
1182 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1185 31, 0,
data) : data;
1190 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1197 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1203 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1209 warn(
"GenericTimerFrame::timerWrite: Unexpected address (0x%x:%i), " 1210 "assuming WI\n", addr, size);
1216 counterCtrlRange(
RangeSize(p->cnt_control_base,
sys->getPageBytes())),
1217 counterStatusRange(
RangeSize(p->cnt_read_base,
sys->getPageBytes())),
1218 timerCtrlRange(
RangeSize(p->cnt_ctl_base,
sys->getPageBytes())),
1229 "GenericTimerMem::GenericTimerMem: Architecture states a maximum of " 1230 "8 memory-mapped timer frames, limit surpassed\n");
1232 for (
int i = 0;
i <
frames.size();
i++) {
1233 uint32_t features = 0x1;
1246 "GenericTimerMem::validateFrameRange: Architecture states each " 1247 "register frame should be in a separate memory page, specified " 1248 "range base address [0x%x] is not compliant\n");
1267 const size_t size = pkt->
getSize();
1268 const bool is_sec = pkt->
isSecure();
1270 "GenericTimerMem::read: Invalid size %i\n", size);
1280 panic(
"GenericTimerMem::read: Invalid address: 0x%x\n", addr);
1282 DPRINTF(Timer,
"GenericTimerMem::read: 0x%x<-0x%x(%i) [S = %u]\n", resp,
1283 addr, size, is_sec);
1294 const size_t size = pkt->
getSize();
1295 const bool is_sec = pkt->
isSecure();
1297 "GenericTimerMem::write: Invalid size %i\n", size);
1307 panic(
"GenericTimerMem::write: Invalid address: 0x%x\n", addr);
1309 DPRINTF(Timer,
"GenericTimerMem::write: 0x%x->0x%x(%i) [S = %u]\n", data,
1310 addr, size, is_sec);
1322 case COUNTER_CTRL_CNTCR:
1342 for (
int i = 0;
i < (freq_table.size() - 1);
i++) {
1345 return freq_table[
i];
1347 warn(
"GenericTimerMem::counterCtrlRead: Unexpected address " 1348 "(0x%x:%i), assuming RAZ\n", addr, size);
1362 case COUNTER_CTRL_CNTCR:
1371 warn(
"GenericTimerMem::counterCtrlWrite: Halt-on-debug is not " 1374 warn(
"GenericTimerMem::counterCtrlWrite: Counter Scaling is not " 1382 warn(
"GenericTimerMem::counterCtrlWrite: RO reg (0x%x) [CNTSR]\n",
1401 warn(
"GenericTimerMem::counterCtrlWrite: RO reg (0x%x) [CNTID]\n",
1408 for (
int i = 0;
i < (freq_table.size() - 1);
i++) {
1410 if (addr == offset) {
1411 freq_table[
i] =
data;
1422 warn(
"GenericTimerMem::counterCtrlWrite: Unexpected address " 1423 "(0x%x:%i), assuming WI\n", addr, size);
1435 warn(
"GenericTimerMem::counterStatusRead: Unexpected address " 1436 "(0x%x:%i), assuming RAZ\n", addr, size);
1446 warn(
"GenericTimerMem::counterStatusWrite: RO reg (0x%x) [CNTCV]\n",
1450 warn(
"GenericTimerMem::counterStatusWrite: Unexpected address " 1451 "(0x%x:%i), assuming WI\n", addr, size);
1465 uint32_t cntnsar = 0x0;
1466 for (
int i = 0;
i <
frames.size();
i++) {
1467 if (
frames[
i]->hasNonSecureAccess())
1468 cntnsar |= 0x1 <<
i;
1474 for (
int i = 0;
i <
frames.size();
i++) {
1480 bool hit = addr == cntacr_off || addr == cntvoff_lo_off ||
1481 addr == cntvoff_hi_off;
1484 frames[
i]->hasNonSecureAccess();
1485 if (hit && !has_access)
return 0;
1486 if (addr == cntacr_off)
1487 return frames[
i]->getAccessBits();
1488 if (addr == cntvoff_lo_off || addr == cntvoff_hi_off) {
1489 return addr == cntvoff_lo_off ?
frames[
i]->getVirtOffset()
1490 :
frames[
i]->getVirtOffset() >> 32;
1493 warn(
"GenericTimerMem::timerCtrlRead: Unexpected address (0x%x:%i), " 1494 "assuming RAZ\n", addr, size);
1507 "GenericTimerMem::timerCtrlWrite: CNTFRQ configured freq " 1508 "does not match the counter freq, ignoring\n");
1512 for (
int i = 0;
i <
frames.size();
i++) {
1514 if (data & (0x1 <<
i))
1515 frames[
i]->setNonSecureAccess();
1519 warn(
"GenericTimerMem::timerCtrlWrite: RO reg (0x%x) [CNTTIDR]\n",
1523 for (
int i = 0;
i <
frames.size();
i++) {
1529 bool hit = addr == cntacr_off || addr == cntvoff_lo_off ||
1530 addr == cntvoff_hi_off;
1533 frames[
i]->hasNonSecureAccess();
1534 if (hit && !has_access)
return;
1535 if (addr == cntacr_off) {
1536 frames[
i]->setAccessBits(data);
1539 if (addr == cntvoff_lo_off || addr == cntvoff_hi_off) {
1540 if (addr == cntvoff_lo_off)
1542 31, 0, data) :
data;
1546 frames[
i]->setVirtOffset(data);
1550 warn(
"GenericTimerMem::timerCtrlWrite: Unexpected address " 1551 "(0x%x:%i), assuming WI\n", addr, size);
1556 SystemCounterParams::create()
1562 GenericTimerParams::create()
1568 GenericTimerFrameParams::create()
1574 GenericTimerMemParams::create()
void unserialize(CheckpointIn &cp) override
Unserialize an object.
ArchTimer(const std::string &name, SimObject &parent, SystemCounter &sysctr, ArmInterruptPin *interrupt)
void setMiscReg(int misc_reg, RegVal val) override
Write to a system register belonging to this device.
const AddrRange counterCtrlRange
#define panic(...)
This implements a cprintf based panic() function.
EventFunctionWrapper _counterLimitReachedEvent
AddrRange RangeSize(Addr start, Addr size)
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
EventFunctionWrapper event
static const Addr TIMER_CTRL_CNTACR
void setUintX(uint64_t w, ByteOrder endian)
Set the value in the word w after truncating it to the length of the packet and then byteswapping it ...
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.
void setMiscReg(int misc_reg, unsigned cpu, RegVal val)
std::vector< SystemCounterListener * > _listeners
Listeners to changes in counting speed.
static const Addr TIMER_CNTV_CVAL_LO
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
static const Addr TIMER_CNTPCT_HI
#define UNSERIALIZE_CONTAINER(member)
static const Addr COUNTER_CTRL_CNTSR
void counterStatusWrite(Addr addr, size_t size, uint64_t data)
std::vector< GenericTimerFrame * > frames
Timer frame references.
Tick _updateTick
Counter cycle start Tick when the counter status affecting its value has been updated.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const Addr TIMER_CNTEL0ACR
CoreTimers & getTimers(int cpu_id)
static const Addr TIMER_CNTP_TVAL
This module implements the global system counter and the local per-CPU architected timers as specifie...
static const Addr COUNTER_STATUS_CNTCV_HI
static const Addr COUNTER_STATUS_CNTCV_LO
bool haveSecurity() const
Returns true if this system implements the Security Extensions.
bool hasReadableVoff() const
Indicates if CNTVOFF is readable for this frame.
void setVirtOffset(uint64_t new_offset)
Sets the virtual offset for this frame's virtual timer after a write to CNTVOFF.
SystemCounter & systemCounter
System counter reference.
CNTKCTL cntkctl
Kernel control register.
static const Addr TIMER_CTRL_CNTVOFF_HI
DrainState drain() override
Notify an object that it needs to drain its state.
Per-CPU architected timer.
RegVal readMiscReg(int misc_reg, unsigned cpu)
bool hasEl0View() const
Indicates if this frame implements a second EL0 view.
uint64_t counterCtrlRead(Addr addr, size_t size, bool is_sec) const
CNTControlBase (System counter control frame)
void notifyListeners(void) const
Notifies counting speed changes to listeners.
void freqUpdateCallback()
Callback for the frequency update.
bool contains(const Addr &a) const
Determine if the range contains an address.
ThreadContext * threadContext
Thread (HW) context associated to this PE implementation.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
void notify(void) override
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
void updateTick(void)
Updates the update tick, normalizes to the lower cycle start tick.
static const Addr TIMER_CNTPCT_LO
void virtEventStreamCallback()
void timerWrite(Addr addr, size_t size, uint64_t data, bool is_sec, bool to_el0)
uint64_t value() const
Returns the value of the counter which this timer relies on.
uint32_t cntfrq
System counter frequency as visible from this core.
const AddrRange timerRange
uint32_t freq() const
Returns the counter frequency.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
virtual BaseCPU * getCpuPtr()=0
const AddrRangeList addrRanges
All MMIO ranges GenericTimerMem responds to.
SystemCounter & systemCounter
System counter reference.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void registerListener(SystemCounterListener *listener)
Called from System Counter Listeners to register.
const char *const miscRegName[]
static const Addr COUNTER_CTRL_CNTID
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void physEventStreamCallback()
void handleStream(CoreTimers::EventStream *ev_stream, ArchTimer *timer, RegVal old_cnt_ctl, RegVal cnt_ctl)
static ExceptionLevel currEL(const ThreadContext *tc)
static bool validateAccessPerm(ArmSystem &sys, bool is_sec)
Validates an MMIO access permissions.
ArmSystem & system
ARM system containing this timer.
DrainState
Object drain/handover states.
static const Addr COUNTER_CTRL_CNTCV_LO
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
void setTimerValue(uint32_t val)
Sets the TimerValue view of the timer.
static const Addr TIMER_CNTP_CTL
const GenericTimerParams * params() const
static const Addr TIMER_CNTV_TVAL
void setGenericTimer(GenericTimer *generic_timer)
Sets the pointer to the Generic Timer.
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits...
ArchTimerCtrl _control
Value of the control register ({CNTP/CNTHP/CNTV}_CTL).
ThreadContext * getThreadContext(ContextID tid) const
bool valid() const
Determine if the range is valid.
bool enabled() const
Indicates if the counter is enabled.
void counterLimitReached()
Called when the upcounter reaches the programmed value.
uint64_t timerRead(Addr addr, size_t size, bool is_sec, bool to_el0) const
CNTBase/CNTEL0Base (Memory-mapped timer frame)
Tick _period
Cached copy of the counter period (inverse of the frequency).
CoreTimers(GenericTimer &_parent, ArmSystem &system, unsigned cpu, ArmInterruptPin *_irqPhysS, ArmInterruptPin *_irqPhysNS, ArmInterruptPin *_irqVirt, ArmInterruptPin *_irqHyp)
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
#define UNSERIALIZE_SCALAR(scalar)
void setValue(uint64_t new_value)
Sets the value explicitly from writes to CNTCR.CNTCV.
void setOffset(uint64_t val)
Draining buffers pending serialization/handover.
static constexpr size_t MAX_TIMER_FRAMES
Maximum architectural number of memory-mapped timer frames.
Tick curTick()
The current simulated tick.
std::string csprintf(const char *format, const Args &...args)
static const Addr TIMER_CNTP_CVAL_LO
EventFunctionWrapper _freqUpdateEvent
Frequency update event handling.
uint64_t eventTargetValue(uint64_t val) const
void serialize(CheckpointOut &cp) const override
Serialize an object.
static const Addr COUNTER_CTRL_CNTCV_HI
uint64_t Tick
Tick count type.
void createTimers(unsigned cpus)
AddrRangeList addrRanges
All MMIO ranges GenericTimerFrame responds to.
void serialize(CheckpointOut &cp) const override
Serialize an object.
uint32_t cnttidr
ID register for reporting features of implemented timer frames.
const AddrRange counterStatusRange
static const Addr TIMER_CNTP_CVAL_HI
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
#define UNSERIALIZE_OPT_SCALAR(scalar)
void setCompareValue(uint64_t val)
Sets the CompareValue view of the timer.
void replaceBits(T &val, int first, int last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
size_t activeFreqEntry() const
Returns the currently active frequency table entry.
void counterCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec)
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
static constexpr size_t MAX_FREQ_ENTRIES
Maximum architectural number of frequency table entries.
void deschedule(Event &event)
uint64_t value()
Updates and returns the counter value.
void disable()
Disables the counter after a CNTCR.EN == 0.
uint32_t timerValue() const
Returns the TimerValue view of the timer.
SystemCounter & systemCounter
System counter reference.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
static const Addr COUNTER_CTRL_CNTFID
static const Addr TIMER_CNTV_CVAL_HI
void schedule(Event &event, Tick when)
T insertBits(T val, int first, int last, B bit_val)
Returns val with bits first to last set to the LSBs of bit_val.
static const Addr TIMER_CTRL_CNTFRQ
This device is the base class which all devices senstive to an address range inherit from...
static const Addr TIMER_CNTFRQ
static const Addr COUNTER_CTRL_CNTSCR
uint64_t timerCtrlRead(Addr addr, size_t size, bool is_sec) const
CNTCTLBase (Memory-mapped timer global control frame)
static void wakeup(ThreadID tid)
static const Addr TIMER_CNTVOFF_HI
void serialize(CheckpointOut &cp) const override
Serialize an object.
void reschedule(Event &event, Tick when, bool always=false)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
bool nonSecureAccess
Reports whether non-secure accesses are allowed to this frame.
virtual bool scheduleEvents()
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
void enable()
Enables the counter after a CNTCR.EN == 1.
RegVal readMiscReg(int misc_reg) override
Read a system register belonging to this device.
void notify(void) override
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
SystemCounter(SystemCounterParams *const p)
Tick whenValue(uint64_t target_val)
static const Addr TIMER_CNTVCT_HI
static const Addr TIMER_CNTVCT_LO
void sendEvent(ThreadContext *tc)
Send an event (SEV) to a specific PE if there isn't already a pending event.
Abstract class for elements whose events depend on the counting speed of the System Counter...
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
#define SERIALIZE_SCALAR(scalar)
bool scheduled() const
Determine if the current event is scheduled.
GenericTimer(GenericTimerParams *const p)
static const Addr TIMER_CTRL_CNTVOFF_LO
static const Addr TIMER_CTRL_CNTNSAR
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
virtual const std::string name() const
std::string name() const
Returns the timer name.
static const Addr TIMER_CNTVOFF_LO
Base class for ARM GIC implementations.
#define SERIALIZE_CONTAINER(member)
virtual void raise()=0
Signal an interrupt.
std::ostream CheckpointOut
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.
void freqUpdateSchedule(size_t new_freq_entry)
Schedules a counter frequency update after a CNTCR.FCREQ == 1 This complies with frequency transition...
uint64_t counterStatusRead(Addr addr, size_t size) const
CNTReadBase (System counter status frame)
GenericTimerFrame(GenericTimerFrameParams *const p)
virtual int threadId() const =0
const SimObjectParams * _params
Cached copy of the object parameters.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t compareValue() const
Returns the CompareValue view of the timer.
void updateValue(void)
Updates the counter value.
void drainResume() override
Resume execution after a successful drain.
uint8_t getAccessBits() const
Returns the access bits for this frame.
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
static void validateFrameRange(const AddrRange &range)
Validates a Generic Timer register frame address range.
ArmInterruptPin *const _interrupt
Addr start() const
Get the start address of the range.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const Addr TIMER_CTRL_CNTTIDR
uint64_t _value
Counter value (as specified in CNTCV).
void timerCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec)
void setControl(uint32_t val)
std::vector< std::unique_ptr< CoreTimers > > timers
Per-CPU physical architected timers.
bool _enabled
Indicates if the counter is enabled.
bool ELIsInHost(ThreadContext *tc, ExceptionLevel el)
Returns true if the current exception level el is executing a Host OS or an application of a Host OS ...
SystemCounter & _systemCounter
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
uint32_t control() const
Sets the control register.
const AddrRange timerCtrlRange
size_t _activeFreqEntry
Currently selected entry in the table, its contents should match _freq.
void setAccessBits(uint8_t data)
Updates the access bits after a write to CNTCTLBase.CNTACR.
void updateCounter()
Timer settings or the offset has changed, re-evaluate trigger condition and raise interrupt if necess...
void eventStreamCallback() const
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
static const Addr TIMER_CNTV_CTL
Tick when() const
Get the time that the event is scheduled.
std::vector< uint32_t > & freqTable()
Returns a reference to the frequency modes table.
CNTHCTL cnthctl
Hypervisor control register.
GenericTimer & parent
Generic Timer parent reference.
Generic representation of an Arm interrupt pin.
uint64_t getVirtOffset() const
Returns the virtual offset for this frame if a virtual timer is implemented.
Abstract superclass for simulation objects.
uint32_t _freq
Counter frequency (as specified by CNTFRQ).
ArchTimer physTimer
Physical and virtual timers.
bool hasNonSecureAccess() const
Indicates if non-secure accesses are allowed to this frame.
GenericTimerMem(GenericTimerMemParams *const p)
void schedNextEvent(EventStream &ev_stream, ArchTimer &timer)
void setNonSecureAccess()
Allows non-secure accesses after an enabling write to CNTCTLBase.CNTNSAR.
uint64_t _increment
Value increment in each counter cycle.
uint64_t _offset
Offset relative to the physical timer (CNTVOFF)
Addr getPageBytes() const
Get the page bytes for the ISA.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
EndBitUnion(ArchTimerCtrl) const std SimObject & _parent
Name of this timer.
static void validateCounterRef(SystemCounter *sys_cnt)
Validates a System Counter reference.