]> git.sur5r.net Git - openocd/commitdiff
aarch64: optimize core state detection
authorMatthias Welwarsky <matthias.welwarsky@sysgo.com>
Tue, 15 Nov 2016 21:10:03 +0000 (22:10 +0100)
committerPaul Fertser <fercerpav@gmail.com>
Fri, 24 Feb 2017 09:13:10 +0000 (09:13 +0000)
Replace loop by right-shift.
Inspired by patch from Alamy Liu

Change-Id: I1285f4f54c0695a93fa42e9863ed8ffa4de00f70
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
Reviewed-on: http://openocd.zylin.com/3985
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
src/target/armv8_dpm.c

index 56e2eb8fef5e7f0ec995bee57338dc9750fd8032..ac53460ebfbee017426438f1f314a30f2bdbaa39 100644 (file)
@@ -51,17 +51,11 @@ enum arm_state armv8_dpm_get_core_state(struct arm_dpm *dpm)
 {
        int el = (dpm->dscr >> 8) & 0x3;
        int rw = (dpm->dscr >> 10) & 0xF;
-       int pos;
 
        dpm->last_el = el;
 
-       /* find the first '0' in DSCR.RW */
-       for (pos = 3; pos >= 0; pos--) {
-               if ((rw & (1 << pos)) == 0)
-                       break;
-       }
-
-       if (el > pos)
+       /* In Debug state, each bit gives the current Execution state of each EL */
+       if ((rw >> el) & 0b1)
                return ARM_STATE_AARCH64;
 
        return ARM_STATE_ARM;