generic_timer.cc (12971:a7fbe4a6eed7) | generic_timer.cc (12975:f521b0fcc17c) |
---|---|
1/* 2 * Copyright (c) 2013, 2015, 2017-2018 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 --- 80 unchanged lines hidden (view full) --- 89 UNSERIALIZE_SCALAR(_resetTick); 90} 91 92 93 94ArchTimer::ArchTimer(const std::string &name, 95 SimObject &parent, 96 SystemCounter &sysctr, | 1/* 2 * Copyright (c) 2013, 2015, 2017-2018 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 --- 80 unchanged lines hidden (view full) --- 89 UNSERIALIZE_SCALAR(_resetTick); 90} 91 92 93 94ArchTimer::ArchTimer(const std::string &name, 95 SimObject &parent, 96 SystemCounter &sysctr, |
97 const Interrupt &interrupt) | 97 ArmInterruptPin *interrupt) |
98 : _name(name), _parent(parent), _systemCounter(sysctr), 99 _interrupt(interrupt), 100 _control(0), _counterLimit(0), _offset(0), 101 _counterLimitReachedEvent([this]{ counterLimitReached(); }, name) 102{ 103} 104 105void 106ArchTimer::counterLimitReached() 107{ 108 _control.istatus = 1; 109 110 if (!_control.enable) 111 return; 112 113 DPRINTF(Timer, "Counter limit reached\n"); 114 if (!_control.imask) { 115 if (scheduleEvents()) { 116 DPRINTF(Timer, "Causing interrupt\n"); | 98 : _name(name), _parent(parent), _systemCounter(sysctr), 99 _interrupt(interrupt), 100 _control(0), _counterLimit(0), _offset(0), 101 _counterLimitReachedEvent([this]{ counterLimitReached(); }, name) 102{ 103} 104 105void 106ArchTimer::counterLimitReached() 107{ 108 _control.istatus = 1; 109 110 if (!_control.enable) 111 return; 112 113 DPRINTF(Timer, "Counter limit reached\n"); 114 if (!_control.imask) { 115 if (scheduleEvents()) { 116 DPRINTF(Timer, "Causing interrupt\n"); |
117 _interrupt.send(); | 117 _interrupt->raise(); |
118 } else { 119 DPRINTF(Timer, "Kvm mode; skipping simulated interrupt\n"); 120 } 121 } 122} 123 124void 125ArchTimer::updateCounter() --- 88 unchanged lines hidden (view full) --- 214} 215 216void 217ArchTimer::drainResume() 218{ 219 updateCounter(); 220} 221 | 118 } else { 119 DPRINTF(Timer, "Kvm mode; skipping simulated interrupt\n"); 120 } 121 } 122} 123 124void 125ArchTimer::updateCounter() --- 88 unchanged lines hidden (view full) --- 214} 215 216void 217ArchTimer::drainResume() 218{ 219 updateCounter(); 220} 221 |
222void 223ArchTimer::Interrupt::send() 224{ 225 if (_ppi) { 226 _gic.sendPPInt(_irq, _cpu); 227 } else { 228 _gic.sendInt(_irq); 229 } 230} 231 232 233void 234ArchTimer::Interrupt::clear() 235{ 236 if (_ppi) { 237 _gic.clearPPInt(_irq, _cpu); 238 } else { 239 _gic.clearInt(_irq); 240 } 241} 242 243 | |
244GenericTimer::GenericTimer(GenericTimerParams *p) 245 : ClockedObject(p), | 222GenericTimer::GenericTimer(GenericTimerParams *p) 223 : ClockedObject(p), |
246 system(*p->system), 247 gic(p->gic), 248 irqPhysS(p->int_phys_s), 249 irqPhysNS(p->int_phys_ns), 250 irqVirt(p->int_virt), 251 irqHyp(p->int_hyp) | 224 system(*p->system) |
252{ 253 fatal_if(!p->system, "No system specified, can't instantiate timer.\n"); 254 system.setGenericTimer(this); 255} 256 | 225{ 226 fatal_if(!p->system, "No system specified, can't instantiate timer.\n"); 227 system.setGenericTimer(this); 228} 229 |
230const GenericTimerParams * 231GenericTimer::params() const 232{ 233 return dynamic_cast<const GenericTimerParams *>(_params); 234} 235 |
|
257void 258GenericTimer::serialize(CheckpointOut &cp) const 259{ 260 paramOut(cp, "cpu_count", timers.size()); 261 262 systemCounter.serializeSection(cp, "sys_counter"); 263 264 for (int i = 0; i < timers.size(); ++i) { --- 44 unchanged lines hidden (view full) --- 309 310 return *timers[cpu_id]; 311} 312 313void 314GenericTimer::createTimers(unsigned cpus) 315{ 316 assert(timers.size() < cpus); | 236void 237GenericTimer::serialize(CheckpointOut &cp) const 238{ 239 paramOut(cp, "cpu_count", timers.size()); 240 241 systemCounter.serializeSection(cp, "sys_counter"); 242 243 for (int i = 0; i < timers.size(); ++i) { --- 44 unchanged lines hidden (view full) --- 288 289 return *timers[cpu_id]; 290} 291 292void 293GenericTimer::createTimers(unsigned cpus) 294{ 295 assert(timers.size() < cpus); |
296 auto p = static_cast<const GenericTimerParams *>(_params); |
|
317 318 const unsigned old_cpu_count(timers.size()); 319 timers.resize(cpus); 320 for (unsigned i = old_cpu_count; i < cpus; ++i) { | 297 298 const unsigned old_cpu_count(timers.size()); 299 timers.resize(cpus); 300 for (unsigned i = old_cpu_count; i < cpus; ++i) { |
301 302 ThreadContext *tc = system.getThreadContext(i); 303 |
|
321 timers[i].reset( 322 new CoreTimers(*this, system, i, | 304 timers[i].reset( 305 new CoreTimers(*this, system, i, |
323 irqPhysS, irqPhysNS, irqVirt, irqHyp)); | 306 p->int_phys_s->get(tc), 307 p->int_phys_ns->get(tc), 308 p->int_virt->get(tc), 309 p->int_hyp->get(tc))); |
324 } 325} 326 327 328void 329GenericTimer::setMiscReg(int reg, unsigned cpu, MiscReg val) 330{ 331 CoreTimers &core(getTimers(cpu)); --- 207 unchanged lines hidden (view full) --- 539GenericTimerMem::GenericTimerMem(GenericTimerMemParams *p) 540 : PioDevice(p), 541 ctrlRange(RangeSize(p->base, TheISA::PageBytes)), 542 timerRange(RangeSize(p->base + TheISA::PageBytes, TheISA::PageBytes)), 543 addrRanges{ctrlRange, timerRange}, 544 systemCounter(), 545 physTimer(csprintf("%s.phys_timer0", name()), 546 *this, systemCounter, | 310 } 311} 312 313 314void 315GenericTimer::setMiscReg(int reg, unsigned cpu, MiscReg val) 316{ 317 CoreTimers &core(getTimers(cpu)); --- 207 unchanged lines hidden (view full) --- 525GenericTimerMem::GenericTimerMem(GenericTimerMemParams *p) 526 : PioDevice(p), 527 ctrlRange(RangeSize(p->base, TheISA::PageBytes)), 528 timerRange(RangeSize(p->base + TheISA::PageBytes, TheISA::PageBytes)), 529 addrRanges{ctrlRange, timerRange}, 530 systemCounter(), 531 physTimer(csprintf("%s.phys_timer0", name()), 532 *this, systemCounter, |
547 ArchTimer::Interrupt(*p->gic, p->int_phys)), | 533 p->int_phys->get()), |
548 virtTimer(csprintf("%s.virt_timer0", name()), 549 *this, systemCounter, | 534 virtTimer(csprintf("%s.virt_timer0", name()), 535 *this, systemCounter, |
550 ArchTimer::Interrupt(*p->gic, p->int_virt)) | 536 p->int_virt->get()) |
551{ 552} 553 554void 555GenericTimerMem::serialize(CheckpointOut &cp) const 556{ 557 paramOut(cp, "timer_count", 1); 558 --- 319 unchanged lines hidden --- | 537{ 538} 539 540void 541GenericTimerMem::serialize(CheckpointOut &cp) const 542{ 543 paramOut(cp, "timer_count", 1); 544 --- 319 unchanged lines hidden --- |