45#include "debug/Checkpoint.hh"
46#include "debug/Timer.hh"
56 timer0(
name() +
".timer0", this,
p.int0->get(),
p.clock0),
57 timer1(
name() +
".timer1", this,
p.
int1->get(),
p.clock1)
63 : _name(__name), parent(_parent), interrupt(_interrupt),
64 clock(_clock), control(0x20),
65 rawInt(false), pendingInt(false), loadValue(0xffffffff),
77 DPRINTF(
Timer,
"Reading from DualTimer at offset: %#x\n", daddr);
84 panic(
"Tried to read SP804 at offset %#x that doesn't exist\n", daddr);
95 pkt->
setLE<uint32_t>(loadValue);
98 DPRINTF(
Timer,
"Event schedule for %d, clock=%d, prescale=%d\n",
101 time = zeroEvent.when() -
curTick();
102 time = (time / clock) >> (4 * control.timerPrescale);
104 pkt->
setLE<uint32_t>(time);
107 pkt->
setLE<uint32_t>(control);
110 pkt->
setLE<uint32_t>(rawInt);
113 pkt->
setLE<uint32_t>(pendingInt);
116 pkt->
setLE<uint32_t>(loadValue);
119 panic(
"Tried to read SP804 timer at offset %#x\n", daddr);
122 DPRINTF(
Timer,
"Reading %#x from Timer at offset: %#x\n",
123 pkt->
getLE<uint32_t>(), daddr);
132 DPRINTF(
Timer,
"Writing to DualTimer at offset: %#x\n", daddr);
139 panic(
"Tried to write SP804 at offset %#x that doesn't exist\n", daddr);
148 pkt->
getLE<uint32_t>(), daddr);
151 loadValue = pkt->
getLE<uint32_t>();
152 restartCounter(loadValue);
159 old_enable = control.timerEnable;
160 control = pkt->
getLE<uint32_t>();
161 if ((old_enable == 0) && control.timerEnable)
162 restartCounter(loadValue);
173 loadValue = pkt->
getLE<uint32_t>();
176 panic(
"Tried to write SP804 timer at offset %#x\n", daddr);
185 if (!control.timerEnable)
188 Tick time = clock << (4 * control.timerPrescale);
189 if (control.timerSize)
194 if (zeroEvent.scheduled()) {
195 DPRINTF(
Timer,
"-- Event was already schedule, de-scheduling\n");
196 parent->deschedule(zeroEvent);
198 parent->schedule(zeroEvent,
curTick() + time);
205 if (!control.timerEnable)
211 bool old_pending = pendingInt;
212 if (control.intEnable)
214 if (pendingInt && !old_pending) {
223 if (control.timerMode == 0)
224 restartCounter(0xffffffff);
226 restartCounter(loadValue);
232 DPRINTF(Checkpoint,
"Serializing Arm Sp804\n");
234 uint32_t control_serial = control;
241 bool is_in_event = zeroEvent.scheduled();
246 event_time = zeroEvent.when();
254 DPRINTF(Checkpoint,
"Unserializing Arm Sp804\n");
256 uint32_t control_serial;
258 control = control_serial;
270 parent->schedule(zeroEvent, event_time);
Base class for ARM GIC implementations.
bool readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
Generic representation of an Arm interrupt pin.
Addr pioAddr
Address that the device listens to.
Tick pioDelay
Delay that the device experinces on an access.
Addr pioSize
Size that the device's address range.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setLE(T v)
Set the value in the data pointer to v as little endian.
void makeAtomicResponse()
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
Timer(std::string __name, Sp804 *parent, ArmInterruptPin *_interrupt, Tick clock)
void counterAtZero()
Called when the counter reaches 0.
void restartCounter(uint32_t val)
Restart the counter ticking at val.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Bitfield< 3, 2 > timerPrescale
void serialize(CheckpointOut &cp) const override
Serialize an object.
Timer timer0
Timers that do the actual work.
Sp804(const Params &p)
The constructor for RealView just registers itself with the MMU.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Tick read(PacketPtr pkt) override
Handle a read to the device.
Tick write(PacketPtr pkt) override
All writes are simply ignored.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define panic(...)
This implements a cprintf based panic() function.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
Declaration of the Packet class.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)
This implements the dual Sp804 timer block.
const std::string & name()