46 #include "debug/Checkpoint.hh" 47 #include "debug/Timer.hh" 54 global_timer(
name() +
".globaltimer", this, p->int_num)
60 : _name(__name), parent(_parent), intNum(int_num), control(0x0),
61 rawInt(false), pendingInt(false), autoIncValue(0x0), cmpValEvent(this)
75 panic(
"Tried to read A9GlobalTimer at offset %#x that doesn't exist\n",
90 DPRINTF(
Timer,
"Reading from A9GlobalTimer at offset: %#x\n", daddr);
96 DPRINTF(
Timer,
"-- returning lower 32-bits of counter: %u\n", time);
97 pkt->
setLE<uint32_t>(time);
102 DPRINTF(
Timer,
"-- returning upper 32-bits of counter: %u\n", time);
103 pkt->
setLE<uint32_t>(time);
112 DPRINTF(
Timer,
"Event schedule for %d, clock=%d, prescale=%d\n",
119 DPRINTF(
Timer,
"-- returning lower 32-bits of comparator: %u\n", time);
120 pkt->
setLE<uint32_t>(time);
123 DPRINTF(
Timer,
"Event schedule for %d, clock=%d, prescale=%d\n",
131 DPRINTF(
Timer,
"-- returning upper 32-bits of comparator: %u\n", time);
132 pkt->
setLE<uint32_t>(time);
138 panic(
"Tried to read A9GlobalTimer at offset %#x\n", daddr);
141 DPRINTF(
Timer,
"Reading %#x from A9GlobalTimer at offset: %#x\n",
142 pkt->
getLE<uint32_t>(), daddr);
151 DPRINTF(
Timer,
"Writing to A9GlobalTimer at offset: %#x\n", daddr);
153 warn_once(
"A9 Global Timer doesn't support banked per-cpu registers\n");
158 panic(
"Tried to write A9GlobalTimer at offset %#x doesn't exist\n",
167 DPRINTF(
Timer,
"Writing %#x to A9GlobalTimer at offset: %#x\n",
168 pkt->
getLE<uint32_t>(), daddr);
172 DPRINTF(
Timer,
"Ignoring unsupported write to Global Timer Counter\n");
178 old_cmpEnable =
control.cmpEnable;
180 if ((old_enable == 0) &&
control.enable)
182 if ((old_cmpEnable == 0) &&
control.cmpEnable)
200 cmpVal |= ((uint64_t)pkt->
getLE<uint32_t>() << 32);
206 panic(
"Tried to write A9GlobalTimer at offset %#x\n", daddr);
225 DPRINTF(
Timer,
"-- Event was already schedule, de-scheduling\n");
229 DPRINTF(
Timer,
"-- Scheduling new event for: %d\n", time);
249 if (
control.autoIncrement == 0)
259 DPRINTF(Checkpoint,
"Serializing Arm A9GlobalTimer\n");
261 uint32_t control_serial =
control;
282 DPRINTF(Checkpoint,
"Unserializing Arm A9GlobalTimer\n");
284 uint32_t control_serial;
316 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)
void deschedule(Event &event)
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.
uint64_t cmpVal
Value of the comparator.
void serialize(CheckpointOut &cp) const override
Serialize an object.
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.
void schedule(Event &event, Tick when)
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.