diff options
author | Adrian Herrera <adrian.herrera@arm.com> | 2019-10-28 20:28:51 +0000 |
---|---|---|
committer | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2019-12-10 13:12:10 +0000 |
commit | acd11787c9a650115efe13076f9d8d24b6332bd5 (patch) | |
tree | f49cee1c7ab0dc127118c61f78f7be6d7c91e7ec /src/dev/arm/generic_timer.cc | |
parent | 7acd6a57c8876c3c5498595d239978b048d28b19 (diff) | |
download | gem5-acd11787c9a650115efe13076f9d8d24b6332bd5.tar.xz |
dev-arm: GenericTimer, configurable base and low freqs
Architecture states the system counter has a fixed base frequency
provided in the first entry of the frequency modes table. Optionally,
other lower frequencies may be specified in consecutive entries.
This patch adds configurable frequencies to the GenericTimer model.
The default base frequency is kept as the one that was previously
hardcoded for backwards compatibility.
The table is not recommended to be updated once the system is running.
Change-Id: Icba0b340a0eb1cbb47dfe7d7e03b547af4570c60
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22425
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/dev/arm/generic_timer.cc')
-rw-r--r-- | src/dev/arm/generic_timer.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/dev/arm/generic_timer.cc b/src/dev/arm/generic_timer.cc index 430b4ebfa..7c1f09add 100644 --- a/src/dev/arm/generic_timer.cc +++ b/src/dev/arm/generic_timer.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, 2017-2018 ARM Limited + * Copyright (c) 2013, 2015, 2017-2018, 2019 ARM Limited * All rights reserved. * * The license below extends only to copyright in the software and shall @@ -36,6 +36,7 @@ * * Authors: Giacomo Gabrielli * Andreas Sandberg + * Adrian Herrera */ #include "dev/arm/generic_timer.hh" @@ -47,10 +48,21 @@ #include "params/GenericTimer.hh" #include "params/GenericTimerMem.hh" -SystemCounter::SystemCounter() - : _freq(0), _period(0), _resetTick(0), _regCntkctl(0) +SystemCounter::SystemCounter(std::vector<uint32_t> &freqs) + : _freqTable(freqs), + _resetTick(0), + _regCntkctl(0) { - setFreq(0x01800000); + fatal_if(_freqTable.empty(), "SystemCounter::SystemCounter: Base " + "frequency not provided\n"); + // Store the table end marker as a 32-bit zero word + _freqTable.push_back(0); + fatal_if(_freqTable.size() > MAX_FREQ_ENTRIES, + "SystemCounter::SystemCounter: Architecture states a maximum of 1004 " + "frequency table entries, limit surpassed\n"); + // Set the active frequency to be the base + _freq = freqs.front(); + _period = (1.0 / _freq) * SimClock::Frequency; } void @@ -221,6 +233,7 @@ ArchTimer::drainResume() GenericTimer::GenericTimer(GenericTimerParams *p) : ClockedObject(p), + systemCounter(p->freqs), system(*p->system) { fatal_if(!p->system, "No system specified, can't instantiate timer.\n"); @@ -528,7 +541,7 @@ GenericTimerMem::GenericTimerMem(GenericTimerMemParams *p) timerRange(RangeSize(p->base + sys->getPageBytes(), sys->getPageBytes())), addrRanges{ctrlRange, timerRange}, - systemCounter(), + systemCounter(p->freqs), physTimer(csprintf("%s.phys_timer0", name()), *this, systemCounter, p->int_phys->get()), |