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(CheckpointOut &cp) const
70{
71 SERIALIZE_SCALAR(_regCntkctl);
72 SERIALIZE_SCALAR(_freq);
73 SERIALIZE_SCALAR(_period);
74 SERIALIZE_SCALAR(_resetTick);
75}
76
77void
78SystemCounter::unserialize(CheckpointIn &cp)
79{
80 // We didn't handle CNTKCTL in this class before, assume it's zero
81 // if it isn't present.
82 if (!UNSERIALIZE_OPT_SCALAR(_regCntkctl))
83 _regCntkctl = 0;
84 UNSERIALIZE_SCALAR(_freq);
85 UNSERIALIZE_SCALAR(_period);
86 UNSERIALIZE_SCALAR(_resetTick);

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

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

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

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

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

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

--- 291 unchanged lines hidden ---