43 #include "debug/Checkpoint.hh" 44 #include "debug/Timer.hh" 61 std::stringstream oss;
62 oss <<
name() <<
".timer" <<
i;
65 new Timer(oss.str(),
this,
66 p->int_timer->get(tc),
67 p->int_watchdog->get(tc)));
77 : _name(timer_name), parent(_parent), intTimer(int_timer),
78 intWatchdog(int_watchdog), timerControl(0x0), watchdogControl(0x0),
79 rawIntTimer(false), rawIntWatchdog(false),
80 rawResetWatchdog(false), watchdogDisableReg(0x0),
81 pendingIntTimer(false), pendingIntWatchdog(false),
82 timerLoadValue(0x0), watchdogLoadValue(0x0),
95 DPRINTF(
Timer,
"Reading from CpuLocalTimer at offset: %#x\n", daddr);
102 panic(
"Tried to read CpuLocalTimer at offset %#x that doesn't exist\n", daddr);
111 DPRINTF(
Timer,
"Reading from CpuLocalTimer at offset: %#x\n", daddr);
119 DPRINTF(
Timer,
"Event schedule for timer %d, clock=%d, prescale=%d\n",
126 pkt->
setLE<uint32_t>(time);
139 "Event schedule for watchdog %d, clock=%d, prescale=%d\n",
146 pkt->
setLE<uint32_t>(time);
158 panic(
"Tried to read from WatchdogDisableRegister\n");
161 panic(
"Tried to read CpuLocalTimer at offset %#x\n", daddr);
173 DPRINTF(
Timer,
"Writing to CpuLocalTimer at offset: %#x\n", daddr);
180 panic(
"Tried to write CpuLocalTimer at offset %#x that doesn't exist\n", daddr);
188 DPRINTF(
Timer,
"Writing to CpuLocalTimer at offset: %#x\n", daddr);
256 panic(
"Tried to write CpuLocalTimer timer at offset %#x\n", daddr);
265 DPRINTF(
Timer,
"Resetting timer counter with value %#x\n", val);
273 DPRINTF(
Timer,
"-- Event was already schedule, de-scheduling\n");
283 DPRINTF(
Timer,
"Resetting watchdog counter with value %#x\n", val);
291 DPRINTF(
Timer,
"-- Event was already schedule, de-scheduling\n");
338 fatal(
"gem5 ARM Model does not support true watchdog operation!\n");
356 DPRINTF(Checkpoint,
"Serializing Arm CpuLocalTimer\n");
377 Tick timer_event_time;
378 if (timer_is_in_event){
382 Tick watchdog_event_time;
383 if (watchdog_is_in_event){
392 DPRINTF(Checkpoint,
"Unserializing Arm CpuLocalTimer\n");
394 uint32_t timer_control_serial;
397 uint32_t watchdog_control_serial;
410 bool timer_is_in_event;
412 bool watchdog_is_in_event;
415 Tick timer_event_time;
416 if (timer_is_in_event){
420 Tick watchdog_event_time;
421 if (watchdog_is_in_event) {
444 CpuLocalTimerParams::create()
#define panic(...)
This implements a cprintf based panic() function.
Tick write(PacketPtr pkt) override
Handle a write to the device.
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
#define fatal(...)
This implements a cprintf based fatal() function.
ArmInterruptPin * intWatchdog
void restartTimerCounter(uint32_t val)
Restart the counter ticking at val.
bool pendingIntTimer
If an interrupt is currently pending.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Timer(const std::string &name, CpuLocalTimer *_parent, ArmInterruptPin *int_timer, ArmInterruptPin *int_watchdog)
uint32_t timerLoadValue
Value to load into counters when periodic mode reaches 0.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
const Params * params() const
EndBitUnion(WatchdogCtrl) protected CpuLocalTimer * parent
Pointer to parent class.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
EventFunctionWrapper timerZeroEvent
void setLE(T v)
Set the value in the data pointer to v as little endian.
ThreadContext * getThreadContext(ContextID tid) const
void serialize(CheckpointOut &cp) const override
Serialize an object.
CpuLocalTimerParams Params
RequestPtr req
A pointer to the original request.
friend class CpuLocalTimer
#define UNSERIALIZE_SCALAR(scalar)
Tick curTick()
The current simulated tick.
std::string csprintf(const char *format, const Args &...args)
ArmInterruptPin * intTimer
Interrupt to cause/clear.
Addr pioSize
Size that the device's address range.
std::vector< std::unique_ptr< Timer > > localTimer
Timers that do the actual work.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void makeAtomicResponse()
TimerCtrl timerControl
Control register as specified above.
uint64_t Tick
Tick count type.
uint64_t power(uint32_t n, uint32_t e)
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
EventFunctionWrapper watchdogZeroEvent
void deschedule(Event &event)
unsigned numContexts() const
uint32_t watchdogLoadValue
void schedule(Event &event, Tick when)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool rawIntTimer
If timer has caused an interrupt.
This implements the cpu local timer from the Cortex-A9 MPCore Technical Reference Manual rev r2p2 (AR...
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
void restartWatchdogCounter(uint32_t val)
void timerAtZero()
Called when the counter reaches 0.
void init() override
Inits the local timers.
#define SERIALIZE_SCALAR(scalar)
bool scheduled() const
Determine if the current event is scheduled.
virtual const std::string name() const
uint32_t watchdogDisableReg
Base class for ARM GIC implementations.
Declaration of the Packet class.
virtual void raise()=0
Signal an interrupt.
std::ostream CheckpointOut
Tick read(PacketPtr pkt) override
Handle a read to the device.
Tick pioDelay
Delay that the device experinces on an access.
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Tick when() const
Get the time that the event is scheduled.
Addr pioAddr
Address that the device listens to.
Generic representation of an Arm interrupt pin.
CpuLocalTimer(Params *p)
The constructor for RealView just registers itself with the MMU.
int ContextID
Globally unique thread context ID.
WatchdogCtrl watchdogControl
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.