Go to the documentation of this file.
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"
67 "frequency not provided\n");
71 "SystemCounter::SystemCounter: Architecture states a maximum of 1004 "
72 "frequency table entries, limit surpassed\n");
81 fatal_if(!sys_cnt,
"SystemCounter::validateCounterRef: No valid system "
82 "counter, can't instantiate system timers\n");
88 DPRINTF(Timer,
"SystemCounter::enable: Counter enabled\n");
96 DPRINTF(Timer,
"SystemCounter::disable: Counter disabled\n");
124 warn(
"Explicit value set with counter enabled, UNKNOWNN result\n");
134 if (target_val > cur_val) {
135 uint64_t num_cycles =
136 std::ceil((target_val - cur_val) / ((
double)
_increment));
165 if (new_freq !=
_freq) {
171 uint64_t target_val =
value();
172 target_val += target_val % std::max(
_increment, new_incr);
181 DPRINTF(Timer,
"SystemCounter::freqUpdateCallback: Changing counter "
208 DPRINTF(Timer,
"SystemCounter::serialize: Serializing\n");
218 if (pending_freq_update) {
228 DPRINTF(Timer,
"SystemCounter::unserialize: Unserializing\n");
236 bool pending_freq_update;
238 if (pending_freq_update) {
239 Tick when_freq_update;
252 : _name(
name), _parent(parent), _systemCounter(sysctr),
253 _interrupt(interrupt),
254 _control(0), _counterLimit(0), _offset(0),
257 _systemCounter.registerListener(
this);
266 DPRINTF(Timer,
"Counter limit reached\n");
270 DPRINTF(Timer,
"Causing interrupt\n");
273 DPRINTF(Timer,
"Kvm mode; skipping simulated interrupt\n");
288 DPRINTF(Timer,
"Clearing interrupt\n");
322 if ((old_ctl.imask && !new_ctl.imask) ||
323 (!old_ctl.enable && new_ctl.enable))
326 else if ((!old_ctl.imask && new_ctl.imask) ||
327 (old_ctl.enable && !new_ctl.enable)) {
330 DPRINTF(Timer,
"Clearing interrupt\n");
400 systemCounter(*
p->counter),
404 fatal_if(!
p->system,
"GenericTimer::GenericTimer: No system specified, "
405 "can't instantiate architected timers\n");
409 const GenericTimerParams *
412 return dynamic_cast<const GenericTimerParams *
>(
_params);
420 for (
int i = 0;
i <
timers.size(); ++
i) {
432 static const unsigned OLD_CPU_MAX = 8;
435 warn(
"Checkpoint does not contain CPU count, assuming %i CPUs\n",
437 cpu_count = OLD_CPU_MAX;
445 fatal(
"The simulated system has been initialized with %d CPUs, "
446 "but the Generic Timer checkpoint expects %d CPUs. Consider "
447 "restoring the checkpoint specifying %d CPUs.",
451 for (
int i = 0;
i < cpu_count; ++
i) {
460 if (cpu_id >=
timers.size())
469 assert(
timers.size() < cpus);
470 auto p =
static_cast<const GenericTimerParams *
>(
_params);
472 const unsigned old_cpu_count(
timers.size());
474 for (
unsigned i = old_cpu_count;
i < cpus; ++
i) {
480 p->int_phys_s->get(tc),
481 p->int_phys_ns->get(tc),
482 p->int_virt->get(tc),
483 p->int_hyp->get(tc)));
492 uint64_t old_evnten =
bits(old_cnt_ctl, 2);
506 }
else if (old_evnten && !
evnten) {
524 "does not match the system counter freq\n");
575 warn(
"Ignoring write to read only count register: %s\n",
650 return core.
cntkctl & 0x00000000ffffffff;
653 return core.
cnthctl & 0x00000000ffffffff;
730 cntfrq(parent.params()->cntfrq),
731 threadContext(
system.threads[cpu]),
733 irqPhysNS(_irqPhysNS),
736 physS(
csprintf(
"%s.phys_s_timer%d", parent.
name(), cpu),
737 system, parent, parent.systemCounter,
742 system, parent, parent.systemCounter,
745 system, parent, parent.systemCounter,
748 system, parent, parent.systemCounter,
756 csprintf(
"%s.virt_event_gen%d", parent.name(), cpu)), 0, 0
764 eventStreamCallback();
765 schedNextEvent(physEvStream, physNS);
771 eventStreamCallback();
772 schedNextEvent(virtEvStream, virt);
779 threadContext->getCpuPtr()->wakeup(threadContext->threadId());
793 schedNextEvent(virtEvStream, virt);
794 schedNextEvent(physEvStream, physNS);
804 const bool phys_ev_scheduled = physEvStream.event.scheduled();
806 if (phys_ev_scheduled) {
807 const Tick phys_ev_when = physEvStream.event.when();
813 const bool virt_ev_scheduled = virtEvStream.event.scheduled();
815 if (virt_ev_scheduled) {
816 const Tick virt_ev_when = virtEvStream.event.when();
822 physS.serializeSection(
cp,
"phys_s_timer");
823 physNS.serializeSection(
cp,
"phys_ns_timer");
824 virt.serializeSection(
cp,
"virt_timer");
825 hyp.serializeSection(
cp,
"hyp_timer");
835 bool phys_ev_scheduled;
837 if (phys_ev_scheduled) {
840 parent.reschedule(physEvStream.event, phys_ev_when,
true);
845 bool virt_ev_scheduled;
847 if (virt_ev_scheduled) {
850 parent.reschedule(virtEvStream.event, virt_ev_when,
true);
855 physS.unserializeSection(
cp,
"phys_s_timer");
856 physNS.unserializeSection(
cp,
"phys_ns_timer");
857 virt.unserializeSection(
cp,
"virt_timer");
858 hyp.unserializeSection(
cp,
"hyp_timer");
865 parent.setMiscReg(
reg, cpu,
val);
871 RegVal value = parent.readMiscReg(
reg, cpu);
880 systemCounter(*
p->counter),
882 *
this, systemCounter,
p->int_phys->get()),
884 *
this, systemCounter,
893 accessBitsEl0 = 0x303;
894 addrRanges.push_back(timerEl0Range);
896 for (
auto &range : addrRanges)
951 accessBits =
data & 0x3f;
969 return accessBits.rvoff;
982 const size_t size = pkt->
getSize();
983 const bool is_sec = pkt->
isSecure();
985 "GenericTimerFrame::read: Invalid size %i\n", size);
996 panic(
"GenericTimerFrame::read: Invalid address: 0x%x\n",
addr);
1001 DPRINTF(Timer,
"GenericTimerFrame::read: 0x%x<-0x%x(%i) [S = %u]\n", resp,
1002 addr, size, is_sec);
1004 pkt->
setUintX(resp, ByteOrder::little);
1013 const size_t size = pkt->
getSize();
1014 const bool is_sec = pkt->
isSecure();
1016 "GenericTimerFrame::write: Invalid size %i\n", size);
1018 bool to_el0 =
false;
1019 const uint64_t
data = pkt->
getUintX(ByteOrder::little);
1027 panic(
"GenericTimerFrame::write: Invalid address: 0x%x\n",
addr);
1032 DPRINTF(Timer,
"GenericTimerFrame::write: 0x%x->0x%x(%i) [S = %u]\n",
data,
1033 addr, size, is_sec);
1049 if (!accessBits.rpct || (to_el0 && !accessBitsEl0.pcten))
1055 if (!accessBits.rpct || (to_el0 && !accessBitsEl0.pcten))
1061 if ((!accessBits.rfrq) ||
1062 (to_el0 && (!accessBitsEl0.pcten && !accessBitsEl0.vcten)))
1071 return accessBitsEl0;
1074 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1080 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1086 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1091 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1097 if (!accessBits.rvct || (to_el0 && !accessBitsEl0.vcten))
1103 if (!accessBits.rvct || (to_el0 && !accessBitsEl0.vcten))
1109 if (!accessBits.rvoff || (to_el0))
1115 if (!accessBits.rvoff || (to_el0))
1121 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1127 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1133 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1139 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1145 warn(
"GenericTimerFrame::timerRead: Unexpected address (0x%x:%i), "
1146 "assuming RAZ\n",
addr, size);
1153 bool is_sec,
bool to_el0)
1161 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTPCT]\n",
1166 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTFRQ]\n",
1179 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1187 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1194 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1200 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1206 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTVCT]\n",
1210 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTVOFF]\n",
1215 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1223 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1230 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1236 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1242 warn(
"GenericTimerFrame::timerWrite: Unexpected address (0x%x:%i), "
1243 "assuming WI\n",
addr, size);
1254 systemCounter(*
p->counter),
1259 for (
auto &range : addrRanges)
1261 fatal_if(frames.size() > MAX_TIMER_FRAMES,
1262 "GenericTimerMem::GenericTimerMem: Architecture states a maximum of "
1263 "8 memory-mapped timer frames, limit surpassed\n");
1265 for (
int i = 0;
i < frames.size();
i++) {
1266 uint32_t features = 0x1;
1268 if (frames[
i]->hasEl0View())
1279 "GenericTimerMem::validateFrameRange: Architecture states each "
1280 "register frame should be in a separate memory page, specified "
1281 "range base address [0x%x] is not compliant\n");
1287 return !
sys.haveSecurity() || is_sec;
1300 const size_t size = pkt->
getSize();
1301 const bool is_sec = pkt->
isSecure();
1303 "GenericTimerMem::read: Invalid size %i\n", size);
1313 panic(
"GenericTimerMem::read: Invalid address: 0x%x\n",
addr);
1315 DPRINTF(Timer,
"GenericTimerMem::read: 0x%x<-0x%x(%i) [S = %u]\n", resp,
1316 addr, size, is_sec);
1318 pkt->
setUintX(resp, ByteOrder::little);
1327 const size_t size = pkt->
getSize();
1328 const bool is_sec = pkt->
isSecure();
1330 "GenericTimerMem::write: Invalid size %i\n", size);
1332 const uint64_t
data = pkt->
getUintX(ByteOrder::little);
1340 panic(
"GenericTimerMem::write: Invalid address: 0x%x\n",
addr);
1342 DPRINTF(Timer,
"GenericTimerMem::write: 0x%x->0x%x(%i) [S = %u]\n",
data,
1343 addr, size, is_sec);
1355 case COUNTER_CTRL_CNTCR:
1375 for (
int i = 0;
i < (freq_table.size() - 1);
i++) {
1378 return freq_table[
i];
1380 warn(
"GenericTimerMem::counterCtrlRead: Unexpected address "
1381 "(0x%x:%i), assuming RAZ\n",
addr, size);
1395 case COUNTER_CTRL_CNTCR:
1404 warn(
"GenericTimerMem::counterCtrlWrite: Halt-on-debug is not "
1407 warn(
"GenericTimerMem::counterCtrlWrite: Counter Scaling is not "
1415 warn(
"GenericTimerMem::counterCtrlWrite: RO reg (0x%x) [CNTSR]\n",
1434 warn(
"GenericTimerMem::counterCtrlWrite: RO reg (0x%x) [CNTID]\n",
1441 for (
int i = 0;
i < (freq_table.size() - 1);
i++) {
1444 freq_table[
i] =
data;
1455 warn(
"GenericTimerMem::counterCtrlWrite: Unexpected address "
1456 "(0x%x:%i), assuming WI\n",
addr, size);
1468 warn(
"GenericTimerMem::counterStatusRead: Unexpected address "
1469 "(0x%x:%i), assuming RAZ\n",
addr, size);
1479 warn(
"GenericTimerMem::counterStatusWrite: RO reg (0x%x) [CNTCV]\n",
1483 warn(
"GenericTimerMem::counterStatusWrite: Unexpected address "
1484 "(0x%x:%i), assuming WI\n",
addr, size);
1498 uint32_t cntnsar = 0x0;
1499 for (
int i = 0;
i <
frames.size();
i++) {
1500 if (
frames[
i]->hasNonSecureAccess())
1501 cntnsar |= 0x1 <<
i;
1507 for (
int i = 0;
i <
frames.size();
i++) {
1513 bool hit =
addr == cntacr_off ||
addr == cntvoff_lo_off ||
1514 addr == cntvoff_hi_off;
1517 frames[
i]->hasNonSecureAccess();
1518 if (hit && !has_access)
return 0;
1519 if (
addr == cntacr_off)
1520 return frames[
i]->getAccessBits();
1521 if (
addr == cntvoff_lo_off ||
addr == cntvoff_hi_off) {
1522 return addr == cntvoff_lo_off ?
frames[
i]->getVirtOffset()
1523 :
frames[
i]->getVirtOffset() >> 32;
1526 warn(
"GenericTimerMem::timerCtrlRead: Unexpected address (0x%x:%i), "
1527 "assuming RAZ\n",
addr, size);
1540 "GenericTimerMem::timerCtrlWrite: CNTFRQ configured freq "
1541 "does not match the counter freq, ignoring\n");
1545 for (
int i = 0;
i <
frames.size();
i++) {
1547 if (
data & (0x1 <<
i))
1548 frames[
i]->setNonSecureAccess();
1552 warn(
"GenericTimerMem::timerCtrlWrite: RO reg (0x%x) [CNTTIDR]\n",
1556 for (
int i = 0;
i <
frames.size();
i++) {
1562 bool hit =
addr == cntacr_off ||
addr == cntvoff_lo_off ||
1563 addr == cntvoff_hi_off;
1566 frames[
i]->hasNonSecureAccess();
1567 if (hit && !has_access)
return;
1568 if (
addr == cntacr_off) {
1572 if (
addr == cntvoff_lo_off ||
addr == cntvoff_hi_off) {
1573 if (
addr == cntvoff_lo_off)
1583 warn(
"GenericTimerMem::timerCtrlWrite: Unexpected address "
1584 "(0x%x:%i), assuming WI\n",
addr, size);
1589 SystemCounterParams::create()
1595 GenericTimerParams::create()
1601 GenericTimerFrameParams::create()
1607 GenericTimerMemParams::create()
static const Addr TIMER_CTRL_CNTVOFF_LO
void sendEvent(ThreadContext *tc)
Send an event (SEV) to a specific PE if there isn't already a pending event.
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
#define fatal(...)
This implements a cprintf based fatal() function.
void setTimerValue(uint32_t val)
Sets the TimerValue view of the timer.
uint64_t eventTargetValue(uint64_t val) const
uint64_t _increment
Value increment in each counter cycle.
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 ...
void handleStream(CoreTimers::EventStream *ev_stream, ArchTimer *timer, RegVal old_cnt_ctl, RegVal cnt_ctl)
bool scheduled() const
Determine if the current event is scheduled.
void timerCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec)
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
ArmISA::CNTKCTL cntkctl
Kernel control register.
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.
ArmSystem & system
ARM system containing this timer.
Tick whenValue(uint64_t target_val)
Returns the tick at which a certain counter value is reached.
std::vector< SystemCounterListener * > _listeners
Listeners to changes in counting speed.
const AddrRange timerRange
uint32_t cnttidr
ID register for reporting features of implemented timer frames.
const AddrRange counterStatusRange
#define UNSERIALIZE_SCALAR(scalar)
ArchTimer physTimer
Physical and virtual timers.
EndBitUnion(ArchTimerCtrl) const std SimObject & _parent
Name of this timer.
RegVal readMiscReg(int misc_reg) override
Read a system register belonging to this device.
static const Addr COUNTER_CTRL_CNTID
void disable()
Disables the counter after a CNTCR.EN == 0.
ArchTimer(const std::string &name, SimObject &parent, SystemCounter &sysctr, ArmInterruptPin *interrupt)
#define UNSERIALIZE_CONTAINER(member)
static const Addr TIMER_CNTP_TVAL
void reschedule(Event &event, Tick when, bool always=false)
static const Addr COUNTER_CTRL_CNTCV_LO
virtual void clear()=0
Clear a signalled interrupt.
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.
void serialize(CheckpointOut &cp) const override
Serialize an object.
SystemCounter & systemCounter
System counter reference.
uint32_t _freq
Counter frequency (as specified by CNTFRQ).
static ExceptionLevel currEL(const ThreadContext *tc)
void eventStreamCallback() const
Per-CPU architected timer.
void counterStatusWrite(Addr addr, size_t size, uint64_t data)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint32_t freq() const
Returns the counter frequency.
virtual void raise()=0
Signal an interrupt.
bool hasEl0View() const
Indicates if this frame implements a second EL0 view.
uint64_t Tick
Tick count type.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static void validateCounterRef(SystemCounter *sys_cnt)
Validates a System Counter reference.
ArchTimerCtrl _control
Value of the control register ({CNTP/CNTHP/CNTV}_CTL).
uint64_t timerRead(Addr addr, size_t size, bool is_sec, bool to_el0) const
CNTBase/CNTEL0Base (Memory-mapped timer frame)
void updateCounter()
Timer settings or the offset has changed, re-evaluate trigger condition and raise interrupt if necess...
bool contains(const Addr &a) const
Determine if the range contains an address.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const Addr TIMER_CNTEL0ACR
uint32_t timerValue() const
Returns the TimerValue view of the timer.
void deschedule(Event &event)
size_t activeFreqEntry() const
Returns the currently active frequency table entry.
static const Addr COUNTER_STATUS_CNTCV_HI
static const Addr COUNTER_STATUS_CNTCV_LO
void setOffset(uint64_t val)
const char *const miscRegName[]
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
Tick when() const
Get the time that the event is scheduled.
Tick _updateTick
Counter cycle start Tick when the counter status affecting its value has been updated.
const AddrRange timerCtrlRange
void updateTick(void)
Updates the update tick, normalizes to the lower cycle start tick.
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
void notify(void) override
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
const AddrRange counterCtrlRange
AddrRangeList addrRanges
All MMIO ranges GenericTimerFrame responds to.
void serialize(CheckpointOut &cp) const override
Serialize an object.
static bool validateAccessPerm(ArmSystem &sys, bool is_sec)
Validates an MMIO access permissions.
static const Addr TIMER_CNTPCT_LO
void schedNextEvent(EventStream &ev_stream, ArchTimer &timer)
Tick _period
Cached copy of the counter period (inverse of the frequency).
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
ArmISA::CNTHCTL cnthctl
Hypervisor control register.
@ Drained
Buffers drained, ready for serialization/handover.
std::vector< uint32_t > _freqTable
Frequency modes table with all possible frequencies for the counter.
void physEventStreamCallback()
void timerWrite(Addr addr, size_t size, uint64_t data, bool is_sec, bool to_el0)
DrainState
Object drain/handover states.
void setCompareValue(uint64_t val)
Sets the CompareValue view of the timer.
static const Addr TIMER_CTRL_CNTNSAR
void freqUpdateCallback()
Callback for the frequency update.
void enable()
Enables the counter after a CNTCR.EN == 1.
This device is the base class which all devices senstive to an address range inherit from.
void schedule(Event &event, Tick when)
static const Addr TIMER_CNTVOFF_HI
ThreadContext is the external interface to all thread state for anything outside of the CPU.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
static const Addr TIMER_CNTP_CVAL_HI
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
uint64_t counterStatusRead(Addr addr, size_t size) const
CNTReadBase (System counter status frame)
const GenericTimerParams * params() const
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
GenericTimer & parent
Generic Timer parent reference.
std::vector< GenericTimerFrame * > frames
Timer frame references.
static const Addr COUNTER_CTRL_CNTCV_HI
static const Addr TIMER_CNTP_CVAL_LO
void unserialize(CheckpointIn &cp) override
Unserialize an object.
static const Addr TIMER_CNTP_CTL
static const Addr TIMER_CNTV_TVAL
uint64_t compareValue() const
Returns the CompareValue view of the timer.
EventFunctionWrapper _freqUpdateEvent
Frequency update event handling.
void registerListener(SystemCounterListener *listener)
Called from System Counter Listeners to register.
void counterCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec)
void notify(void) override
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
bool valid() const
Determine if the range is valid.
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
SystemCounter(SystemCounterParams *const p)
GenericTimerMem(GenericTimerMemParams *const p)
static const Addr TIMER_CNTFRQ
RegVal readMiscReg(int misc_reg, unsigned cpu)
AddrRange RangeSize(Addr start, Addr size)
static void validateFrameRange(const AddrRange &range)
Validates a Generic Timer register frame address range.
#define UNSERIALIZE_OPT_SCALAR(scalar)
void serialize(CheckpointOut &cp) const override
Serialize an object.
EventFunctionWrapper event
CoreTimers & getTimers(int cpu_id)
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 value() const
Returns the value of the counter which this timer relies on.
uint64_t counterCtrlRead(Addr addr, size_t size, bool is_sec) const
CNTControlBase (System counter control frame)
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
static constexpr size_t MAX_FREQ_ENTRIES
Maximum architectural number of frequency table entries.
uint64_t value()
Updates and returns the counter value.
void notifyListeners(void) const
Notifies counting speed changes to listeners.
bool enabled() const
Indicates if the counter is enabled.
SystemCounter & _systemCounter
static const Addr TIMER_CNTVCT_HI
uint32_t control() const
Sets the control register.
static const Addr TIMER_CNTV_CVAL_HI
Abstract class for elements whose events depend on the counting speed of the System Counter.
static const Addr COUNTER_CTRL_CNTSR
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
bool _enabled
Indicates if the counter is enabled.
void setValue(uint64_t new_value)
Sets the value explicitly from writes to CNTCR.CNTCV.
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
bool active() const
True if interrupt pin is active, false otherwise.
uint8_t getAccessBits() const
Returns the access bits for this frame.
void counterLimitReached()
Called when the upcounter reaches the programmed value.
virtual const std::string name() const
size_t _activeFreqEntry
Currently selected entry in the table, its contents should match _freq.
void updateValue(void)
Updates the counter value.
static const Addr COUNTER_CTRL_CNTSCR
static const Addr TIMER_CNTVCT_LO
void drainResume() override
Resume execution after a successful drain.
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
ArmInterruptPin *const _interrupt
virtual bool scheduleEvents()
void setControl(uint32_t val)
Addr start() const
Get the start address of the range.
GenericTimer(GenericTimerParams *const p)
bool nonSecureAccess
Reports whether non-secure accesses are allowed to this frame.
const SimObjectParams * _params
Cached copy of the object parameters.
uint32_t cntfrq
System counter frequency as visible from this core.
static const Addr TIMER_CNTVOFF_LO
#define SERIALIZE_CONTAINER(member)
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.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
void serialize(CheckpointOut &cp) const override
Serialize an object.
Generic representation of an Arm interrupt pin.
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
bool hasNonSecureAccess() const
Indicates if non-secure accesses are allowed to this frame.
void setMiscReg(int misc_reg, RegVal val) override
Write to a system register belonging to this device.
uint64_t _value
Counter value (as specified in CNTCV).
std::ostream CheckpointOut
static const Addr TIMER_CTRL_CNTTIDR
void setGenericTimer(GenericTimer *generic_timer)
Sets the pointer to the Generic Timer.
CoreTimers(GenericTimer &_parent, ArmSystem &system, unsigned cpu, ArmInterruptPin *_irqPhysS, ArmInterruptPin *_irqPhysNS, ArmInterruptPin *_irqVirt, ArmInterruptPin *_irqHyp)
uint64_t _offset
Offset relative to the physical timer (CNTVOFF)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static constexpr Addr PageBytes
void serialize(CheckpointOut &cp) const override
Serialize an object.
EventFunctionWrapper _counterLimitReachedEvent
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
SystemCounter & systemCounter
System counter reference.
uint64_t getVirtOffset() const
Returns the virtual offset for this frame if a virtual timer is implemented.
static const Addr TIMER_CTRL_CNTACR
void setNonSecureAccess()
Allows non-secure accesses after an enabling write to CNTCTLBase.CNTNSAR.
uint64_t _counterLimit
Programmed limit value for the upcounter ({CNTP/CNTHP/CNTV}_CVAL).
void virtEventStreamCallback()
void createTimers(unsigned cpus)
GenericTimerFrame(GenericTimerFrameParams *const p)
std::string csprintf(const char *format, const Args &...args)
Tick whenValue(uint64_t target_val)
static const Addr TIMER_CTRL_CNTVOFF_HI
void setMiscReg(int misc_reg, unsigned cpu, RegVal val)
void setAccessBits(uint8_t data)
Updates the access bits after a write to CNTCTLBase.CNTACR.
uint64_t timerCtrlRead(Addr addr, size_t size, bool is_sec) const
CNTCTLBase (Memory-mapped timer global control frame)
static const Addr TIMER_CNTV_CTL
static const Addr TIMER_CTRL_CNTFRQ
void freqUpdateSchedule(size_t new_freq_entry)
Schedules a counter frequency update after a CNTCR.FCREQ == 1 This complies with frequency transition...
#define panic(...)
This implements a cprintf based panic() function.
std::vector< uint32_t > & freqTable()
Returns a reference to the frequency modes table.
static const Addr TIMER_CNTV_CVAL_LO
Tick curTick()
The current simulated tick.
const AddrRangeList addrRanges
All MMIO ranges GenericTimerMem responds to.
std::vector< std::unique_ptr< CoreTimers > > timers
Per-CPU physical architected timers.
SystemCounter & systemCounter
System counter reference.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Abstract superclass for simulation objects.
static const Addr TIMER_CNTPCT_HI
static const Addr COUNTER_CTRL_CNTFID
Generated on Wed Sep 30 2020 14:02:10 for gem5 by doxygen 1.8.17