#define KPC_ALL_CPUS (1u << 31)
/* action id setters/getters */
-#define FIXED_ACTIONID(ctr) (kpc_actionid[(ctr)])
-#define CONFIGURABLE_ACTIONID(ctr) (kpc_actionid[(ctr) + kpc_fixed_count()])
+#define FIXED_ACTIONID(ctr) (kpc_actionid[(ctr)])
+#define CONFIGURABLE_ACTIONID(ctr) (kpc_actionid[(ctr) + kpc_fixed_count()])
/* reload counter setters/getters */
-#define FIXED_RELOAD(ctr) (current_cpu_datap()->cpu_kpc_reload[(ctr)])
-#define FIXED_RELOAD_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_reload[(ctr)])
-#define CONFIGURABLE_RELOAD(ctr) (current_cpu_datap()->cpu_kpc_reload[(ctr) + kpc_fixed_count()])
-#define CONFIGURABLE_RELOAD_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_reload[(ctr) + kpc_fixed_count()])
+#define FIXED_RELOAD(ctr) (current_cpu_datap()->cpu_kpc_reload[(ctr)])
+#define FIXED_RELOAD_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_reload[(ctr)])
+#define CONFIGURABLE_RELOAD(ctr) (current_cpu_datap()->cpu_kpc_reload[(ctr) + kpc_fixed_count()])
+#define CONFIGURABLE_RELOAD_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_reload[(ctr) + kpc_fixed_count()])
/* shadow counter setters/getters */
-#define FIXED_SHADOW(ctr) (current_cpu_datap()->cpu_kpc_shadow[(ctr)])
-#define FIXED_SHADOW_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_shadow[(ctr)])
-#define CONFIGURABLE_SHADOW(ctr) (current_cpu_datap()->cpu_kpc_shadow[(ctr) + kpc_fixed_count()])
-#define CONFIGURABLE_SHADOW_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_shadow[(ctr) + kpc_fixed_count()])
+#define FIXED_SHADOW(ctr) (current_cpu_datap()->cpu_kpc_shadow[(ctr)])
+#define FIXED_SHADOW_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_shadow[(ctr)])
+#define CONFIGURABLE_SHADOW(ctr) (current_cpu_datap()->cpu_kpc_shadow[(ctr) + kpc_fixed_count()])
+#define CONFIGURABLE_SHADOW_CPU(cpu, ctr) (cpu_datap(cpu)->cpu_kpc_shadow[(ctr) + kpc_fixed_count()])
/**
* Callback for notification when PMCs are acquired/released by a task. The
/* bootstrap */
extern void kpc_init(void);
-/* common initialization */
-extern void kpc_common_init(void);
-
/* Architecture specific initialisation */
extern void kpc_arch_init(void);
-/* Thread counting initialization */
-extern void kpc_thread_init(void);
-
/* Get the bitmask of available classes */
extern uint32_t kpc_get_classes(void);
extern int kpc_set_running(uint32_t classes);
/* Read CPU counters */
-extern int kpc_get_cpu_counters(boolean_t all_cpus, uint32_t classes,
- int *curcpu, uint64_t *buf);
+extern int kpc_get_cpu_counters(boolean_t all_cpus, uint32_t classes,
+ int *curcpu, uint64_t *buf);
/* Read shadow counters */
extern int kpc_get_shadow_counters( boolean_t all_cpus, uint32_t classes,
- int *curcpu, uint64_t *buf );
+ int *curcpu, uint64_t *buf );
/* Read current thread's counter accumulations */
extern int kpc_get_curthread_counters(uint32_t *inoutcount, uint64_t *buf);
* This is a deprecated function used by old Power Managers, new Power Managers
* should use the @em kpc_reserve_pm_counters() function. This function actually
* calls @em kpc_reserve_pm_counters() with the following arguments:
- * - handler = handler
- * - pmc_mask = 0x83
- * - custom_config = TRUE
+ * - handler = handler
+ * - pmc_mask = 0x83
+ * - custom_config = TRUE
*
* See @em kpc_reserve_pm_counters() for more details about the return value.
*/
* Manager can start using the reserved PMCs.
*/
extern boolean_t kpc_reserve_pm_counters(uint64_t pmc_mask, kpc_pm_handler_t handler,
- boolean_t custom_config);
+ boolean_t custom_config);
/*
* Unregister the Power Manager as a PMCs user, and release the previously
/* handler for mp operations */
struct kpc_running_remote {
- uint32_t classes; /* classes to run */
- uint64_t cfg_target_mask; /* configurable counters selected */
- uint64_t cfg_state_mask; /* configurable counters new state */
+ uint32_t classes; /* classes to run */
+ uint64_t cfg_target_mask; /* configurable counters selected */
+ uint64_t cfg_state_mask; /* configurable counters new state */
};
/* handler for mp operations */
uint64_t *buf;
};
-extern int kpc_get_all_cpus_counters(uint32_t classes, int *curcpu, uint64_t *buf);
-extern int kpc_get_curcpu_counters(uint32_t classes, int *curcpu, uint64_t *buf);
-extern int kpc_get_fixed_counters(uint64_t *counterv);
-extern int kpc_get_configurable_counters(uint64_t *counterv, uint64_t pmc_mask);
-extern boolean_t kpc_is_running_fixed(void);
-extern boolean_t kpc_is_running_configurable(uint64_t pmc_mask);
-extern uint32_t kpc_fixed_count(void);
-extern uint32_t kpc_configurable_count(void);
-extern uint32_t kpc_fixed_config_count(void);
-extern uint32_t kpc_configurable_config_count(uint64_t pmc_mask);
-extern uint32_t kpc_rawpmu_config_count(void);
-extern int kpc_get_fixed_config(kpc_config_t *configv);
-extern int kpc_get_configurable_config(kpc_config_t *configv, uint64_t pmc_mask);
-extern int kpc_get_rawpmu_config(kpc_config_t *configv);
-extern uint64_t kpc_fixed_max(void);
-extern uint64_t kpc_configurable_max(void);
-extern int kpc_set_config_arch(struct kpc_config_remote *mp_config);
-extern int kpc_set_period_arch(struct kpc_config_remote *mp_config);
-extern void kpc_sample_kperf(uint32_t actionid);
-extern int kpc_set_running_arch(struct kpc_running_remote *mp_config);
+int kpc_get_all_cpus_counters(uint32_t classes, int *curcpu, uint64_t *buf);
+int kpc_get_curcpu_counters(uint32_t classes, int *curcpu, uint64_t *buf);
+int kpc_get_fixed_counters(uint64_t *counterv);
+int kpc_get_configurable_counters(uint64_t *counterv, uint64_t pmc_mask);
+boolean_t kpc_is_running_fixed(void);
+boolean_t kpc_is_running_configurable(uint64_t pmc_mask);
+uint32_t kpc_fixed_count(void);
+uint32_t kpc_configurable_count(void);
+uint32_t kpc_fixed_config_count(void);
+uint32_t kpc_configurable_config_count(uint64_t pmc_mask);
+uint32_t kpc_rawpmu_config_count(void);
+int kpc_get_fixed_config(kpc_config_t *configv);
+int kpc_get_configurable_config(kpc_config_t *configv, uint64_t pmc_mask);
+int kpc_get_rawpmu_config(kpc_config_t *configv);
+uint64_t kpc_fixed_max(void);
+uint64_t kpc_configurable_max(void);
+int kpc_set_config_arch(struct kpc_config_remote *mp_config);
+int kpc_set_period_arch(struct kpc_config_remote *mp_config);
+
+__options_decl(kperf_kpc_flags_t, uint16_t, {
+ KPC_KERNEL_PC = 0x01,
+ KPC_KERNEL_COUNTING = 0x02,
+ KPC_USER_COUNTING = 0x04,
+});
+
+void kpc_sample_kperf(uint32_t actionid, uint32_t counter, uint64_t config,
+ uint64_t count, uintptr_t pc, kperf_kpc_flags_t flags);
+
+int kpc_set_running_arch(struct kpc_running_remote *mp_config);
/*
/* Interface for kexts to publish a kpc interface */
-struct kpc_driver
-{
+struct kpc_driver {
uint32_t (*get_classes)(void);
uint32_t (*get_running)(void);
int (*set_running)(uint32_t classes);
- int (*get_cpu_counters)(boolean_t all_cpus, uint32_t classes,
- int *curcpu, uint64_t *buf);
+ int (*get_cpu_counters)(boolean_t all_cpus, uint32_t classes,
+ int *curcpu, uint64_t *buf);
int (*get_curthread_counters)(uint32_t *inoutcount, uint64_t *buf);
uint32_t (*get_counter_count)(uint32_t classes);
uint32_t (*get_config_count)(uint32_t classes);