|
Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
|
Data Structures | |
| struct | pmu_counter_config |
| PMU counter configuration entry. More... | |
Macros | |
| #define | PMU_MAX_COUNTERS 8 |
| Maximum number of logical event counters this API can describe. | |
Functions | |
| int | pmu_init (void) |
| Initialize the PMU for the current logical CPU. | |
| uint32_t | pmu_num_counters (void) |
| void | pmu_get_info (pmu_info_t *info) |
| Fill info with PMU identification for the current logical CPU. | |
| int | pmu_counter_config (uint32_t counter, pmu_evt_t event) |
| Map hardware event counter counter to architectural event event. | |
| void | pmu_counter_enable (uint32_t counter) |
| Enable counting on hardware event counter counter. | |
| void | pmu_counter_disable (uint32_t counter) |
| Disable counting on hardware event counter counter. | |
| void | pmu_counter_enable_all (void) |
| Enable all implemented event counters (and the cycle counter where applicable). | |
| void | pmu_counter_disable_all (void) |
| Disable all event counters (and the cycle counter where applicable). | |
| uint64_t | pmu_counter_read (uint32_t counter) |
| Read the current value of hardware event counter counter. | |
| void | pmu_counter_reset (uint32_t counter) |
| Reset hardware event counter counter to zero. | |
| void | pmu_counter_reset_all (void) |
| Reset all hardware event counters to zero (implementation-defined; may include cycle counter policies). | |
| uint64_t | pmu_cycle_count (void) |
| Read the architectural cycle count register (if implemented). | |
| void | pmu_cycle_reset (void) |
| Reset the cycle count register to zero (implementation-defined). | |
| void | pmu_start (void) |
| Start counting: enable the PMU globally (implementation-defined). | |
| void | pmu_stop (void) |
| Stop counting: disable the PMU globally (implementation-defined). | |
| bool | pmu_counter_overflow (uint32_t counter) |
| Return whether hardware event counter counter has overflowed since the flag was cleared. | |
| void | pmu_counter_clear_overflow (uint32_t counter) |
| Clear the overflow flag for hardware event counter counter. | |
| #define PMU_MAX_COUNTERS 8 |
#include <zephyr/arch/pmu.h>
Maximum number of logical event counters this API can describe.
A given backend may implement fewer active hardware counters.
| void pmu_counter_clear_overflow | ( | uint32_t | counter | ) |
#include <zephyr/arch/pmu.h>
Clear the overflow flag for hardware event counter counter.
| counter | Event counter index [0, pmu_num_counters()). |
#include <zephyr/arch/pmu.h>
Map hardware event counter counter to architectural event event.
| counter | Event counter index in the range [0, pmu_num_counters()). |
| event | Event selector (pmu_evt_t from the architecture supplement when present). |
| void pmu_counter_disable | ( | uint32_t | counter | ) |
#include <zephyr/arch/pmu.h>
Disable counting on hardware event counter counter.
| counter | Event counter index [0, pmu_num_counters()). |
| void pmu_counter_disable_all | ( | void | ) |
#include <zephyr/arch/pmu.h>
Disable all event counters (and the cycle counter where applicable).
| void pmu_counter_enable | ( | uint32_t | counter | ) |
#include <zephyr/arch/pmu.h>
Enable counting on hardware event counter counter.
| counter | Event counter index [0, pmu_num_counters()). |
| void pmu_counter_enable_all | ( | void | ) |
#include <zephyr/arch/pmu.h>
Enable all implemented event counters (and the cycle counter where applicable).
#include <zephyr/arch/pmu.h>
Return whether hardware event counter counter has overflowed since the flag was cleared.
| counter | Event counter index [0, pmu_num_counters()). |
#include <zephyr/arch/pmu.h>
Read the current value of hardware event counter counter.
| counter | Event counter index [0, pmu_num_counters()). |
| void pmu_counter_reset | ( | uint32_t | counter | ) |
#include <zephyr/arch/pmu.h>
Reset hardware event counter counter to zero.
| counter | Event counter index [0, pmu_num_counters()). |
| void pmu_counter_reset_all | ( | void | ) |
#include <zephyr/arch/pmu.h>
Reset all hardware event counters to zero (implementation-defined; may include cycle counter policies).
| uint64_t pmu_cycle_count | ( | void | ) |
#include <zephyr/arch/pmu.h>
Read the architectural cycle count register (if implemented).
| void pmu_cycle_reset | ( | void | ) |
#include <zephyr/arch/pmu.h>
Reset the cycle count register to zero (implementation-defined).
| void pmu_get_info | ( | pmu_info_t * | info | ) |
#include <zephyr/arch/pmu.h>
Fill info with PMU identification for the current logical CPU.
info must not be NULL. Fields are only meaningful after a successful pmu_init on this CPU; contents are backend-defined (see arch pmu_info_t).
| int pmu_init | ( | void | ) |
#include <zephyr/arch/pmu.h>
Initialize the PMU for the current logical CPU.
Architecture-neutral interface for hardware performance counters. Backends implement these functions for each supported architecture (for example ARMv8-A PMUv3 on AArch64, future ARMv8-R / Cortex-R52, RISC-V HPM CSRs, etc.).
Architectural event codes are defined by the architecture supplement (for example pmu_evt_t in <zephyr/arch/arm64/pmuv3.h> when CONFIG_ARM64 is enabled).
PMU is not initialized during kernel startup. Call pmu_init() before other pmu_*() functions on this CPU.
Call once per logical CPU that will use counters, before any other pmu_*() API on that CPU. Idempotent on success: later calls return 0 if this CPU already initialized successfully, or -ENOTSUP if this CPU recorded that no PMU is available.
PMU control and counters are per-CPU. On SMP, use the PMU only while running on the intended CPU — for example pin the thread with k_thread_cpu_pin() (requires CONFIG_SCHED_CPU_MASK), or constrain its CPU affinity with k_thread_cpu_mask_enable() / k_thread_cpu_mask_disable(), so it does not migrate during a measurement.
There is no SYS_INIT hook; callers choose when to probe (for example at the start of a benchmark).
| 0 | Success |
| -ENOTSUP | No PMU or not usable at this exception level on this CPU |
| uint32_t pmu_num_counters | ( | void | ) |
#include <zephyr/arch/pmu.h>
| void pmu_start | ( | void | ) |
#include <zephyr/arch/pmu.h>
Start counting: enable the PMU globally (implementation-defined).
| void pmu_stop | ( | void | ) |
#include <zephyr/arch/pmu.h>
Stop counting: disable the PMU globally (implementation-defined).