timer_cpulocal.cc (9525:0587c8983d47) timer_cpulocal.cc (9545:508784fad4e5)
1/*
1/*
2 * Copyright (c) 2010-2011 ARM Limited
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;
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].clock = clock;
62 localTimer[i].cpuNum = i;
63 }
64 pioSize = 0x38;
65}
66
67CpuLocalTimer::Timer::Timer()
68 : timerControl(0x0), watchdogControl(0x0), rawIntTimer(false), rawIntWatchdog(false),
69 rawResetWatchdog(false), watchdogDisableReg(0x0), pendingIntTimer(false), pendingIntWatchdog(false),

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

99 Tick time;
100
101 switch(daddr) {
102 case TimerLoadReg:
103 pkt->set<uint32_t>(timerLoadValue);
104 break;
105 case TimerCounterReg:
106 DPRINTF(Timer, "Event schedule for timer %d, clock=%d, prescale=%d\n",
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",
107 timerZeroEvent.when(), clock, timerControl.prescalar);
106 timerZeroEvent.when(), parent->clockPeriod(),
107 timerControl.prescalar);
108 time = timerZeroEvent.when() - curTick();
108 time = timerZeroEvent.when() - curTick();
109 time = time / clock / power(16, timerControl.prescalar);
109 time = time / parent->clockPeriod() /
110 power(16, timerControl.prescalar);
110 DPRINTF(Timer, "-- returning counter at %d\n", time);
111 pkt->set<uint32_t>(time);
112 break;
113 case TimerControlReg:
114 pkt->set<uint32_t>(timerControl);
115 break;
116 case TimerIntStatusReg:
117 pkt->set<uint32_t>(rawIntTimer);
118 break;
119 case WatchdogLoadReg:
120 pkt->set<uint32_t>(watchdogLoadValue);
121 break;
122 case WatchdogCounterReg:
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:
123 DPRINTF(Timer, "Event schedule for watchdog %d, clock=%d, prescale=%d\n",
124 watchdogZeroEvent.when(), clock, watchdogControl.prescalar);
124 DPRINTF(Timer,
125 "Event schedule for watchdog %d, clock=%d, prescale=%d\n",
126 watchdogZeroEvent.when(), parent->clockPeriod(),
127 watchdogControl.prescalar);
125 time = watchdogZeroEvent.when() - curTick();
128 time = watchdogZeroEvent.when() - curTick();
126 time = time / clock / power(16, watchdogControl.prescalar);
129 time = time / parent->clockPeriod() /
130 power(16, watchdogControl.prescalar);
127 DPRINTF(Timer, "-- returning counter at %d\n", time);
128 pkt->set<uint32_t>(time);
129 break;
130 case WatchdogControlReg:
131 pkt->set<uint32_t>(watchdogControl);
132 break;
133 case WatchdogIntStatusReg:
134 pkt->set<uint32_t>(rawIntWatchdog);

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

244//XXX: Two functions are needed because the control registers are different types
245void
246CpuLocalTimer::Timer::restartTimerCounter(uint32_t val)
247{
248 DPRINTF(Timer, "Resetting timer counter with value %#x\n", val);
249 if (!timerControl.enable)
250 return;
251
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
252 Tick time = clock * power(16, timerControl.prescalar);
256 Tick time = parent->clockPeriod() * power(16, timerControl.prescalar);
253 time *= val;
254
255 if (timerZeroEvent.scheduled()) {
256 DPRINTF(Timer, "-- Event was already schedule, de-scheduling\n");
257 parent->deschedule(timerZeroEvent);
258 }
259 parent->schedule(timerZeroEvent, curTick() + time);
260 DPRINTF(Timer, "-- Scheduling new event for: %d\n", curTick() + time);
261}
262
263void
264CpuLocalTimer::Timer::restartWatchdogCounter(uint32_t val)
265{
266 DPRINTF(Timer, "Resetting watchdog counter with value %#x\n", val);
267 if (!watchdogControl.enable)
268 return;
269
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
270 Tick time = clock * power(16, watchdogControl.prescalar);
274 Tick time = parent->clockPeriod() * power(16, watchdogControl.prescalar);
271 time *= val;
272
273 if (watchdogZeroEvent.scheduled()) {
274 DPRINTF(Timer, "-- Event was already schedule, de-scheduling\n");
275 parent->deschedule(watchdogZeroEvent);
276 }
277 parent->schedule(watchdogZeroEvent, curTick() + time);
278 DPRINTF(Timer, "-- Scheduling new event for: %d\n", curTick() + time);

--- 160 unchanged lines hidden ---
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 ---