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 --- 42 unchanged lines hidden (view full) --- 53 // Initialize the timer registers for each per cpu timer 54 for (int i = 0; i < CPU_MAX; i++) { 55 std::stringstream oss; 56 oss << name() << ".timer" << i; 57 localTimer[i]._name = oss.str(); 58 localTimer[i].parent = this; 59 localTimer[i].intNumTimer = p->int_num_timer; 60 localTimer[i].intNumWatchdog = p->int_num_watchdog; |
61 localTimer[i].cpuNum = i; 62 } 63 pioSize = 0x38; 64} 65 66CpuLocalTimer::Timer::Timer() 67 : timerControl(0x0), watchdogControl(0x0), rawIntTimer(false), rawIntWatchdog(false), 68 rawResetWatchdog(false), watchdogDisableReg(0x0), pendingIntTimer(false), pendingIntWatchdog(false), --- 29 unchanged lines hidden (view full) --- 98 Tick time; 99 100 switch(daddr) { 101 case TimerLoadReg: 102 pkt->set<uint32_t>(timerLoadValue); 103 break; 104 case TimerCounterReg: 105 DPRINTF(Timer, "Event schedule for timer %d, clock=%d, prescale=%d\n", |
106 timerZeroEvent.when(), parent->clockPeriod(), 107 timerControl.prescalar); |
108 time = timerZeroEvent.when() - curTick(); |
109 time = time / parent->clockPeriod() / 110 power(16, timerControl.prescalar); |
111 DPRINTF(Timer, "-- returning counter at %d\n", time); 112 pkt->set<uint32_t>(time); 113 break; 114 case TimerControlReg: 115 pkt->set<uint32_t>(timerControl); 116 break; 117 case TimerIntStatusReg: 118 pkt->set<uint32_t>(rawIntTimer); 119 break; 120 case WatchdogLoadReg: 121 pkt->set<uint32_t>(watchdogLoadValue); 122 break; 123 case WatchdogCounterReg: |
124 DPRINTF(Timer, 125 "Event schedule for watchdog %d, clock=%d, prescale=%d\n", 126 watchdogZeroEvent.when(), parent->clockPeriod(), 127 watchdogControl.prescalar); |
128 time = watchdogZeroEvent.when() - curTick(); |
129 time = time / parent->clockPeriod() / 130 power(16, watchdogControl.prescalar); |
131 DPRINTF(Timer, "-- returning counter at %d\n", time); 132 pkt->set<uint32_t>(time); 133 break; 134 case WatchdogControlReg: 135 pkt->set<uint32_t>(watchdogControl); 136 break; 137 case WatchdogIntStatusReg: 138 pkt->set<uint32_t>(rawIntWatchdog); --- 109 unchanged lines hidden (view full) --- 248//XXX: Two functions are needed because the control registers are different types 249void 250CpuLocalTimer::Timer::restartTimerCounter(uint32_t val) 251{ 252 DPRINTF(Timer, "Resetting timer counter with value %#x\n", val); 253 if (!timerControl.enable) 254 return; 255 |
256 Tick time = parent->clockPeriod() * power(16, timerControl.prescalar); |
257 time *= val; 258 259 if (timerZeroEvent.scheduled()) { 260 DPRINTF(Timer, "-- Event was already schedule, de-scheduling\n"); 261 parent->deschedule(timerZeroEvent); 262 } 263 parent->schedule(timerZeroEvent, curTick() + time); 264 DPRINTF(Timer, "-- Scheduling new event for: %d\n", curTick() + time); 265} 266 267void 268CpuLocalTimer::Timer::restartWatchdogCounter(uint32_t val) 269{ 270 DPRINTF(Timer, "Resetting watchdog counter with value %#x\n", val); 271 if (!watchdogControl.enable) 272 return; 273 |
274 Tick time = parent->clockPeriod() * power(16, watchdogControl.prescalar); |
275 time *= val; 276 277 if (watchdogZeroEvent.scheduled()) { 278 DPRINTF(Timer, "-- Event was already schedule, de-scheduling\n"); 279 parent->deschedule(watchdogZeroEvent); 280 } 281 parent->schedule(watchdogZeroEvent, curTick() + time); 282 DPRINTF(Timer, "-- Scheduling new event for: %d\n", curTick() + time); --- 160 unchanged lines hidden --- |