Go to the documentation of this file.
42 #include "debug/Checkpoint.hh"
43 #include "debug/Timer.hh"
50 timer0(
name() +
".timer0", this,
p->int0->get(),
p->clock0),
51 timer1(
name() +
".timer1", this,
p->
int1->get(),
p->clock1)
57 : _name(__name), parent(_parent), interrupt(_interrupt),
58 clock(_clock), control(0x20),
59 rawInt(false), pendingInt(false), loadValue(0xffffffff),
71 DPRINTF(
Timer,
"Reading from DualTimer at offset: %#x\n", daddr);
78 panic(
"Tried to read SP804 at offset %#x that doesn't exist\n", daddr);
89 pkt->
setLE<uint32_t>(loadValue);
92 DPRINTF(
Timer,
"Event schedule for %d, clock=%d, prescale=%d\n",
95 time = zeroEvent.when() -
curTick();
96 time = time / clock /
power(16, control.timerPrescale);
98 pkt->
setLE<uint32_t>(time);
101 pkt->
setLE<uint32_t>(control);
104 pkt->
setLE<uint32_t>(rawInt);
107 pkt->
setLE<uint32_t>(pendingInt);
110 pkt->
setLE<uint32_t>(loadValue);
113 panic(
"Tried to read SP804 timer at offset %#x\n", daddr);
116 DPRINTF(
Timer,
"Reading %#x from Timer at offset: %#x\n",
117 pkt->
getLE<uint32_t>(), daddr);
126 DPRINTF(
Timer,
"Writing to DualTimer at offset: %#x\n", daddr);
133 panic(
"Tried to write SP804 at offset %#x that doesn't exist\n", daddr);
142 pkt->
getLE<uint32_t>(), daddr);
145 loadValue = pkt->
getLE<uint32_t>();
146 restartCounter(loadValue);
153 old_enable = control.timerEnable;
154 control = pkt->
getLE<uint32_t>();
155 if ((old_enable == 0) && control.timerEnable)
156 restartCounter(loadValue);
167 loadValue = pkt->
getLE<uint32_t>();
170 panic(
"Tried to write SP804 timer at offset %#x\n", daddr);
179 if (!control.timerEnable)
182 Tick time = clock *
power(16, control.timerPrescale);
183 if (control.timerSize)
188 if (zeroEvent.scheduled()) {
189 DPRINTF(
Timer,
"-- Event was already schedule, de-scheduling\n");
190 parent->deschedule(zeroEvent);
192 parent->schedule(zeroEvent,
curTick() + time);
199 if (!control.timerEnable)
205 bool old_pending = pendingInt;
206 if (control.intEnable)
208 if (pendingInt && !old_pending) {
217 if (control.timerMode == 0)
218 restartCounter(0xffffffff);
220 restartCounter(loadValue);
226 DPRINTF(Checkpoint,
"Serializing Arm Sp804\n");
228 uint32_t control_serial = control;
235 bool is_in_event = zeroEvent.scheduled();
240 event_time = zeroEvent.when();
248 DPRINTF(Checkpoint,
"Unserializing Arm Sp804\n");
250 uint32_t control_serial;
252 control = control_serial;
264 parent->schedule(zeroEvent, event_time);
285 Sp804Params::create()
287 return new Sp804(
this);
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.
Sp804(Params *p)
The constructor for RealView just registers itself with the MMU.
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
uint64_t power(uint32_t n, uint32_t e)
#define panic(...)
This implements a cprintf based panic() function.
Tick curTick()
The current simulated tick.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Generated on Wed Sep 30 2020 14:02:10 for gem5 by doxygen 1.8.17