Go to the documentation of this file.
47 #include "debug/Timer.hh"
50 #include "params/GenericTimer.hh"
51 #include "params/GenericTimerFrame.hh"
52 #include "params/GenericTimerMem.hh"
53 #include "params/SystemCounter.hh"
69 "frequency not provided\n");
73 "SystemCounter::SystemCounter: Architecture states a maximum of 1004 "
74 "frequency table entries, limit surpassed\n");
83 fatal_if(!sys_cnt,
"SystemCounter::validateCounterRef: No valid system "
84 "counter, can't instantiate system timers\n");
90 DPRINTF(Timer,
"SystemCounter::enable: Counter enabled\n");
98 DPRINTF(Timer,
"SystemCounter::disable: Counter disabled\n");
126 warn(
"Explicit value set with counter enabled, UNKNOWNN result\n");
136 if (target_val > cur_val) {
137 uint64_t num_cycles =
138 std::ceil((target_val - cur_val) / ((
double)
_increment));
167 if (new_freq !=
_freq) {
173 uint64_t target_val =
value();
174 target_val += target_val % std::max(
_increment, new_incr);
183 DPRINTF(Timer,
"SystemCounter::freqUpdateCallback: Changing counter "
210 DPRINTF(Timer,
"SystemCounter::serialize: Serializing\n");
220 if (pending_freq_update) {
230 DPRINTF(Timer,
"SystemCounter::unserialize: Unserializing\n");
238 bool pending_freq_update;
240 if (pending_freq_update) {
241 Tick when_freq_update;
254 : _name(
name), _parent(parent), _systemCounter(sysctr),
255 _interrupt(interrupt),
256 _control(0), _counterLimit(0), _offset(0),
259 _systemCounter.registerListener(
this);
268 DPRINTF(Timer,
"Counter limit reached\n");
272 DPRINTF(Timer,
"Causing interrupt\n");
275 DPRINTF(Timer,
"Kvm mode; skipping simulated interrupt\n");
290 DPRINTF(Timer,
"Clearing interrupt\n");
324 if ((old_ctl.imask && !new_ctl.imask) ||
325 (!old_ctl.enable && new_ctl.enable))
328 else if ((!old_ctl.imask && new_ctl.imask) ||
329 (old_ctl.enable && !new_ctl.enable)) {
332 DPRINTF(Timer,
"Clearing interrupt\n");
402 systemCounter(*
p.counter),
406 fatal_if(!
p.system,
"GenericTimer::GenericTimer: No system specified, "
407 "can't instantiate architected timers\n");
416 for (
int i = 0;
i <
timers.size(); ++
i) {
428 static const unsigned OLD_CPU_MAX = 8;
431 warn(
"Checkpoint does not contain CPU count, assuming %i CPUs\n",
433 cpu_count = OLD_CPU_MAX;
441 fatal(
"The simulated system has been initialized with %d CPUs, "
442 "but the Generic Timer checkpoint expects %d CPUs. Consider "
443 "restoring the checkpoint specifying %d CPUs.",
447 for (
int i = 0;
i < cpu_count; ++
i) {
456 if (cpu_id >=
timers.size())
465 assert(
timers.size() < cpus);
468 const unsigned old_cpu_count(
timers.size());
470 for (
unsigned i = old_cpu_count;
i < cpus; ++
i) {
476 p.int_phys_s->get(tc),
477 p.int_phys_ns->get(tc),
479 p.int_hyp->get(tc)));
488 uint64_t old_evnten =
bits(old_cnt_ctl, 2);
502 }
else if (old_evnten && !
evnten) {
520 "does not match the system counter freq\n");
571 warn(
"Ignoring write to read only count register: %s\n",
646 return core.
cntkctl & 0x00000000ffffffff;
649 return core.
cnthctl & 0x00000000ffffffff;
726 cntfrq(parent.params().cntfrq),
727 threadContext(
system.threads[cpu]),
729 irqPhysNS(_irqPhysNS),
732 physS(
csprintf(
"%s.phys_s_timer%d", parent.
name(), cpu),
733 system, parent, parent.systemCounter,
738 system, parent, parent.systemCounter,
741 system, parent, parent.systemCounter,
744 system, parent, parent.systemCounter,
752 csprintf(
"%s.virt_event_gen%d", parent.name(), cpu)), 0, 0
760 eventStreamCallback();
761 schedNextEvent(physEvStream, physNS);
767 eventStreamCallback();
768 schedNextEvent(virtEvStream, virt);
775 threadContext->getCpuPtr()->wakeup(threadContext->threadId());
789 schedNextEvent(virtEvStream, virt);
790 schedNextEvent(physEvStream, physNS);
800 const bool phys_ev_scheduled = physEvStream.event.scheduled();
802 if (phys_ev_scheduled) {
803 const Tick phys_ev_when = physEvStream.event.when();
809 const bool virt_ev_scheduled = virtEvStream.event.scheduled();
811 if (virt_ev_scheduled) {
812 const Tick virt_ev_when = virtEvStream.event.when();
818 physS.serializeSection(
cp,
"phys_s_timer");
819 physNS.serializeSection(
cp,
"phys_ns_timer");
820 virt.serializeSection(
cp,
"virt_timer");
821 hyp.serializeSection(
cp,
"hyp_timer");
831 bool phys_ev_scheduled;
833 if (phys_ev_scheduled) {
836 parent.reschedule(physEvStream.event, phys_ev_when,
true);
841 bool virt_ev_scheduled;
843 if (virt_ev_scheduled) {
846 parent.reschedule(virtEvStream.event, virt_ev_when,
true);
851 physS.unserializeSection(
cp,
"phys_s_timer");
852 physNS.unserializeSection(
cp,
"phys_ns_timer");
853 virt.unserializeSection(
cp,
"virt_timer");
854 hyp.unserializeSection(
cp,
"hyp_timer");
861 parent.setMiscReg(
reg, cpu,
val);
867 RegVal value = parent.readMiscReg(
reg, cpu);
876 systemCounter(*
p.counter),
878 *
this, systemCounter,
p.int_phys->get()),
880 *
this, systemCounter,
889 accessBitsEl0 = 0x303;
890 addrRanges.push_back(timerEl0Range);
892 for (
auto &range : addrRanges)
947 accessBits =
data & 0x3f;
965 return accessBits.rvoff;
978 const size_t size = pkt->
getSize();
979 const bool is_sec = pkt->
isSecure();
981 "GenericTimerFrame::read: Invalid size %i\n", size);
992 panic(
"GenericTimerFrame::read: Invalid address: 0x%x\n",
addr);
997 DPRINTF(Timer,
"GenericTimerFrame::read: 0x%x<-0x%x(%i) [S = %u]\n", resp,
1000 pkt->
setUintX(resp, ByteOrder::little);
1009 const size_t size = pkt->
getSize();
1010 const bool is_sec = pkt->
isSecure();
1012 "GenericTimerFrame::write: Invalid size %i\n", size);
1014 bool to_el0 =
false;
1015 const uint64_t
data = pkt->
getUintX(ByteOrder::little);
1023 panic(
"GenericTimerFrame::write: Invalid address: 0x%x\n",
addr);
1028 DPRINTF(Timer,
"GenericTimerFrame::write: 0x%x->0x%x(%i) [S = %u]\n",
data,
1029 addr, size, is_sec);
1045 if (!accessBits.rpct || (to_el0 && !accessBitsEl0.pcten))
1051 if (!accessBits.rpct || (to_el0 && !accessBitsEl0.pcten))
1057 if ((!accessBits.rfrq) ||
1058 (to_el0 && (!accessBitsEl0.pcten && !accessBitsEl0.vcten)))
1067 return accessBitsEl0;
1070 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1076 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1082 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1087 if (!accessBits.rwpt || (to_el0 && !accessBitsEl0.pten))
1093 if (!accessBits.rvct || (to_el0 && !accessBitsEl0.vcten))
1099 if (!accessBits.rvct || (to_el0 && !accessBitsEl0.vcten))
1105 if (!accessBits.rvoff || (to_el0))
1111 if (!accessBits.rvoff || (to_el0))
1117 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1123 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1129 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1135 if (!accessBits.rwvt || (to_el0 && !accessBitsEl0.vten))
1141 warn(
"GenericTimerFrame::timerRead: Unexpected address (0x%x:%i), "
1142 "assuming RAZ\n",
addr, size);
1149 bool is_sec,
bool to_el0)
1157 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTPCT]\n",
1162 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTFRQ]\n",
1175 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1183 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1190 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1196 if ((!accessBits.rwpt) || (to_el0 && !accessBitsEl0.pten))
1202 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTVCT]\n",
1206 warn(
"GenericTimerFrame::timerWrite: RO reg (0x%x) [CNTVOFF]\n",
1211 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1219 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1226 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1232 if ((!accessBits.rwvt) || (to_el0 && !accessBitsEl0.vten))
1238 warn(
"GenericTimerFrame::timerWrite: Unexpected address (0x%x:%i), "
1239 "assuming WI\n",
addr, size);
1250 systemCounter(*
p.counter),
1255 for (
auto &range : addrRanges)
1257 fatal_if(frames.size() > MAX_TIMER_FRAMES,
1258 "GenericTimerMem::GenericTimerMem: Architecture states a maximum of "
1259 "8 memory-mapped timer frames, limit surpassed\n");
1261 for (
int i = 0;
i < frames.size();
i++) {
1262 uint32_t features = 0x1;
1264 if (frames[
i]->hasEl0View())
1275 "GenericTimerMem::validateFrameRange: Architecture states each "
1276 "register frame should be in a separate memory page, specified "
1277 "range base address [0x%x] is not compliant\n");
1283 return !
sys.haveSecurity() || is_sec;
1296 const size_t size = pkt->
getSize();
1297 const bool is_sec = pkt->
isSecure();
1299 "GenericTimerMem::read: Invalid size %i\n", size);
1309 panic(
"GenericTimerMem::read: Invalid address: 0x%x\n",
addr);
1311 DPRINTF(Timer,
"GenericTimerMem::read: 0x%x<-0x%x(%i) [S = %u]\n", resp,
1312 addr, size, is_sec);
1314 pkt->
setUintX(resp, ByteOrder::little);
1323 const size_t size = pkt->
getSize();
1324 const bool is_sec = pkt->
isSecure();
1326 "GenericTimerMem::write: Invalid size %i\n", size);
1328 const uint64_t
data = pkt->
getUintX(ByteOrder::little);
1336 panic(
"GenericTimerMem::write: Invalid address: 0x%x\n",
addr);
1338 DPRINTF(Timer,
"GenericTimerMem::write: 0x%x->0x%x(%i) [S = %u]\n",
data,
1339 addr, size, is_sec);
1351 case COUNTER_CTRL_CNTCR:
1371 for (
int i = 0;
i < (freq_table.size() - 1);
i++) {
1374 return freq_table[
i];
1376 warn(
"GenericTimerMem::counterCtrlRead: Unexpected address "
1377 "(0x%x:%i), assuming RAZ\n",
addr, size);
1391 case COUNTER_CTRL_CNTCR:
1400 warn(
"GenericTimerMem::counterCtrlWrite: Halt-on-debug is not "
1403 warn(
"GenericTimerMem::counterCtrlWrite: Counter Scaling is not "
1411 warn(
"GenericTimerMem::counterCtrlWrite: RO reg (0x%x) [CNTSR]\n",
1430 warn(
"GenericTimerMem::counterCtrlWrite: RO reg (0x%x) [CNTID]\n",
1437 for (
int i = 0;
i < (freq_table.size() - 1);
i++) {
1440 freq_table[
i] =
data;
1451 warn(
"GenericTimerMem::counterCtrlWrite: Unexpected address "
1452 "(0x%x:%i), assuming WI\n",
addr, size);
1464 warn(
"GenericTimerMem::counterStatusRead: Unexpected address "
1465 "(0x%x:%i), assuming RAZ\n",
addr, size);
1475 warn(
"GenericTimerMem::counterStatusWrite: RO reg (0x%x) [CNTCV]\n",
1479 warn(
"GenericTimerMem::counterStatusWrite: Unexpected address "
1480 "(0x%x:%i), assuming WI\n",
addr, size);
1494 uint32_t cntnsar = 0x0;
1495 for (
int i = 0;
i <
frames.size();
i++) {
1496 if (
frames[
i]->hasNonSecureAccess())
1497 cntnsar |= 0x1 <<
i;
1503 for (
int i = 0;
i <
frames.size();
i++) {
1509 bool hit =
addr == cntacr_off ||
addr == cntvoff_lo_off ||
1510 addr == cntvoff_hi_off;
1513 frames[
i]->hasNonSecureAccess();
1514 if (hit && !has_access)
return 0;
1515 if (
addr == cntacr_off)
1516 return frames[
i]->getAccessBits();
1517 if (
addr == cntvoff_lo_off ||
addr == cntvoff_hi_off) {
1518 return addr == cntvoff_lo_off ?
frames[
i]->getVirtOffset()
1519 :
frames[
i]->getVirtOffset() >> 32;
1522 warn(
"GenericTimerMem::timerCtrlRead: Unexpected address (0x%x:%i), "
1523 "assuming RAZ\n",
addr, size);
1536 "GenericTimerMem::timerCtrlWrite: CNTFRQ configured freq "
1537 "does not match the counter freq, ignoring\n");
1541 for (
int i = 0;
i <
frames.size();
i++) {
1543 if (
data & (0x1 <<
i))
1544 frames[
i]->setNonSecureAccess();
1548 warn(
"GenericTimerMem::timerCtrlWrite: RO reg (0x%x) [CNTTIDR]\n",
1552 for (
int i = 0;
i <
frames.size();
i++) {
1558 bool hit =
addr == cntacr_off ||
addr == cntvoff_lo_off ||
1559 addr == cntvoff_hi_off;
1562 frames[
i]->hasNonSecureAccess();
1563 if (hit && !has_access)
return;
1564 if (
addr == cntacr_off) {
1568 if (
addr == cntvoff_lo_off ||
addr == cntvoff_hi_off) {
1569 if (
addr == cntvoff_lo_off)
1579 warn(
"GenericTimerMem::timerCtrlWrite: Unexpected address "
1580 "(0x%x:%i), assuming WI\n",
addr, size);
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.
constexpr T insertBits(T val, unsigned first, unsigned last, B bit_val)
Returns val with bits first to last set to the LSBs of bit_val.
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.
GenericTimer(const Params &p)
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 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.
SystemCounter(const SystemCounterParams &p)
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)
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...
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
GenericTimerFrame(const GenericTimerFrameParams &p)
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)
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
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.
GenericTimerMem(const GenericTimerMemParams &p)
bool nonSecureAccess
Reports whether non-secure accesses are allowed to this frame.
uint32_t cntfrq
System counter frequency as visible from this core.
static const Addr TIMER_CNTVOFF_LO
#define SERIALIZE_CONTAINER(member)
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
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).
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
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 curTick()
The universal simulation clock.
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.
const Params & params() const
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.
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
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)
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.
constexpr void replaceBits(T &val, unsigned first, unsigned last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
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
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.
Abstract superclass for simulation objects.
static const Addr TIMER_CNTPCT_HI
static const Addr COUNTER_CTRL_CNTFID
Generated on Tue Mar 23 2021 19:41:25 for gem5 by doxygen 1.8.17