44 #include "debug/Checkpoint.hh"
45 #include "debug/Timer.hh"
52 timer0(
name() +
".timer0", this, p->int_num0, p->clock0),
53 timer1(
name() +
".timer1", this, p->int_num1, p->clock1)
58 : _name(__name), parent(_parent), intNum(int_num), clock(_clock), control(0x20),
59 rawInt(false), pendingInt(false), loadValue(0xffffffff), zeroEvent(this)
70 DPRINTF(
Timer,
"Reading from DualTimer at offset: %#x\n", daddr);
77 panic(
"Tried to read SP804 at offset %#x that doesn't exist\n", daddr);
88 pkt->
set<uint32_t>(loadValue);
91 DPRINTF(
Timer,
"Event schedule for %d, clock=%d, prescale=%d\n",
94 time = zeroEvent.when() -
curTick();
95 time = time / clock /
power(16, control.timerPrescale);
97 pkt->
set<uint32_t>(time);
100 pkt->
set<uint32_t>(control);
103 pkt->
set<uint32_t>(rawInt);
106 pkt->
set<uint32_t>(pendingInt);
109 pkt->
set<uint32_t>(loadValue);
112 panic(
"Tried to read SP804 timer at offset %#x\n", daddr);
115 DPRINTF(
Timer,
"Reading %#x from Timer at offset: %#x\n", pkt->
get<uint32_t>(), daddr);
124 DPRINTF(
Timer,
"Writing to DualTimer at offset: %#x\n", daddr);
131 panic(
"Tried to write SP804 at offset %#x that doesn't exist\n", daddr);
139 DPRINTF(
Timer,
"Writing %#x to Timer at offset: %#x\n", pkt->
get<uint32_t>(), daddr);
142 loadValue = pkt->
get<uint32_t>();
143 restartCounter(loadValue);
150 old_enable = control.timerEnable;
151 control = pkt->
get<uint32_t>();
152 if ((old_enable == 0) && control.timerEnable)
153 restartCounter(loadValue);
160 parent->gic->clearInt(intNum);
164 loadValue = pkt->
get<uint32_t>();
167 panic(
"Tried to write SP804 timer at offset %#x\n", daddr);
175 DPRINTF(
Timer,
"Resetting counter with value %#x\n", val);
176 if (!control.timerEnable)
179 Tick time = clock *
power(16, control.timerPrescale);
180 if (control.timerSize)
183 time *=
bits(val,15,0);
185 if (zeroEvent.scheduled()) {
186 DPRINTF(
Timer,
"-- Event was already schedule, de-scheduling\n");
187 parent->deschedule(zeroEvent);
189 parent->schedule(zeroEvent,
curTick() + time);
196 if (!control.timerEnable)
202 bool old_pending = pendingInt;
203 if (control.intEnable)
205 if (pendingInt && !old_pending) {
207 parent->gic->sendInt(intNum);
214 if (control.timerMode == 0)
215 restartCounter(0xffffffff);
217 restartCounter(loadValue);
223 DPRINTF(Checkpoint,
"Serializing Arm Sp804\n");
225 uint32_t control_serial = control;
232 bool is_in_event = zeroEvent.scheduled();
237 event_time = zeroEvent.when();
245 DPRINTF(Checkpoint,
"Unserializing Arm Sp804\n");
247 uint32_t control_serial;
249 control = control_serial;
261 parent->schedule(zeroEvent, event_time);
282 Sp804Params::create()
284 return new Sp804(
this);
void counterAtZero()
Called when the counter reaches 0.
void set(T v, ByteOrder endian)
Set the value in the data pointer to v using the specified endianness.
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
const std::string & name()
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
void restartCounter(uint32_t val)
Restart the counter ticking at val.
AmbaPioDeviceParams Params
Timer timer0
Timers that do the actual work.
BaseGic * gic
Pointer to the GIC for causing an interrupt.
void serialize(CheckpointOut &cp) const override
Serialize an object.
T get(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
#define UNSERIALIZE_SCALAR(scalar)
Tick curTick()
The current simulated tick.
Sp804(Params *p)
The constructor for RealView just registers itself with the MMU.
Addr pioSize
Size that the device's address range.
void makeAtomicResponse()
uint64_t Tick
Tick count type.
uint64_t power(uint32_t n, uint32_t e)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
Tick write(PacketPtr pkt) override
All writes are simply ignored.
This implements the dual Sp804 timer block.
bool readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
#define SERIALIZE_SCALAR(scalar)
Base class for ARM GIC implementations.
Declaration of the Packet class.
std::ostream CheckpointOut
Bitfield< 3, 2 > timerPrescale
Tick pioDelay
Delay that the device experinces on an access.
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
Timer(std::string __name, Sp804 *parent, int int_num, Tick clock)
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
Addr pioAddr
Address that the device listens to.
void serialize(CheckpointOut &cp) const override
Serialize an object.
Tick read(PacketPtr pkt) override
Handle a read to the device.