diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2013-02-19 05:56:06 -0500 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2013-02-19 05:56:06 -0500 |
commit | 7cd49b24d2523eaf21179946e291c46c6acf5bfc (patch) | |
tree | 91c066608dfb6e4ca52dd25e91a61719848d64a7 /src/dev | |
parent | 5c7ebee434a0328802c01b38c19845c50ae75cab (diff) | |
download | gem5-7cd49b24d2523eaf21179946e291c46c6acf5bfc.tar.xz |
sim: Make clock private and access using clockPeriod()
This patch makes the clock member private to the ClockedObject and
forces all children to access it using clockPeriod(). This makes it
impossible to inadvertently change the clock, and also makes it easier
to transition to a situation where the clock is derived from e.g. a
clock domain, or through a multiplier.
Diffstat (limited to 'src/dev')
-rw-r--r-- | src/dev/arm/timer_cpulocal.cc | 22 | ||||
-rw-r--r-- | src/dev/arm/timer_cpulocal.hh | 3 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/dev/arm/timer_cpulocal.cc b/src/dev/arm/timer_cpulocal.cc index 84bc12aa9..458df0674 100644 --- a/src/dev/arm/timer_cpulocal.cc +++ b/src/dev/arm/timer_cpulocal.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2011 ARM Limited + * Copyright (c) 2010-2013 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -58,7 +58,6 @@ CpuLocalTimer::CpuLocalTimer(Params *p) localTimer[i].parent = this; localTimer[i].intNumTimer = p->int_num_timer; localTimer[i].intNumWatchdog = p->int_num_watchdog; - localTimer[i].clock = clock; localTimer[i].cpuNum = i; } pioSize = 0x38; @@ -104,9 +103,11 @@ CpuLocalTimer::Timer::read(PacketPtr pkt, Addr daddr) break; case TimerCounterReg: DPRINTF(Timer, "Event schedule for timer %d, clock=%d, prescale=%d\n", - timerZeroEvent.when(), clock, timerControl.prescalar); + timerZeroEvent.when(), parent->clockPeriod(), + timerControl.prescalar); time = timerZeroEvent.when() - curTick(); - time = time / clock / power(16, timerControl.prescalar); + time = time / parent->clockPeriod() / + power(16, timerControl.prescalar); DPRINTF(Timer, "-- returning counter at %d\n", time); pkt->set<uint32_t>(time); break; @@ -120,10 +121,13 @@ CpuLocalTimer::Timer::read(PacketPtr pkt, Addr daddr) pkt->set<uint32_t>(watchdogLoadValue); break; case WatchdogCounterReg: - DPRINTF(Timer, "Event schedule for watchdog %d, clock=%d, prescale=%d\n", - watchdogZeroEvent.when(), clock, watchdogControl.prescalar); + DPRINTF(Timer, + "Event schedule for watchdog %d, clock=%d, prescale=%d\n", + watchdogZeroEvent.when(), parent->clockPeriod(), + watchdogControl.prescalar); time = watchdogZeroEvent.when() - curTick(); - time = time / clock / power(16, watchdogControl.prescalar); + time = time / parent->clockPeriod() / + power(16, watchdogControl.prescalar); DPRINTF(Timer, "-- returning counter at %d\n", time); pkt->set<uint32_t>(time); break; @@ -249,7 +253,7 @@ CpuLocalTimer::Timer::restartTimerCounter(uint32_t val) if (!timerControl.enable) return; - Tick time = clock * power(16, timerControl.prescalar); + Tick time = parent->clockPeriod() * power(16, timerControl.prescalar); time *= val; if (timerZeroEvent.scheduled()) { @@ -267,7 +271,7 @@ CpuLocalTimer::Timer::restartWatchdogCounter(uint32_t val) if (!watchdogControl.enable) return; - Tick time = clock * power(16, watchdogControl.prescalar); + Tick time = parent->clockPeriod() * power(16, watchdogControl.prescalar); time *= val; if (watchdogZeroEvent.scheduled()) { diff --git a/src/dev/arm/timer_cpulocal.hh b/src/dev/arm/timer_cpulocal.hh index 086dc1c63..f53f5bc25 100644 --- a/src/dev/arm/timer_cpulocal.hh +++ b/src/dev/arm/timer_cpulocal.hh @@ -103,9 +103,6 @@ class CpuLocalTimer : public BasicPioDevice /** Cpu this timer is attached to */ uint32_t cpuNum; - /** Number of ticks in a clock input */ - Tick clock; - /** Control register as specified above */ TimerCtrl timerControl; WatchdogCtrl watchdogControl; |