43 #include "debug/Checkpoint.hh" 44 #include "debug/Timer.hh" 51 global_timer(
name() +
".globaltimer", this, p->int_num)
57 : _name(__name), parent(_parent), intNum(int_num), control(0x0),
58 rawInt(false), pendingInt(false), autoIncValue(0x0), cmpValEvent(this)
72 panic(
"Tried to read A9GlobalTimer at offset %#x that doesn't exist\n",
87 DPRINTF(
Timer,
"Reading from A9GlobalTimer at offset: %#x\n", daddr);
93 DPRINTF(
Timer,
"-- returning lower 32-bits of counter: %u\n", time);
94 pkt->
setLE<uint32_t>(time);
99 DPRINTF(
Timer,
"-- returning upper 32-bits of counter: %u\n", time);
100 pkt->
setLE<uint32_t>(time);
109 DPRINTF(
Timer,
"Event schedule for %d, clock=%d, prescale=%d\n",
116 DPRINTF(
Timer,
"-- returning lower 32-bits of comparator: %u\n", time);
117 pkt->
setLE<uint32_t>(time);
120 DPRINTF(
Timer,
"Event schedule for %d, clock=%d, prescale=%d\n",
128 DPRINTF(
Timer,
"-- returning upper 32-bits of comparator: %u\n", time);
129 pkt->
setLE<uint32_t>(time);
135 panic(
"Tried to read A9GlobalTimer at offset %#x\n", daddr);
138 DPRINTF(
Timer,
"Reading %#x from A9GlobalTimer at offset: %#x\n",
139 pkt->
getLE<uint32_t>(), daddr);
148 DPRINTF(
Timer,
"Writing to A9GlobalTimer at offset: %#x\n", daddr);
150 warn_once(
"A9 Global Timer doesn't support banked per-cpu registers\n");
155 panic(
"Tried to write A9GlobalTimer at offset %#x doesn't exist\n",
164 DPRINTF(
Timer,
"Writing %#x to A9GlobalTimer at offset: %#x\n",
165 pkt->
getLE<uint32_t>(), daddr);
169 DPRINTF(
Timer,
"Ignoring unsupported write to Global Timer Counter\n");
175 old_cmpEnable =
control.cmpEnable;
177 if ((old_enable == 0) &&
control.enable)
179 if ((old_cmpEnable == 0) &&
control.cmpEnable)
197 cmpVal |= ((uint64_t)pkt->
getLE<uint32_t>() << 32);
203 panic(
"Tried to write A9GlobalTimer at offset %#x\n", daddr);
222 DPRINTF(
Timer,
"-- Event was already schedule, de-scheduling\n");
226 DPRINTF(
Timer,
"-- Scheduling new event for: %d\n", time);
246 if (
control.autoIncrement == 0)
256 DPRINTF(Checkpoint,
"Serializing Arm A9GlobalTimer\n");
258 uint32_t control_serial =
control;
279 DPRINTF(Checkpoint,
"Unserializing Arm A9GlobalTimer\n");
281 uint32_t control_serial;
313 A9GlobalTimerParams::create()
#define panic(...)
This implements a cprintf based panic() function.
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
BaseGic * gic
Pointer to the GIC for causing an interrupt.
Tick write(PacketPtr pkt) override
Handle a write to the device.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t getTimeCounterFromTicks(Tick ticks)
Convert a number of ticks into the time counter format.
A9GlobalTimer(Params *p)
The constructor for RealView just registers itself with the MMU.
virtual void clearInt(uint32_t num)=0
Clear an interrupt from a device that is connected to the GIC.
const std::string & name()
CTRL control
Control register as specified above.
EventWrapper< Timer, &Timer::counterAtCmpVal > cmpValEvent
Timer global_timer
Timer that does the actual work.
Timer(std::string __name, A9GlobalTimer *parent, int int_num)
Tick read(PacketPtr pkt) override
Handle a read to the device.
void setLE(T v)
Set the value in the data pointer to v as little endian.
#define UNSERIALIZE_SCALAR(scalar)
void restartCounter()
Restart the counter ticking.
Tick curTick()
The current simulated tick.
Addr pioSize
Size that the device's address range.
void serialize(CheckpointOut &cp) const override
Serialize an object.
virtual void sendPPInt(uint32_t num, uint32_t cpu)=0
Interface call for private peripheral interrupts.
void makeAtomicResponse()
EndBitUnion(CTRL) protected A9GlobalTimer * parent
Pointer to parent class.
uint64_t Tick
Tick count type.
const uint32_t intNum
Number of interrupt to cause/clear.
bool pendingInt
If an interrupt is currently pending.
void deschedule(Event &event)
uint64_t cmpVal
Value of the comparator.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void schedule(Event &event, Tick when)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
#define ULL(N)
uint64_t constant
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
void counterAtCmpVal()
Called when the counter reaches the comparator.
#define SERIALIZE_SCALAR(scalar)
Base class for ARM GIC implementations.
A9GlobalTimerParams Params
Declaration of the Packet class.
std::ostream CheckpointOut
void unserialize(CheckpointIn &cp) override
Unserialize an object.
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 read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
This implements the Cortex A9-MPCore global timer from TRM rev r4p1.
bool rawInt
If timer has caused an interrupt.
uint32_t autoIncValue
Value to add to comparator when counter reaches comparator.
Addr pioAddr
Address that the device listens to.