Andrew Jones <andrew.jones@xxxxxxxxx> writes:
+#if defined(__aarch64__) + +#include "arch_timer.h" + +uint64_t cycles_read(void) +{ + return timer_get_cntct(VIRTUAL); +} + +double cycles_to_ns(struct kvm_vcpu *vcpu, double cycles) +{ + return cycles * (1e9 / timer_get_cntfrq()); +} + +#elif defined(__x86_64__) + +#include "processor.h" + +uint64_t cycles_read(void) +{ + return rdtsc(); +} + +double cycles_to_ns(struct kvm_vcpu *vcpu, double cycles) +{ + uint64_t tsc_khz = __vcpu_ioctl(vcpu, KVM_GET_TSC_KHZ, NULL); + + return cycles * (1e9 / (tsc_khz * 1000)); +} +#endif
Instead of the #ifdef's why not must put these functions in lib/ARCH/processor.c?
Seems like a good suggestion.