qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH target-arm v3 4/8] target-arm: Add arm_ccnt_enabled


From: Peter Crosthwaite
Subject: [Qemu-devel] [PATCH target-arm v3 4/8] target-arm: Add arm_ccnt_enabled function
Date: Mon, 18 Aug 2014 01:14:06 -0700

From: Alistair Francis <address@hidden>

Include a helper function to determine if the CCNT counter
is enabled as well as the constants used to mask the pmccfiltr_el0
and c9_pmxevtyper registers.

Signed-off-by: Alistair Francis <address@hidden>
Signed-off-by: Peter Crosthwaite <address@hidden>
---
Changed since v2 (PMM review):
Blank line for readability
Use switch instead of cascading ifs.
Use true and false.
Drop extraneous #endif #if

 target-arm/helper.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index 7363c8d..0318816 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -547,6 +547,50 @@ static CPAccessResult pmreg_access(CPUARMState *env, const 
ARMCPRegInfo *ri)
 }
 
 #ifndef CONFIG_USER_ONLY
+
+#define PMCCFILTR_NSH 0x8000000
+#define PMCCFILTR_P 0x80000000
+#define PMCCFILTR_U 0x40000000
+
+#define PMXEVTYPER_P 0x80000000
+#define PMXEVTYPER_U 0x40000000
+
+static inline bool arm_ccnt_enabled(CPUARMState *env)
+{
+    /* This does not support checking for the secure/non-secure
+     * components of the PMCCFILTR_EL0 register
+     */
+
+    if (!(env->cp15.c9_pmcr & PMCRE)) {
+        return false;
+    }
+
+    switch (arm_current_pl(env)) {
+    case 2:
+        if (!(env->cp15.pmccfiltr_el0 & PMCCFILTR_NSH)) {
+            return false;
+        } else {
+          break;
+        }
+    case 1:
+        if (env->cp15.pmccfiltr_el0 & PMCCFILTR_P ||
+            env->cp15.c9_pmxevtyper & PMXEVTYPER_P) {
+            return false;
+        } else {
+            break;
+        }
+    case 0:
+        if (env->cp15.pmccfiltr_el0 & PMCCFILTR_U ||
+            env->cp15.c9_pmxevtyper & PMXEVTYPER_U) {
+            return false;
+        } else {
+            break;
+        }
+    }
+
+    return true;
+}
+
 static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
                        uint64_t value)
 {
-- 
2.0.1.1.gfbfc394




reply via email to

[Prev in Thread] Current Thread [Next in Thread]