kperf_sys/
constants.rs

1/// C Style enum in rust
2/// Can't use an actual rust enum, read this: (https://mdaverde.com/posts/rust-bindgen-enum/)
3pub mod kpep_config_error_code {
4    pub type Type = ::std::os::raw::c_uint;
5    pub const KPEP_CONFIG_ERROR_NONE: Type = 0;
6    pub const KPEP_CONFIG_ERROR_INVALID_ARGUMENT: Type = 1;
7    pub const KPEP_CONFIG_ERROR_OUT_OF_MEMORY: Type = 2;
8    pub const KPEP_CONFIG_ERROR_IO: Type = 3;
9    pub const KPEP_CONFIG_ERROR_BUFFER_TOO_SMALL: Type = 4;
10    pub const KPEP_CONFIG_ERROR_CUR_SYSTEM_UNKNOWN: Type = 5;
11    pub const KPEP_CONFIG_ERROR_DB_PATH_INVALID: Type = 6;
12    pub const KPEP_CONFIG_ERROR_DB_NOT_FOUND: Type = 7;
13    pub const KPEP_CONFIG_ERROR_DB_ARCH_UNSUPPORTED: Type = 8;
14    pub const KPEP_CONFIG_ERROR_DB_VERSION_UNSUPPORTED: Type = 9;
15    pub const KPEP_CONFIG_ERROR_DB_CORRUPT: Type = 10;
16    pub const KPEP_CONFIG_ERROR_EVENT_NOT_FOUND: Type = 11;
17    pub const KPEP_CONFIG_ERROR_CONFLICTING_EVENTS: Type = 12;
18    pub const KPEP_CONFIG_ERROR_COUNTERS_NOT_FORCED: Type = 13;
19    pub const KPEP_CONFIG_ERROR_EVENT_UNAVAILABLE: Type = 14;
20    pub const KPEP_CONFIG_ERROR_ERRNO: Type = 15;
21    pub const KPEP_CONFIG_ERROR_MAX: Type = 16;
22}
23
24// Cross-platform class constants
25pub const KPC_CLASS_FIXED: u32 = 0;
26pub const KPC_CLASS_CONFIGURABLE: u32 = 1;
27pub const KPC_CLASS_POWER: u32 = 2;
28pub const KPC_CLASS_RAWPMU: u32 = 3;
29
30// Cross-platform class mask constants
31pub const KPC_CLASS_FIXED_MASK: u32 = 1 << KPC_CLASS_FIXED;
32pub const KPC_CLASS_CONFIGURABLE_MASK: u32 = 1 << KPC_CLASS_CONFIGURABLE;
33pub const KPC_CLASS_POWER_MASK: u32 = 1 << KPC_CLASS_POWER;
34pub const KPC_CLASS_RAWPMU_MASK: u32 = 1 << KPC_CLASS_RAWPMU;
35
36// PMU version constants
37pub const KPC_PMU_ERROR: u32 = 0; // Error
38pub const KPC_PMU_INTEL_V3: u32 = 1; // Intel
39pub const KPC_PMU_ARM_APPLE: u32 = 2; // ARM64
40pub const KPC_PMU_INTEL_V2: u32 = 3; // Old intel
41pub const KPC_PMU_ARM_V2: u32 = 4; // Old ARM
42
43// The maximum number of counters we could read from every class in one go.
44// ARMV7: FIXED: 1, CONFIGURABLE: 4
45// ARM32: FIXED: 2, CONFIGURABLE: 6
46// ARM64: FIXED: 2, CONFIGURABLE: CORE_NCTRS - FIXED (6 or 8)
47// x86: 32
48pub const KPC_MAX_COUNTERS: u32 = 32;
49
50// Bits for defining what to do on an action.
51// Defined in https://github.com/apple/darwin-xnu/blob/main/osfmk/kperf/action.h
52pub const KPERF_SAMPLER_TH_INFO: u32 = 1 << 0;
53pub const KPERF_SAMPLER_TH_SNAPSHOT: u32 = 1 << 1;
54pub const KPERF_SAMPLER_KSTACK: u32 = 1 << 2;
55pub const KPERF_SAMPLER_USTACK: u32 = 1 << 3;
56pub const KPERF_SAMPLER_PMC_THREAD: u32 = 1 << 4;
57pub const KPERF_SAMPLER_PMC_CPU: u32 = 1 << 5;
58pub const KPERF_SAMPLER_PMC_CONFIG: u32 = 1 << 6;
59pub const KPERF_SAMPLER_MEMINFO: u32 = 1 << 7;
60pub const KPERF_SAMPLER_TH_SCHEDULING: u32 = 1 << 8;
61pub const KPERF_SAMPLER_TH_DISPATCH: u32 = 1 << 9;
62pub const KPERF_SAMPLER_TK_SNAPSHOT: u32 = 1 << 10;
63pub const KPERF_SAMPLER_SYS_MEM: u32 = 1 << 11;
64pub const KPERF_SAMPLER_TH_INSCYC: u32 = 1 << 12;
65pub const KPERF_SAMPLER_TK_INFO: u32 = 1 << 13;
66
67// Maximum number of kperf action ids.
68pub const KPERF_ACTION_MAX: u32 = 32;
69
70// Maximum number of kperf timer ids.
71pub const KPERF_TIMER_MAX: u32 = 8;
72
73// KPEP CPU archtecture constants.
74pub const KPEP_ARCH_I386: u32 = 0;
75pub const KPEP_ARCH_X86_64: u32 = 1;
76pub const KPEP_ARCH_ARM: u32 = 2;
77pub const KPEP_ARCH_ARM64: u32 = 3;