From 52b584bc157331a6a8b12a727172c5c6f49c8bfc Mon Sep 17 00:00:00 2001 From: Zbigniew Bodek Date: Tue, 21 Jul 2015 12:50:45 +0000 Subject: [PATCH] Implement get_cyclecount() on ARM64 Use Vritual Counter register associated with Generic Timer to read the cyclecount. Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3134 --- sys/arm64/include/cpu.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/arm64/include/cpu.h b/sys/arm64/include/cpu.h index 33e2af65da4f..15cdd80d4e26 100644 --- a/sys/arm64/include/cpu.h +++ b/sys/arm64/include/cpu.h @@ -43,6 +43,7 @@ #include #include +#include #define TRAPF_PC(tfp) ((tfp)->tf_lr) #define TRAPF_USERMODE(tfp) (((tfp)->tf_elr & (1ul << 63)) == 0) @@ -120,9 +121,11 @@ void swi_vm(void *v); static __inline uint64_t get_cyclecount(void) { + uint64_t ret; - /* TODO: This is bogus */ - return (1); + ret = READ_SPECIALREG(cntvct_el0); + + return (ret); } #define ADDRESS_TRANSLATE_FUNC(stage) \