gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
generic_timer.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013, 2015, 2017-2018,2020,2022 Arm Limited
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef __DEV_ARM_GENERIC_TIMER_HH__
39#define __DEV_ARM_GENERIC_TIMER_HH__
40
41#include <cstdint>
42#include <vector>
43
45#include "arch/arm/system.hh"
46#include "base/addr_range.hh"
47#include "base/bitunion.hh"
48#include "base/types.hh"
49#include "dev/arm/base_gic.hh"
51#include "sim/drain.hh"
52#include "sim/eventq.hh"
53#include "sim/serialize.hh"
54#include "sim/sim_object.hh"
55
64
65namespace gem5
66{
67
68class Checkpoint;
69struct SystemCounterParams;
70struct GenericTimerParams;
71struct GenericTimerFrameParams;
72struct GenericTimerMemParams;
73
77{
78 public:
81 virtual void notify(void) = 0;
82 virtual ~SystemCounterListener() = default;
83};
84
88{
89 protected:
93 uint32_t _freq;
95 uint64_t _value;
97 uint64_t _increment;
107
110
112 static constexpr size_t MAX_FREQ_ENTRIES = 1004;
113
114 public:
115 SystemCounter(const SystemCounterParams &p);
116
119 static void validateCounterRef(SystemCounter *sys_cnt);
120
122 bool enabled() const { return _enabled; }
124 uint32_t freq() const { return _freq; }
126 uint64_t value();
128 uint64_t increment() const { return _increment; }
132 size_t activeFreqEntry() const { return _activeFreqEntry; }
134 Tick period() const { return _period; }
135
137 void enable();
139 void disable();
140
144 void freqUpdateSchedule(size_t new_freq_entry);
145
147 void setValue(uint64_t new_value);
148
151
153 Tick whenValue(uint64_t target_val);
154 Tick whenValue(uint64_t cur_val, uint64_t target_val) const;
155
156 void serialize(CheckpointOut &cp) const override;
157 void unserialize(CheckpointIn &cp) override;
158
159 private:
160 // Disable copying
162
167 void freqUpdateCallback();
168
170 void updateValue(void);
171
173 void updateTick(void);
174
176 void notifyListeners(void) const;
177};
178
181 public Serializable
182{
183 protected:
185 BitUnion32(ArchTimerCtrl)
186 Bitfield<0> enable;
187 Bitfield<1> imask;
188 Bitfield<2> istatus;
189 EndBitUnion(ArchTimerCtrl)
190
191
192 const std::string _name;
193
196
198
200
202 ArchTimerCtrl _control;
206 uint64_t _offset;
207
212 void updateCounter();
213
215 void counterLimitReached();
217
218 virtual bool scheduleEvents() { return true; }
219
220 public:
221 ArchTimer(const std::string &name,
222 SimObject &parent,
223 SystemCounter &sysctr,
224 ArmInterruptPin *interrupt);
225
227 std::string name() const { return _name; }
228
230 uint64_t compareValue() const { return _counterLimit; }
232 void setCompareValue(uint64_t val);
233
235 uint32_t timerValue() const { return _counterLimit - value(); }
237 void setTimerValue(uint32_t val);
238
240 uint32_t control() const { return _control; }
241 void setControl(uint32_t val);
242
243 uint64_t offset() const { return _offset; }
244 void setOffset(uint64_t val);
245
247 uint64_t value() const;
248 Tick whenValue(uint64_t target_val) {
249 return _systemCounter.whenValue(value(), target_val);
250 }
251
252 void notify(void) override;
253
254 // Serializable
255 void serialize(CheckpointOut &cp) const override;
256 void unserialize(CheckpointIn &cp) override;
257
258 // Drainable
259 DrainState drain() override;
260 void drainResume() override;
261
262 private:
263 // Disable copying
265};
266
268{
269 private:
271
272 public:
273 ArchTimerKvm(const std::string &name,
275 SimObject &parent,
276 SystemCounter &sysctr,
277 ArmInterruptPin *interrupt)
278 : ArchTimer(name, parent, sysctr, interrupt), system(system) {}
279
280 protected:
281 // For ArchTimer's in a GenericTimerISA with Kvm execution about
282 // to begin, skip rescheduling the event.
283 // Otherwise, we should reschedule the event (if necessary).
284 bool scheduleEvents() override;
285};
286
288{
289 public:
291
292 GenericTimer(const Params &p);
293
294 void serialize(CheckpointOut &cp) const override;
295 void unserialize(CheckpointIn &cp) override;
296
297 public:
298 void setMiscReg(int misc_reg, unsigned cpu, RegVal val);
299 RegVal readMiscReg(int misc_reg, unsigned cpu);
300
301 protected:
303 {
304 public:
305 CoreTimers(GenericTimer &_parent, ArmSystem &system, unsigned cpu,
306 ArmInterruptPin *irq_el3_phys,
307 ArmInterruptPin *irq_el1_phys,
308 ArmInterruptPin *irq_el1_virt,
309 ArmInterruptPin *irq_el2_ns_phys,
310 ArmInterruptPin *irq_el2_ns_virt,
311 ArmInterruptPin *irq_el2_s_phys,
312 ArmInterruptPin *irq_el2_s_virt);
313
316
318 uint32_t cntfrq;
319
321 ArmISA::CNTKCTL cntkctl;
322
324 ArmISA::CNTHCTL cnthctl;
325
328
336
344
345 // Event Stream. Events are generated based on a configurable
346 // transitionBit over the counter value. transitionTo indicates
347 // the transition direction (0->1 or 1->0)
349 {
353
354 uint64_t
355 eventTargetValue(uint64_t val) const
356 {
357 uint64_t bit_val = bits(val, transitionBit);
358 uint64_t ret_val = mbits(val, 63, transitionBit);
359 uint64_t incr_val = 1 << transitionBit;
360 if (bit_val == transitionTo)
361 incr_val *= 2;
362 return ret_val + incr_val;
363 }
364 };
365
370 void eventStreamCallback() const;
371 void schedNextEvent(EventStream &ev_stream, ArchTimer &timer);
372
373 void notify(void) override;
374
375 void serialize(CheckpointOut &cp) const override;
376 void unserialize(CheckpointIn &cp) override;
377
378 private:
379 // Disable copying
381 };
382
383 CoreTimers &getTimers(int cpu_id);
384 void createTimers(unsigned cpus);
385
388
391
392 protected: // Configuration
395
397 ArchTimer *timer, RegVal old_cnt_ctl, RegVal cnt_ctl);
398};
399
401{
402 public:
403 GenericTimerISA(GenericTimer &_parent, unsigned _cpu)
404 : parent(_parent), cpu(_cpu) {}
405
406 void setMiscReg(int misc_reg, RegVal val) override;
407 RegVal readMiscReg(int misc_reg) override;
408
409 protected:
411 unsigned cpu;
412};
413
415{
416 public:
417 GenericTimerFrame(const GenericTimerFrameParams &p);
418
419 void serialize(CheckpointOut &cp) const override;
420 void unserialize(CheckpointIn &cp) override;
421
423 bool hasVirtualTimer() const;
424
427 uint64_t getVirtOffset() const;
428
431 void setVirtOffset(uint64_t new_offset);
432
434 bool hasEl0View() const;
435
437 uint8_t getAccessBits() const;
438
440 void setAccessBits(uint8_t data);
441
443 bool hasNonSecureAccess() const;
444
447 void setNonSecureAccess();
448
450 bool hasReadableVoff() const;
451
452 protected:
453 AddrRangeList getAddrRanges() const override;
454 Tick read(PacketPtr pkt) override;
455 Tick write(PacketPtr pkt) override;
456
457 private:
459 uint64_t timerRead(Addr addr, size_t size, bool is_sec, bool to_el0) const;
460 void timerWrite(Addr addr, size_t size, uint64_t data, bool is_sec,
461 bool to_el0);
464
465 static const Addr TIMER_CNTPCT_LO = 0x00;
466 static const Addr TIMER_CNTPCT_HI = 0x04;
467 static const Addr TIMER_CNTVCT_LO = 0x08;
468 static const Addr TIMER_CNTVCT_HI = 0x0c;
469 static const Addr TIMER_CNTFRQ = 0x10;
470 static const Addr TIMER_CNTEL0ACR = 0x14;
471 static const Addr TIMER_CNTVOFF_LO = 0x18;
472 static const Addr TIMER_CNTVOFF_HI = 0x1c;
473 static const Addr TIMER_CNTP_CVAL_LO = 0x20;
474 static const Addr TIMER_CNTP_CVAL_HI = 0x24;
475 static const Addr TIMER_CNTP_TVAL = 0x28;
476 static const Addr TIMER_CNTP_CTL = 0x2c;
477 static const Addr TIMER_CNTV_CVAL_LO = 0x30;
478 static const Addr TIMER_CNTV_CVAL_HI = 0x34;
479 static const Addr TIMER_CNTV_TVAL = 0x38;
480 static const Addr TIMER_CNTV_CTL = 0x3c;
481
484
487
491
493 BitUnion8(AccessBits)
494 Bitfield<5> rwpt;
495 Bitfield<4> rwvt;
496 Bitfield<3> rvoff;
497 Bitfield<2> rfrq;
498 Bitfield<1> rvct;
499 Bitfield<0> rpct;
500 EndBitUnion(AccessBits)
501 AccessBits accessBits;
502
503 // Reports access properties of the CNTEL0Base register frame elements
504 BitUnion16(AccessBitsEl0)
505 Bitfield<9> pten;
506 Bitfield<8> vten;
507 Bitfield<1> vcten;
508 Bitfield<0> pcten;
509 EndBitUnion(AccessBitsEl0)
510 AccessBitsEl0 accessBitsEl0;
511
514
516};
517
519{
520 public:
521 GenericTimerMem(const GenericTimerMemParams &p);
522
525 static void validateFrameRange(const AddrRange &range);
526
530 static bool validateAccessPerm(ArmSystem &sys, bool is_sec);
531
532 protected:
533 AddrRangeList getAddrRanges() const override;
534 Tick read(PacketPtr pkt) override;
535 Tick write(PacketPtr pkt) override;
536
537 private:
539 uint64_t counterCtrlRead(Addr addr, size_t size, bool is_sec) const;
540 void counterCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec);
542
544 Bitfield<17,8> fcreq;
545 Bitfield<2> scen;
546 Bitfield<1> hdbg;
547 Bitfield<0> en;
549
550 BitUnion32(CNTSR)
551 Bitfield<31,8> fcack;
553
554 static const Addr COUNTER_CTRL_CNTCR = 0x00;
555 static const Addr COUNTER_CTRL_CNTSR = 0x04;
556 static const Addr COUNTER_CTRL_CNTCV_LO = 0x08;
557 static const Addr COUNTER_CTRL_CNTCV_HI = 0x0c;
558 static const Addr COUNTER_CTRL_CNTSCR = 0x10;
559 static const Addr COUNTER_CTRL_CNTID = 0x1c;
560 static const Addr COUNTER_CTRL_CNTFID = 0x20;
561
563 uint64_t counterStatusRead(Addr addr, size_t size) const;
564 void counterStatusWrite(Addr addr, size_t size, uint64_t data);
566
567 static const Addr COUNTER_STATUS_CNTCV_LO = 0x00;
568 static const Addr COUNTER_STATUS_CNTCV_HI = 0x04;
569
571 uint64_t timerCtrlRead(Addr addr, size_t size, bool is_sec) const;
572 void timerCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec);
574
576 uint32_t cnttidr;
577
578 static const Addr TIMER_CTRL_CNTFRQ = 0x00;
579 static const Addr TIMER_CTRL_CNTNSAR = 0x04;
580 static const Addr TIMER_CTRL_CNTTIDR = 0x08;
581 static const Addr TIMER_CTRL_CNTACR = 0x40;
582 static const Addr TIMER_CTRL_CNTVOFF_LO = 0x80;
583 static const Addr TIMER_CTRL_CNTVOFF_HI = 0x84;
584
587
590
592 static constexpr size_t MAX_TIMER_FRAMES = 8;
593
596
598};
599
600} // namespace gem5
601
602#endif // __DEV_ARM_GENERIC_TIMER_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Base class for ARM GIC implementations.
const char data[]
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
ArchTimerKvm(const std::string &name, ArmSystem &system, SimObject &parent, SystemCounter &sysctr, ArmInterruptPin *interrupt)
bool scheduleEvents() override
Per-CPU architected timer.
EventFunctionWrapper _counterLimitReachedEvent
void setTimerValue(uint32_t val)
Sets the TimerValue view of the timer.
uint32_t timerValue() const
Returns the TimerValue view of the timer.
Bitfield< 1 > imask
virtual bool scheduleEvents()
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
EndBitUnion(ArchTimerCtrl) const std SimObject & _parent
Name of this timer.
std::string name() const
Returns the timer name.
void drainResume() override
Resume execution after a successful drain.
uint64_t compareValue() const
Returns the CompareValue view of the timer.
Bitfield< 2 > istatus
uint64_t _offset
Offset relative to the physical timer (CNTVOFF)
void notify(void) override
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
void setCompareValue(uint64_t val)
Sets the CompareValue view of the timer.
ArchTimer(const std::string &name, SimObject &parent, SystemCounter &sysctr, ArmInterruptPin *interrupt)
ArchTimerCtrl _control
Value of the control register ({CNTP/CNTHP/CNTV}_CTL).
void setOffset(uint64_t val)
void serialize(CheckpointOut &cp) const override
Serialize an object.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t value() const
Returns the value of the counter which this timer relies on.
void setControl(uint32_t val)
uint32_t control() const
Sets the control register.
void updateCounter()
Timer settings or the offset has changed, re-evaluate trigger condition and raise interrupt if necess...
ArchTimer(const ArchTimer &t)
BitUnion32(ArchTimerCtrl) Bitfield< 0 > enable
Control register.
SystemCounter & _systemCounter
void counterLimitReached()
Called when the upcounter reaches the programmed value.
uint64_t offset() const
ArmInterruptPin *const _interrupt
uint64_t _counterLimit
Programmed limit value for the upcounter ({CNTP/CNTHP/CNTV}_CVAL).
Tick whenValue(uint64_t target_val)
Base class for devices that use the MiscReg interfaces.
Definition isa_device.hh:62
Generic representation of an Arm interrupt pin.
Definition base_gic.hh:200
GenericTimerFrame(const GenericTimerFrameParams &p)
static const Addr TIMER_CNTP_CTL
void serialize(CheckpointOut &cp) const override
Serialize an object.
static const Addr TIMER_CNTV_TVAL
bool nonSecureAccess
Reports whether non-secure accesses are allowed to this frame.
bool hasVirtualTimer() const
Indicates if this frame implements a virtual timer.
uint64_t timerRead(Addr addr, size_t size, bool is_sec, bool to_el0) const
CNTBase/CNTEL0Base (Memory-mapped timer frame)
bool hasEl0View() const
Indicates if this frame implements a second EL0 view.
static const Addr TIMER_CNTP_CVAL_HI
void unserialize(CheckpointIn &cp) override
Unserialize an object.
BitUnion8(AccessBits) Bitfield< 5 > rwpt
Reports access properties of the CNTBase register frame elements.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const Addr TIMER_CNTV_CVAL_LO
static const Addr TIMER_CNTVCT_LO
uint8_t getAccessBits() const
Returns the access bits for this frame.
static const Addr TIMER_CNTFRQ
SystemCounter & systemCounter
System counter reference.
bool hasNonSecureAccess() const
Indicates if non-secure accesses are allowed to this frame.
ArchTimer physTimer
Physical and virtual timers.
BitUnion16(AccessBitsEl0) Bitfield< 9 > pten
static const Addr TIMER_CNTP_CVAL_LO
void setAccessBits(uint8_t data)
Updates the access bits after a write to CNTCTLBase.CNTACR.
static const Addr TIMER_CNTV_CVAL_HI
void setVirtOffset(uint64_t new_offset)
Sets the virtual offset for this frame's virtual timer after a write to CNTVOFF.
const AddrRange timerRange
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_CNTP_TVAL
static const Addr TIMER_CNTVOFF_HI
static const Addr TIMER_CNTVCT_HI
AddrRangeList addrRanges
All MMIO ranges GenericTimerFrame responds to.
bool hasReadableVoff() const
Indicates if CNTVOFF is readable for this frame.
static const Addr TIMER_CNTPCT_LO
static const Addr TIMER_CNTVOFF_LO
static const Addr TIMER_CNTPCT_HI
EndBitUnion(AccessBits) AccessBits accessBits
uint64_t getVirtOffset() const
Returns the virtual offset for this frame if a virtual timer is implemented.
static const Addr TIMER_CNTEL0ACR
EndBitUnion(AccessBitsEl0) AccessBitsEl0 accessBitsEl0
void setNonSecureAccess()
Allows non-secure accesses after an enabling write to CNTCTLBase.CNTNSAR.
static const Addr TIMER_CNTV_CTL
void timerWrite(Addr addr, size_t size, uint64_t data, bool is_sec, bool to_el0)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
RegVal readMiscReg(int misc_reg) override
Read a system register belonging to this device.
GenericTimerISA(GenericTimer &_parent, unsigned _cpu)
void setMiscReg(int misc_reg, RegVal val) override
Write to a system register belonging to this device.
void counterCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec)
static const Addr COUNTER_CTRL_CNTID
BitUnion32(CNTCR) Bitfield< 17
uint64_t counterCtrlRead(Addr addr, size_t size, bool is_sec) const
CNTControlBase (System counter control frame)
const AddrRange timerCtrlRange
static const Addr TIMER_CTRL_CNTTIDR
static const Addr COUNTER_CTRL_CNTCV_HI
static const Addr COUNTER_CTRL_CNTFID
EndBitUnion(CNTCR) BitUnion32(CNTSR) Bitfield< 31
GenericTimerMem(const GenericTimerMemParams &p)
static const Addr COUNTER_CTRL_CNTCV_LO
void counterStatusWrite(Addr addr, size_t size, uint64_t data)
std::vector< GenericTimerFrame * > frames
Timer frame references.
static const Addr TIMER_CTRL_CNTFRQ
static const Addr COUNTER_STATUS_CNTCV_HI
static const Addr COUNTER_CTRL_CNTSCR
const AddrRange counterStatusRange
static const Addr TIMER_CTRL_CNTACR
uint64_t timerCtrlRead(Addr addr, size_t size, bool is_sec) const
CNTCTLBase (Memory-mapped timer global control frame)
const AddrRange counterCtrlRange
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const Addr TIMER_CTRL_CNTVOFF_LO
static void validateFrameRange(const AddrRange &range)
Validates a Generic Timer register frame address range.
uint64_t counterStatusRead(Addr addr, size_t size) const
CNTReadBase (System counter status frame)
static const Addr COUNTER_STATUS_CNTCV_LO
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
void timerCtrlWrite(Addr addr, size_t size, uint64_t data, bool is_sec)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
uint32_t cnttidr
ID register for reporting features of implemented timer frames.
static const Addr COUNTER_CTRL_CNTSR
SystemCounter & systemCounter
System counter reference.
const AddrRangeList addrRanges
All MMIO ranges GenericTimerMem responds to.
static constexpr size_t MAX_TIMER_FRAMES
Maximum architectural number of memory-mapped timer frames.
static const Addr TIMER_CTRL_CNTNSAR
static bool validateAccessPerm(ArmSystem &sys, bool is_sec)
Validates an MMIO access permissions.
static const Addr TIMER_CTRL_CNTVOFF_HI
ThreadContext * threadContext
Thread (HW) context associated to this PE implementation.
ArmInterruptPin const * irqPhysNsEL2
GenericTimer & parent
Generic Timer parent reference.
ArmInterruptPin const * irqVirtSEL2
void notify(void) override
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
void serialize(CheckpointOut &cp) const override
Serialize an object.
void schedNextEvent(EventStream &ev_stream, ArchTimer &timer)
ArmInterruptPin const * irqVirtEL1
uint32_t cntfrq
System counter frequency as visible from this core.
ArmInterruptPin const * irqPhysEL3
ArmInterruptPin const * irqPhysSEL2
CoreTimers(const CoreTimers &c)
ArmInterruptPin const * irqVirtNsEL2
void unserialize(CheckpointIn &cp) override
Unserialize an object.
CoreTimers(GenericTimer &_parent, ArmSystem &system, unsigned cpu, ArmInterruptPin *irq_el3_phys, ArmInterruptPin *irq_el1_phys, ArmInterruptPin *irq_el1_virt, ArmInterruptPin *irq_el2_ns_phys, ArmInterruptPin *irq_el2_ns_virt, ArmInterruptPin *irq_el2_s_phys, ArmInterruptPin *irq_el2_s_virt)
ArmInterruptPin const * irqPhysEL1
ArmISA::CNTHCTL cnthctl
Hypervisor control register.
ArmISA::CNTKCTL cntkctl
Kernel control register.
std::vector< std::unique_ptr< CoreTimers > > timers
Per-CPU physical architected timers.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void setMiscReg(int misc_reg, unsigned cpu, RegVal val)
CoreTimers & getTimers(int cpu_id)
RegVal readMiscReg(int misc_reg, unsigned cpu)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void createTimers(unsigned cpus)
PARAMS(GenericTimer)
SystemCounter & systemCounter
System counter reference.
void handleStream(CoreTimers::EventStream *ev_stream, ArchTimer *timer, RegVal old_cnt_ctl, RegVal cnt_ctl)
ArmSystem & system
ARM system containing this timer.
GenericTimer(const Params &p)
PioDevice(const Params &p)
Definition io_device.cc:50
Abstract superclass for simulation objects.
SimObjectParams Params
Abstract class for elements whose events depend on the counting speed of the System Counter.
virtual void notify(void)=0
Called from the SystemCounter when a change in counting speed occurred Events should be rescheduled p...
virtual ~SystemCounterListener()=default
Global system counter.
void updateValue(void)
Updates the counter value.
uint32_t _freq
Counter frequency (as specified by CNTFRQ).
std::vector< uint32_t > _freqTable
Frequency modes table with all possible frequencies for the counter.
bool enabled() const
Indicates if the counter is enabled.
std::vector< SystemCounterListener * > _listeners
Listeners to changes in counting speed.
void setValue(uint64_t new_value)
Sets the value explicitly from writes to CNTCR.CNTCV.
Tick _period
Cached copy of the counter period (inverse of the frequency).
Tick whenValue(uint64_t target_val)
Returns the tick at which a certain counter value is reached.
SystemCounter(const SystemCounterParams &p)
EventFunctionWrapper _freqUpdateEvent
Frequency update event handling.
size_t activeFreqEntry() const
Returns the currently active frequency table entry.
static constexpr size_t MAX_FREQ_ENTRIES
Maximum architectural number of frequency table entries.
static void validateCounterRef(SystemCounter *sys_cnt)
Validates a System Counter reference.
void updateTick(void)
Updates the update tick, normalizes to the lower cycle start tick.
uint64_t value()
Updates and returns the counter value.
Tick period() const
Returns the counter period.
void disable()
Disables the counter after a CNTCR.EN == 0.
void notifyListeners(void) const
Notifies counting speed changes to listeners.
SystemCounter(const SystemCounter &c)
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::vector< uint32_t > & freqTable()
Returns a reference to the frequency modes table.
void enable()
Enables the counter after a CNTCR.EN == 1.
uint64_t _value
Counter value (as specified in CNTCV).
uint64_t increment() const
Returns the value increment.
uint32_t freq() const
Returns the counter frequency.
void freqUpdateCallback()
Callback for the frequency update.
Tick _updateTick
Counter cycle start Tick when the counter status affecting its value has been updated.
uint64_t _increment
Value increment in each counter cycle.
size_t _activeFreqEntry
Currently selected entry in the table, its contents should match _freq.
void registerListener(SystemCounterListener *listener)
Called from System Counter Listeners to register.
void freqUpdateSchedule(size_t new_freq_entry)
Schedules a counter frequency update after a CNTCR.FCREQ == 1 This complies with frequency transition...
void unserialize(CheckpointIn &cp) override
Unserialize an object.
bool _enabled
Indicates if the counter is enabled.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
STL vector class.
Definition stl.hh:37
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition addr_range.hh:64
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition bitfield.hh:79
constexpr T mbits(T val, unsigned first, unsigned last)
Mask off the given bits in place like bits() but without shifting.
Definition bitfield.hh:106
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
DrainState
Object drain/handover states.
Definition drain.hh:76
SimObject(const Params &p)
Definition sim_object.cc:58
Bitfield< 5 > t
Definition misc_types.hh:71
Bitfield< 29 > c
Definition misc_types.hh:53
Bitfield< 0 > p
Bitfield< 11 > enable
Definition misc.hh:1086
Bitfield< 63 > val
Definition misc.hh:804
Bitfield< 3 > addr
Definition types.hh:84
Bitfield< 15, 8 > vector
Definition intmessage.hh:48
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t RegVal
Definition types.hh:173
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
Packet * PacketPtr
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81
uint64_t eventTargetValue(uint64_t val) const
const std::string & name()
Definition trace.cc:48

Generated on Mon Oct 27 2025 04:13:01 for gem5 by doxygen 1.14.0