Go to the documentation of this file.
45 #include "debug/Checkpoint.hh"
46 #include "debug/Timer.hh"
53 timer0(
name() +
".timer0", this,
p.int0->get(),
p.clock0),
54 timer1(
name() +
".timer1", this,
p.
int1->get(),
p.clock1)
60 : _name(__name), parent(_parent), interrupt(_interrupt),
61 clock(_clock), control(0x20),
62 rawInt(false), pendingInt(false), loadValue(0xffffffff),
74 DPRINTF(
Timer,
"Reading from DualTimer at offset: %#x\n", daddr);
81 panic(
"Tried to read SP804 at offset %#x that doesn't exist\n", daddr);
92 pkt->
setLE<uint32_t>(loadValue);
95 DPRINTF(
Timer,
"Event schedule for %d, clock=%d, prescale=%d\n",
98 time = zeroEvent.when() -
curTick();
99 time = time / clock /
power(16, control.timerPrescale);
101 pkt->
setLE<uint32_t>(time);
104 pkt->
setLE<uint32_t>(control);
107 pkt->
setLE<uint32_t>(rawInt);
110 pkt->
setLE<uint32_t>(pendingInt);
113 pkt->
setLE<uint32_t>(loadValue);
116 panic(
"Tried to read SP804 timer at offset %#x\n", daddr);
119 DPRINTF(
Timer,
"Reading %#x from Timer at offset: %#x\n",
120 pkt->
getLE<uint32_t>(), daddr);
129 DPRINTF(
Timer,
"Writing to DualTimer at offset: %#x\n", daddr);
136 panic(
"Tried to write SP804 at offset %#x that doesn't exist\n", daddr);
145 pkt->
getLE<uint32_t>(), daddr);
148 loadValue = pkt->
getLE<uint32_t>();
149 restartCounter(loadValue);
156 old_enable = control.timerEnable;
157 control = pkt->
getLE<uint32_t>();
158 if ((old_enable == 0) && control.timerEnable)
159 restartCounter(loadValue);
170 loadValue = pkt->
getLE<uint32_t>();
173 panic(
"Tried to write SP804 timer at offset %#x\n", daddr);
182 if (!control.timerEnable)
185 Tick time = clock *
power(16, control.timerPrescale);
186 if (control.timerSize)
191 if (zeroEvent.scheduled()) {
192 DPRINTF(
Timer,
"-- Event was already schedule, de-scheduling\n");
193 parent->deschedule(zeroEvent);
195 parent->schedule(zeroEvent,
curTick() + time);
202 if (!control.timerEnable)
208 bool old_pending = pendingInt;
209 if (control.intEnable)
211 if (pendingInt && !old_pending) {
220 if (control.timerMode == 0)
221 restartCounter(0xffffffff);
223 restartCounter(loadValue);
229 DPRINTF(Checkpoint,
"Serializing Arm Sp804\n");
231 uint32_t control_serial = control;
238 bool is_in_event = zeroEvent.scheduled();
243 event_time = zeroEvent.when();
251 DPRINTF(Checkpoint,
"Unserializing Arm Sp804\n");
253 uint32_t control_serial;
255 control = control_serial;
267 parent->schedule(zeroEvent, event_time);
void serialize(CheckpointOut &cp) const override
Serialize an object.
void makeAtomicResponse()
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Addr pioAddr
Address that the device listens to.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
#define UNSERIALIZE_SCALAR(scalar)
Bitfield< 3, 2 > timerPrescale
Timer timer0
Timers that do the actual work.
uint64_t Tick
Tick count type.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
void restartCounter(uint32_t val)
Restart the counter ticking at val.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
bool readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
Addr pioSize
Size that the device's address range.
Tick write(PacketPtr pkt) override
All writes are simply ignored.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
Timer(std::string __name, Sp804 *parent, ArmInterruptPin *_interrupt, Tick clock)
virtual const std::string name() const
void counterAtZero()
Called when the counter reaches 0.
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
AmbaPioDeviceParams Params
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Generic representation of an Arm interrupt pin.
Tick pioDelay
Delay that the device experinces on an access.
void setLE(T v)
Set the value in the data pointer to v as little endian.
Tick read(PacketPtr pkt) override
Handle a read to the device.
std::ostream CheckpointOut
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Tick curTick()
The universal simulation clock.
Sp804(const Params &p)
The constructor for RealView just registers itself with the MMU.
uint64_t power(uint32_t n, uint32_t e)
#define panic(...)
This implements a cprintf based panic() function.
Generated on Tue Mar 23 2021 19:41:26 for gem5 by doxygen 1.8.17