kperf_sys/
structs.rs

1use libc::{c_char, c_uchar, c_uint, c_ulonglong, c_void, size_t};
2
3#[allow(non_camel_case_types)]
4pub type kpc_config_t = u64;
5
6/// KPEP event (size: 48/28 bytes on 64/32 bit OS)
7#[repr(C)]
8#[allow(non_camel_case_types)]
9pub struct kpep_event {
10    /// Unique name of a event, such as "INST_RETIRED.ANY".
11    pub name: *const c_char,
12    /// Description for this event.
13    pub description: *const c_char,
14    /// Errata, currently NULL.
15    pub errata: *const c_char,
16    /// Alias name, such as "Instructions", "Cycles".
17    pub alias: *const c_char,
18    /// Fallback event name for fixed counter.
19    pub fallback: *const c_char,
20    pub mask: c_uint,
21    pub number: c_uchar,
22    pub umask: c_uchar,
23    pub reserved: c_uchar,
24    pub is_fixed: c_uchar,
25}
26
27/// KPEP database (size: 144/80 bytes on 64/32 bit OS)
28#[allow(non_camel_case_types)]
29#[repr(C)]
30pub struct kpep_db {
31    /// Database name, such as "haswell".
32    pub name: *const c_char,
33    /// Plist name, such as "cpu_7_8_10b282dc".
34    pub cpu_id: *const c_char,
35    /// Marketing name, such as "Intel Haswell".
36    pub marketing_name: *const c_char,
37    /// Plist data (CFDataRef), currently NULL.
38    pub plist_data: *mut c_void,
39    /// All events (CFDict<CFSTR(event_name), kpep_event *>).
40    pub event_map: *mut c_void,
41    /// Event struct buffer (sizeof(kpep_event) * events_count).
42    pub event_arr: *mut kpep_event,
43    /// Fixed counter events (sizeof(kpep_event *)
44    pub fixed_event_arr: *mut *mut kpep_event,
45    /// All aliases (CFDict<CFSTR(event_name), kpep_event *>).
46    pub alias_map: *mut c_void,
47    pub reserved_1: size_t,
48    pub reserved_2: size_t,
49    pub reserved_3: size_t,
50    /// All events count.
51    pub event_count: size_t,
52    pub alias_count: size_t,
53    pub fixed_counter_count: size_t,
54    pub config_counter_count: size_t,
55    pub power_counter_count: size_t,
56    /// see `KPEP CPU archtecture constants` above.
57    pub archtecture: c_uint,
58    pub fixed_counter_bits: c_uint,
59    pub config_counter_bits: c_uint,
60    pub power_counter_bits: c_uint,
61}
62
63/// KPEP config (size: 80/44 bytes on 64/32 bit OS)
64#[repr(C)]
65#[allow(non_camel_case_types)]
66pub struct kpep_config {
67    pub db: *mut kpep_db,
68    /// (sizeof(kpep_event *) * counter_count), init NULL
69    pub ev_arr: *mut *mut kpep_event,
70    /// (sizeof(size_t *) * counter_count), init 0
71    pub ev_map: *mut size_t,
72    /// (sizeof(size_t *) * counter_count), init -1
73    pub ev_idx: *mut size_t,
74    /// (sizeof(c_uint *) * counter_count), init 0
75    pub flags: *mut c_uint,
76    /// (sizeof(c_ulonglong *) * counter_count), init 0
77    pub kpc_periods: *mut c_ulonglong,
78    /// kpep_config_events_count()
79    pub event_count: size_t,
80    pub counter_count: size_t,
81    /// See `class mask constants` above.
82    pub classes: c_uint,
83    pub config_counter: c_uint,
84    pub power_counter: c_uint,
85    pub reserved: c_uint,
86}