So it’s a follow-up to this answer. I simply created a terminal app with Xcode and basically pasted the code there but in a loop:
#include <stdint.h>
#include <stdio.h>
#include <string.h>
uint64_t getfreq(void) {
uint64_t value=0;
asm("isb; mrs %0, CNTVCT_EL0" : "=r"(value));
return value;
}
int main() {
do {
printf("CNTVCT_EL0 = 0x%016llXn", getfreq());
} while(1);
}
Issue I have is I get something like this as output:
CNTVCT_EL0 = 0x0000000104CB1910
CNTVCT_EL0 = 0x0000000000000001
CNTVCT_EL0 = 0x0000000000000001
CNTVCT_EL0 = 0x0000000000000001
Why is only the first time the value looks remotely valid (it’s the same if I don’t have a loop) – maybe I need to clear something with another asm instruction?
Xcode Version 15.4 (15F31d)
MacOS 14.5 (23F79)
Mac mini m1 (2020)