28 F(int, kpc_get_counting, void) \
29 F(int, kpc_force_all_ctrs_set, int) \
30 F(int, kpc_set_counting, uint32_t) \
31 F(int, kpc_set_thread_counting, uint32_t) \
32 F(int, kpc_set_config, uint32_t, void *) \
33 F(int, kpc_get_config, uint32_t, void *) \
34 F(int, kpc_set_period, uint32_t, void *) \
35 F(int, kpc_get_period, uint32_t, void *) \
36 F(uint32_t, kpc_get_counter_count, uint32_t) \
37 F(uint32_t, kpc_get_config_count, uint32_t) \
38 F(int, kperf_sample_get, int *) \
39 F(int, kpc_get_thread_counters, int, unsigned int, void *)
41 #define F(ret, name, ...) \
42 typedef ret name##proc(__VA_ARGS__); \
43 static name##proc *name = NULL;
47 #define CFGWORD_EL0A32EN_MASK (0x10000)
48 #define CFGWORD_EL0A64EN_MASK (0x20000)
49 #define CFGWORD_EL1EN_MASK (0x40000)
50 #define CFGWORD_EL3EN_MASK (0x80000)
51 #define CFGWORD_ALLMODES_MASK (0xf0000)
54 #define CPMU_CORE_CYCLE 0x02
55 #define CPMU_INST_A64 0x8c
56 #define CPMU_INST_BRANCH 0x8d
57 #define CPMU_SYNC_DC_LOAD_MISS 0xbf
58 #define CPMU_SYNC_DC_STORE_MISS 0xc0
59 #define CPMU_SYNC_DTLB_MISS 0xc1
60 #define CPMU_SYNC_ST_HIT_YNGR_LD 0xc4
61 #define CPMU_SYNC_BR_ANY_MISP 0xcb
62 #define CPMU_FED_IC_MISS_DEM 0xd3
63 #define CPMU_FED_ITLB_MISS 0xd4
65 #define KPC_CLASS_FIXED_MASK (1 << 0)
66 #define KPC_CLASS_CONFIGURABLE_MASK (1 << 1)
67 #define KPC_CLASS_POWER_MASK (1 << 2)
68 #define KPC_CLASS_RAWPMU_MASK (1 << 3)
70 #define COUNTERS_COUNT 10
71 #define CONFIG_COUNT 8
72 #define KPC_MASK (KPC_CLASS_CONFIGURABLE_MASK | KPC_CLASS_FIXED_MASK)
79 av_assert0(kperf = dlopen(
"/System/Library/PrivateFrameworks/kperf.framework/Versions/A/kperf", RTLD_LAZY));
81 #define F(ret, name, ...) av_assert0(name = (name##proc *)(dlsym(kperf, #name)));