Deleted Added
sdiff udiff text old ( 10847:1826ee736709 ) new ( 10905:a6ca6831e775 )
full compact
1/*
2 * Copyright (c) 2013, 2015 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

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

61 warn_once("The frequency of the system counter has already been set");
62 }
63 _freq = freq;
64 _period = (1.0 / freq) * SimClock::Frequency;
65 _resetTick = curTick();
66}
67
68void
69SystemCounter::serialize(std::ostream &os) const
70{
71 SERIALIZE_SCALAR(_regCntkctl);
72 SERIALIZE_SCALAR(_freq);
73 SERIALIZE_SCALAR(_period);
74 SERIALIZE_SCALAR(_resetTick);
75}
76
77void
78SystemCounter::unserialize(Checkpoint *cp,
79 const std::string &section)
80{
81 // We didn't handle CNTKCTL in this class before, assume it's zero
82 // if it isn't present.
83 if (!UNSERIALIZE_OPT_SCALAR(_regCntkctl))
84 _regCntkctl = 0;
85 UNSERIALIZE_SCALAR(_freq);
86 UNSERIALIZE_SCALAR(_period);
87 UNSERIALIZE_SCALAR(_resetTick);

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

170
171uint64_t
172ArchTimer::value() const
173{
174 return _systemCounter.value() - _offset;
175}
176
177void
178ArchTimer::serialize(std::ostream &os) const
179{
180 paramOut(os, "control_serial", _control);
181 SERIALIZE_SCALAR(_counterLimit);
182 SERIALIZE_SCALAR(_offset);
183
184 const bool event_scheduled(_counterLimitReachedEvent.scheduled());
185 SERIALIZE_SCALAR(event_scheduled);
186 if (event_scheduled) {
187 const Tick event_time(_counterLimitReachedEvent.when());
188 SERIALIZE_SCALAR(event_time);
189 }
190}
191
192void
193ArchTimer::unserialize(Checkpoint *cp,
194 const std::string &section)
195{
196 paramIn(cp, section, "control_serial", _control);
197 // We didn't serialize an offset before we added support for the
198 // virtual timer. Consider it optional to maintain backwards
199 // compatibility.
200 if (!UNSERIALIZE_OPT_SCALAR(_offset))
201 _offset = 0;
202 bool event_scheduled;
203 UNSERIALIZE_SCALAR(event_scheduled);
204 if (event_scheduled) {

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

235 gic(p->gic),
236 irqPhys(p->int_phys),
237 irqVirt(p->int_virt)
238{
239 dynamic_cast<ArmSystem &>(*p->system).setGenericTimer(this);
240}
241
242void
243GenericTimer::serialize(std::ostream &os)
244{
245 paramOut(os, "cpu_count", timers.size());
246
247 nameOut(os, csprintf("%s.sys_counter", name()));
248 systemCounter.serialize(os);
249
250 for (int i = 0; i < timers.size(); ++i) {
251 CoreTimers &core(getTimers(i));
252
253 nameOut(os, core.phys.name());
254 core.phys.serialize(os);
255
256 nameOut(os, core.virt.name());
257 core.virt.serialize(os);
258 }
259}
260
261void
262GenericTimer::unserialize(Checkpoint *cp, const std::string &section)
263{
264 systemCounter.unserialize(cp, csprintf("%s.sys_counter", section));
265
266 // Try to unserialize the CPU count. Old versions of the timer
267 // model assumed a 8 CPUs, so we fall back to that if the field
268 // isn't present.
269 static const unsigned OLD_CPU_MAX = 8;
270 unsigned cpu_count;
271 if (!UNSERIALIZE_OPT_SCALAR(cpu_count)) {
272 warn("Checkpoint does not contain CPU count, assuming %i CPUs\n",
273 OLD_CPU_MAX);
274 cpu_count = OLD_CPU_MAX;
275 }
276
277 for (int i = 0; i < cpu_count; ++i) {
278 CoreTimers &core(getTimers(i));
279 // This should really be phys_timerN, but we are stuck with
280 // arch_timer for backwards compatibility.
281 core.phys.unserialize(cp, csprintf("%s.arch_timer%d", section, i));
282 core.virt.unserialize(cp, csprintf("%s.virt_timer%d", section, i));
283 }
284}
285
286
287GenericTimer::CoreTimers &
288GenericTimer::getTimers(int cpu_id)
289{
290 if (cpu_id >= timers.size())

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

493 ArchTimer::Interrupt(*p->gic, p->int_phys)),
494 virtTimer(csprintf("%s.virt_timer0", name()),
495 *this, systemCounter,
496 ArchTimer::Interrupt(*p->gic, p->int_virt))
497{
498}
499
500void
501GenericTimerMem::serialize(std::ostream &os)
502{
503 paramOut(os, "timer_count", 1);
504
505 nameOut(os, csprintf("%s.sys_counter", name()));
506 systemCounter.serialize(os);
507
508 nameOut(os, physTimer.name());
509 physTimer.serialize(os);
510
511 nameOut(os, virtTimer.name());
512 virtTimer.serialize(os);
513}
514
515void
516GenericTimerMem::unserialize(Checkpoint *cp, const std::string &section)
517{
518 systemCounter.unserialize(cp, csprintf("%s.sys_counter", section));
519
520 unsigned timer_count;
521 UNSERIALIZE_SCALAR(timer_count);
522 // The timer count variable is just here for future versions where
523 // we support more than one set of timers.
524 if (timer_count != 1)
525 panic("Incompatible checkpoint: Only one set of timers supported");
526
527 physTimer.unserialize(cp, csprintf("%s.phys_timer0", section));
528 virtTimer.unserialize(cp, csprintf("%s.virt_timer0", section));
529}
530
531Tick
532GenericTimerMem::read(PacketPtr pkt)
533{
534 const unsigned size(pkt->getSize());
535 const Addr addr(pkt->getAddr());
536 uint64_t value;

--- 291 unchanged lines hidden ---