dev-arm: Make CNTFRQ a GenericTimer parameter
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Tue, 26 May 2020 09:45:36 +0000 (10:45 +0100)
committerBobby R. Bruce <bbruce@ucdavis.edu>
Thu, 28 May 2020 22:44:12 +0000 (22:44 +0000)
This register should be in theory initialized by the highest
priviledged software. We do this in gem5 to avoid KVM
complications (the gem5 firmware won't run at highest EL)

JIRA: https://gem5.atlassian.net/browse/GEM5-611

Change-Id: I62d368105af48584f2fe9671de7c70b484b40c12
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Ciro Santilli <ciro.santilli@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29612
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: Bobby R. Bruce <bbruce@ucdavis.edu>
src/dev/arm/GenericTimer.py
src/dev/arm/generic_timer.cc
src/dev/arm/generic_timer.hh

index 077b6f65ddf30d1e9a501b47dc0e5c6f598c865c..ed81b24715b69cc42902a5ecf36289ec92c6f993 100644 (file)
@@ -89,6 +89,15 @@ Reference:
     int_virt = Param.ArmPPI("Virtual timer interrupt")
     int_hyp = Param.ArmPPI("Hypervisor timer interrupt")
 
+    # This value should be in theory initialized by the highest
+    # priviledged software. We do this in gem5 to avoid KVM
+    # complications (the gem5 firmware won't run at highest EL)
+    #
+    # PLEASE note: change this parameter only if using the gem5 bootloader
+    # Another real world bootloader might be changing the CNTFRQ register
+    # value, so this initial value will be discarded
+    cntfrq = Param.UInt64(0x1800000, "Value for the CNTFRQ timer register")
+
     def generateDeviceTree(self, state):
         node = FdtNode("timer")
 
index 7ba0374a4458d8c8a84077380ef161fb9b230136..51a52c723f587be29df04862ed28f7d1474ff0e6 100644 (file)
@@ -689,6 +689,42 @@ GenericTimer::readMiscReg(int reg, unsigned cpu)
     }
 }
 
+GenericTimer::CoreTimers::CoreTimers(GenericTimer &_parent,
+    ArmSystem &system, unsigned cpu,
+    ArmInterruptPin *_irqPhysS, ArmInterruptPin *_irqPhysNS,
+    ArmInterruptPin *_irqVirt, ArmInterruptPin *_irqHyp)
+      : parent(_parent),
+        cntfrq(parent.params()->cntfrq),
+        threadContext(system.getThreadContext(cpu)),
+        irqPhysS(_irqPhysS),
+        irqPhysNS(_irqPhysNS),
+        irqVirt(_irqVirt),
+        irqHyp(_irqHyp),
+        physS(csprintf("%s.phys_s_timer%d", parent.name(), cpu),
+              system, parent, parent.systemCounter,
+              _irqPhysS),
+        // This should really be phys_timerN, but we are stuck with
+        // arch_timer for backwards compatibility.
+        physNS(csprintf("%s.arch_timer%d", parent.name(), cpu),
+             system, parent, parent.systemCounter,
+             _irqPhysNS),
+        virt(csprintf("%s.virt_timer%d", parent.name(), cpu),
+           system, parent, parent.systemCounter,
+           _irqVirt),
+        hyp(csprintf("%s.hyp_timer%d", parent.name(), cpu),
+           system, parent, parent.systemCounter,
+           _irqHyp),
+        physEvStream{
+           EventFunctionWrapper([this]{ physEventStreamCallback(); },
+           csprintf("%s.phys_event_gen%d", parent.name(), cpu)), 0, 0
+        },
+        virtEvStream{
+           EventFunctionWrapper([this]{ virtEventStreamCallback(); },
+           csprintf("%s.virt_event_gen%d", parent.name(), cpu)), 0, 0
+        }
+{
+}
+
 void
 GenericTimer::CoreTimers::physEventStreamCallback()
 {
index b74b19a16da43d79b064fea8998cf491f5f1a6ba..75051c32b33edba6bdf26e1bf5772ee87e1a9aa3 100644 (file)
@@ -293,38 +293,10 @@ class GenericTimer : public SimObject
       public:
         CoreTimers(GenericTimer &_parent, ArmSystem &system, unsigned cpu,
                    ArmInterruptPin *_irqPhysS, ArmInterruptPin *_irqPhysNS,
-                   ArmInterruptPin *_irqVirt, ArmInterruptPin *_irqHyp)
-            : parent(_parent),
-              threadContext(system.getThreadContext(cpu)),
-              irqPhysS(_irqPhysS),
-              irqPhysNS(_irqPhysNS),
-              irqVirt(_irqVirt),
-              irqHyp(_irqHyp),
-              physS(csprintf("%s.phys_s_timer%d", parent.name(), cpu),
-                     system, parent, parent.systemCounter,
-                     _irqPhysS),
-              // This should really be phys_timerN, but we are stuck with
-              // arch_timer for backwards compatibility.
-              physNS(csprintf("%s.arch_timer%d", parent.name(), cpu),
-                     system, parent, parent.systemCounter,
-                     _irqPhysNS),
-              virt(csprintf("%s.virt_timer%d", parent.name(), cpu),
-                   system, parent, parent.systemCounter,
-                   _irqVirt),
-              hyp(csprintf("%s.hyp_timer%d", parent.name(), cpu),
-                   system, parent, parent.systemCounter,
-                   _irqHyp),
-              physEvStream{
-                   EventFunctionWrapper([this]{ physEventStreamCallback(); },
-                   csprintf("%s.phys_event_gen%d", parent.name(), cpu)), 0, 0
-              },
-              virtEvStream{
-                   EventFunctionWrapper([this]{ virtEventStreamCallback(); },
-                   csprintf("%s.virt_event_gen%d", parent.name(), cpu)), 0, 0
-              }
-        {
-            cntfrq = 0x01800000;
-        }
+                   ArmInterruptPin *_irqVirt, ArmInterruptPin *_irqHyp);
+
+        /// Generic Timer parent reference
+        GenericTimer &parent;
 
         /// System counter frequency as visible from this core
         uint32_t cntfrq;
@@ -335,9 +307,6 @@ class GenericTimer : public SimObject
         /// Hypervisor control register
         CNTHCTL cnthctl;
 
-        /// Generic Timer parent reference
-        GenericTimer &parent;
-
         /// Thread (HW) context associated to this PE implementation
         ThreadContext *threadContext;