generic_timer.cc (10847:1826ee736709) | generic_timer.cc (10905:a6ca6831e775) |
---|---|
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 | 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 | 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 | 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 §ion) | 78SystemCounter::unserialize(CheckpointIn &cp) |
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 | 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 |
178ArchTimer::serialize(std::ostream &os) const | 177ArchTimer::serialize(CheckpointOut &cp) const |
179{ | 178{ |
180 paramOut(os, "control_serial", _control); | 179 paramOut(cp, "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 | 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 |
193ArchTimer::unserialize(Checkpoint *cp, 194 const std::string §ion) | 192ArchTimer::unserialize(CheckpointIn &cp) |
195{ | 193{ |
196 paramIn(cp, section, "control_serial", _control); | 194 paramIn(cp, "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 | 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 |
243GenericTimer::serialize(std::ostream &os) | 241GenericTimer::serialize(CheckpointOut &cp) const |
244{ | 242{ |
245 paramOut(os, "cpu_count", timers.size()); | 243 paramOut(cp, "cpu_count", timers.size()); |
246 | 244 |
247 nameOut(os, csprintf("%s.sys_counter", name())); 248 systemCounter.serialize(os); | 245 systemCounter.serializeSection(cp, "sys_counter"); |
249 250 for (int i = 0; i < timers.size(); ++i) { | 246 247 for (int i = 0; i < timers.size(); ++i) { |
251 CoreTimers &core(getTimers(i)); | 248 const CoreTimers &core(*timers[i]); |
252 | 249 |
253 nameOut(os, core.phys.name()); 254 core.phys.serialize(os); 255 256 nameOut(os, core.virt.name()); 257 core.virt.serialize(os); | 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)); |
258 } 259} 260 261void | 254 } 255} 256 257void |
262GenericTimer::unserialize(Checkpoint *cp, const std::string §ion) | 258GenericTimer::unserialize(CheckpointIn &cp) |
263{ | 259{ |
264 systemCounter.unserialize(cp, csprintf("%s.sys_counter", section)); | 260 systemCounter.unserializeSection(cp, "sys_counter"); |
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. | 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. |
281 core.phys.unserialize(cp, csprintf("%s.arch_timer%d", section, i)); 282 core.virt.unserialize(cp, csprintf("%s.virt_timer%d", section, i)); | 277 core.phys.unserializeSection(cp, csprintf("arch_timer%d", i)); 278 core.virt.unserializeSection(cp, csprintf("virt_timer%d", 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 | 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 |
501GenericTimerMem::serialize(std::ostream &os) | 497GenericTimerMem::serialize(CheckpointOut &cp) const |
502{ | 498{ |
503 paramOut(os, "timer_count", 1); | 499 paramOut(cp, "timer_count", 1); |
504 | 500 |
505 nameOut(os, csprintf("%s.sys_counter", name())); 506 systemCounter.serialize(os); | 501 systemCounter.serializeSection(cp, "sys_counter"); |
507 | 502 |
508 nameOut(os, physTimer.name()); 509 physTimer.serialize(os); 510 511 nameOut(os, virtTimer.name()); 512 virtTimer.serialize(os); | 503 physTimer.serializeSection(cp, "phys_timer0"); 504 virtTimer.serializeSection(cp, "virt_timer0"); |
513} 514 515void | 505} 506 507void |
516GenericTimerMem::unserialize(Checkpoint *cp, const std::string §ion) | 508GenericTimerMem::unserialize(CheckpointIn &cp) |
517{ | 509{ |
518 systemCounter.unserialize(cp, csprintf("%s.sys_counter", section)); | 510 systemCounter.unserializeSection(cp, "sys_counter"); |
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 | 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 |
527 physTimer.unserialize(cp, csprintf("%s.phys_timer0", section)); 528 virtTimer.unserialize(cp, csprintf("%s.virt_timer0", section)); | 519 physTimer.unserializeSection(cp, "phys_timer0"); 520 virtTimer.unserializeSection(cp, "virt_timer0"); |
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 --- | 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 --- |