1 #include <darwintest.h> 2 #include <sys/sysctl.h> 3 #include "apple_generic_timer.h" 4 #include "test_utils.h" 5 6 T_GLOBAL_META( 7 T_META_NAMESPACE("xnu.arm"), 8 T_META_RADAR_COMPONENT_NAME("xnu"), 9 T_META_RADAR_COMPONENT_VERSION("arm"), 10 T_META_ENABLED(TARGET_CPU_ARM64), 11 T_META_OWNER("xi_han"), 12 T_META_RUN_CONCURRENTLY(true), 13 XNU_T_META_SOC_SPECIFIC 14 ); 15 16 #define AIDR_AGT (1ULL << 32) 17 T_DECL(apple_generic_timer, 18 "Test that CNTFRQ_EL0 reads the correct frequency") 19 { 20 uint64_t aidr; 21 size_t sysctl_size = sizeof(aidr); 22 sysctlbyname("machdep.cpu.sysreg_AIDR_EL1", &aidr, &sysctl_size, NULL, 0); 23 24 const bool has_agt = aidr & AIDR_AGT; 25 26 /* When AIDR_AGT is set, expect 1 GHz; otherwise expect 24 MHz. */ 27 agt_test_helper(has_agt); 28 } 29