Go to the documentation of this file.
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);
Tick curTick()
The universal simulation clock.
void restartCounter(uint32_t val)
Restart the counter ticking at val.
Addr pioAddr
Address that the device listens to.
void serialize(CheckpointOut &cp) const override
Serialize an object.
#define UNSERIALIZE_SCALAR(scalar)
void serialize(CheckpointOut &cp) const override
Serialize an object.
void write(PacketPtr pkt, Addr daddr)
Handle write for a single timer.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
void makeAtomicResponse()
void read(PacketPtr pkt, Addr daddr)
Handle read for a single timer.
AmbaPioDeviceParams Params
void counterAtZero()
Called when the counter reaches 0.
Sp804(const Params &p)
The constructor for RealView just registers itself with the MMU.
Tick read(PacketPtr pkt) override
Handle a read to the device.
virtual std::string name() const
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
uint64_t Tick
Tick count type.
Tick pioDelay
Delay that the device experinces on an access.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
Timer timer0
Timers that do the actual work.
Timer(std::string __name, Sp804 *parent, ArmInterruptPin *_interrupt, Tick clock)
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
Addr pioSize
Size that the device's address range.
Tick write(PacketPtr pkt) override
All writes are simply ignored.
Bitfield< 3, 2 > timerPrescale
Generic representation of an Arm interrupt pin.
std::ostream CheckpointOut
bool readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
void setLE(T v)
Set the value in the data pointer to v as little endian.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
#define panic(...)
This implements a cprintf based panic() function.
Generated on Sun Jul 30 2023 01:56:55 for gem5 by doxygen 1.8.17