laforge has submitted this change. ( https://gerrit.osmocom.org/c/gapk/+/33620 )
Change subject: aarch64: add get_cycles ......................................................................
aarch64: add get_cycles
borrowed from arch/arm64/include/asm/arch_timer.h
Change-Id: I489fb8346fbc7440f40695f01d80a89b90761165 --- A .checkpatch.conf M include/osmocom/gapk/get_cycles.h 2 files changed, 22 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
diff --git a/.checkpatch.conf b/.checkpatch.conf new file mode 100644 index 0000000..58a0b87 --- /dev/null +++ b/.checkpatch.conf @@ -0,0 +1 @@ +--ignore NEW_TYPEDEFS diff --git a/include/osmocom/gapk/get_cycles.h b/include/osmocom/gapk/get_cycles.h index 40ac570..25376a1 100644 --- a/include/osmocom/gapk/get_cycles.h +++ b/include/osmocom/gapk/get_cycles.h @@ -103,6 +103,16 @@ #endif return ret & ~TICK_PRIV_BIT; } +#elif defined(__aarch64__) + +typedef unsigned long cycles_t; +static inline cycles_t get_cycles(void) +{ + cycles_t cval; + asm volatile("isb" : : : "memory"); + asm volatile("mrs %0, cntvct_el0" : "=r" (cval)); + return cval; +} #elif defined(__PPC__) #define CPU_FTR_601 0x00000100 typedef unsigned long cycles_t;