Deleted Added
sdiff udiff text old ( 12086:069c529a76fd ) new ( 13106:3af014b59080 )
full compact
1/*
2 * Copyright (c) 2010-2013 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 24 unchanged lines hidden (view full) ---

35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * Authors: Ali Saidi
38 * Geoffrey Blake
39 */
40
41#include "dev/arm/timer_cpulocal.hh"
42
43#include "base/intmath.hh"
44#include "base/trace.hh"
45#include "debug/Checkpoint.hh"
46#include "debug/Timer.hh"
47#include "dev/arm/base_gic.hh"
48#include "mem/packet.hh"
49#include "mem/packet_access.hh"
50
51CpuLocalTimer::CpuLocalTimer(Params *p)
52 : BasicPioDevice(p, 0x38), gic(p->gic)
53{
54 // Initialize the timer registers for each per cpu timer
55 for (int i = 0; i < CPU_MAX; i++) {
56 std::stringstream oss;
57 oss << name() << ".timer" << i;
58 localTimer[i]._name = oss.str();
59 localTimer[i].parent = this;
60 localTimer[i].intNumTimer = p->int_num_timer;
61 localTimer[i].intNumWatchdog = p->int_num_watchdog;
62 localTimer[i].cpuNum = i;
63 }
64}
65
66CpuLocalTimer::Timer::Timer()
67 : timerControl(0x0), watchdogControl(0x0), rawIntTimer(false), rawIntWatchdog(false),
68 rawResetWatchdog(false), watchdogDisableReg(0x0), pendingIntTimer(false), pendingIntWatchdog(false),
69 timerLoadValue(0x0), watchdogLoadValue(0x0),
70 timerZeroEvent([this]{ timerAtZero(); }, name()),
71 watchdogZeroEvent([this]{ watchdogAtZero(); }, name())
72{
73}
74
75Tick
76CpuLocalTimer::read(PacketPtr pkt)
77{
78 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
79 assert(pkt->getSize() == 4);
80 Addr daddr = pkt->getAddr() - pioAddr;
81 ContextID cpu_id = pkt->req->contextId();
82 DPRINTF(Timer, "Reading from CpuLocalTimer at offset: %#x\n", daddr);
83 assert(cpu_id >= 0);
84 assert(cpu_id < CPU_MAX);
85
86 if (daddr < Timer::Size)
87 localTimer[cpu_id].read(pkt, daddr);
88 else
89 panic("Tried to read CpuLocalTimer at offset %#x that doesn't exist\n", daddr);
90 pkt->makeAtomicResponse();
91 return pioDelay;
92}
93
94
95void

--- 58 unchanged lines hidden (view full) ---

154CpuLocalTimer::write(PacketPtr pkt)
155{
156 assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
157 assert(pkt->getSize() == 4);
158 Addr daddr = pkt->getAddr() - pioAddr;
159 ContextID cpu_id = pkt->req->contextId();
160 DPRINTF(Timer, "Writing to CpuLocalTimer at offset: %#x\n", daddr);
161 assert(cpu_id >= 0);
162 assert(cpu_id < CPU_MAX);
163
164 if (daddr < Timer::Size)
165 localTimer[cpu_id].write(pkt, daddr);
166 else
167 panic("Tried to write CpuLocalTimer at offset %#x that doesn't exist\n", daddr);
168 pkt->makeAtomicResponse();
169 return pioDelay;
170}
171
172void
173CpuLocalTimer::Timer::write(PacketPtr pkt, Addr daddr)

--- 118 unchanged lines hidden (view full) ---

292 DPRINTF(Timer, "Timer Counter reached zero\n");
293
294 rawIntTimer = true;
295 bool old_pending = pendingIntTimer;
296 if (timerControl.intEnable)
297 pendingIntTimer = true;
298 if (pendingIntTimer && !old_pending) {
299 DPRINTF(Timer, "-- Causing interrupt\n");
300 parent->gic->sendPPInt(intNumTimer, cpuNum);
301 }
302
303 if (!timerControl.autoReload)
304 return;
305 else
306 restartTimerCounter(timerLoadValue);
307}
308

--- 14 unchanged lines hidden (view full) ---

323 else if (watchdogControl.watchdogMode) {
324 rawResetWatchdog = true;
325 fatal("gem5 ARM Model does not support true watchdog operation!\n");
326 //XXX: Should we ever support a true watchdog reset?
327 }
328
329 if (pendingIntWatchdog && !old_pending) {
330 DPRINTF(Timer, "-- Causing interrupt\n");
331 parent->gic->sendPPInt(intNumWatchdog, cpuNum);
332 }
333
334 if (watchdogControl.watchdogMode)
335 return;
336 else if (watchdogControl.autoReload)
337 restartWatchdogCounter(watchdogLoadValue);
338}
339
340void
341CpuLocalTimer::Timer::serialize(CheckpointOut &cp) const
342{
343 DPRINTF(Checkpoint, "Serializing Arm CpuLocalTimer\n");
344 SERIALIZE_SCALAR(intNumTimer);
345 SERIALIZE_SCALAR(intNumWatchdog);
346
347 uint32_t timer_control_serial = timerControl;
348 uint32_t watchdog_control_serial = watchdogControl;
349 SERIALIZE_SCALAR(timer_control_serial);
350 SERIALIZE_SCALAR(watchdog_control_serial);
351
352 SERIALIZE_SCALAR(rawIntTimer);
353 SERIALIZE_SCALAR(rawIntWatchdog);

--- 21 unchanged lines hidden (view full) ---

375 }
376}
377
378void
379CpuLocalTimer::Timer::unserialize(CheckpointIn &cp)
380{
381 DPRINTF(Checkpoint, "Unserializing Arm CpuLocalTimer\n");
382
383 UNSERIALIZE_SCALAR(intNumTimer);
384 UNSERIALIZE_SCALAR(intNumWatchdog);
385
386 uint32_t timer_control_serial;
387 UNSERIALIZE_SCALAR(timer_control_serial);
388 timerControl = timer_control_serial;
389 uint32_t watchdog_control_serial;
390 UNSERIALIZE_SCALAR(watchdog_control_serial);
391 watchdogControl = watchdog_control_serial;
392
393 UNSERIALIZE_SCALAR(rawIntTimer);

--- 22 unchanged lines hidden (view full) ---

416 }
417}
418
419
420
421void
422CpuLocalTimer::serialize(CheckpointOut &cp) const
423{
424 for (int i = 0; i < CPU_MAX; i++)
425 localTimer[i].serializeSection(cp, csprintf("timer%d", i));
426}
427
428void
429CpuLocalTimer::unserialize(CheckpointIn &cp)
430{
431 for (int i = 0; i < CPU_MAX; i++)
432 localTimer[i].unserializeSection(cp, csprintf("timer%d", i));
433}
434
435CpuLocalTimer *
436CpuLocalTimerParams::create()
437{
438 return new CpuLocalTimer(this);
439}