Function sbi_rt::pmu_counter_config_matching
source · pub fn pmu_counter_config_matching<T>(
counter_idx_base: usize,
counter_idx_mask: usize,
config_flags: T,
event_idx: usize,
event_data: u64
) -> SbiRetwhere
T: ConfigFlags,
Expand description
Find and configure a counter from a set of counters.
The counters to be found and configured should not be started (or enabled) and should be able to monitor the specified event.
§Parameters
The counter_idx_base
and counter_idx_mask
parameters represent the set of counters,
whereas the event_idx
represent the event to be monitored
and event_data
represents any additional event configuration.
The config_flags
parameter represents additional configuration and filter flags of the counter.
The bit definitions of the config_flags
parameter are shown in the table below:
Flag Name | Bits | Description |
---|---|---|
SBI_PMU_CFG_FLAG_SKIP_MATCH | 0:0 | Skip the counter matching |
SBI_PMU_CFG_FLAG_CLEAR_VALUE | 1:1 | Clear (or zero) the counter value in counter configuration |
SBI_PMU_CFG_FLAG_AUTO_START | 2:2 | Start the counter after configuring a matching counter |
SBI_PMU_CFG_FLAG_SET_VUINH | 3:3 | Event counting inhibited in VU-mode |
SBI_PMU_CFG_FLAG_SET_VSINH | 4:4 | Event counting inhibited in VS-mode |
SBI_PMU_CFG_FLAG_SET_UINH | 5:5 | Event counting inhibited in U-mode |
SBI_PMU_CFG_FLAG_SET_SINH | 6:6 | Event counting inhibited in S-mode |
SBI_PMU_CFG_FLAG_SET_MINH | 7:7 | Event counting inhibited in M-mode |
RESERVED | 8:(XLEN-1) | All non-zero values are reserved for future use. |
NOTE: When SBI_PMU_CFG_FLAG_SKIP_MATCH is set in config_flags
, the
SBI implementation will unconditionally select the first counter from the
set of counters specified by the counter_idx_base
and counter_idx_mask
.
NOTE: The SBI_PMU_CFG_FLAG_AUTO_START flag in config_flags
has no
impact on the value of the counter.
NOTE: The config_flags[3:7]
bits are event filtering hints so these
can be ignored or overridden by the SBI implementation for security concerns
or due to lack of event filtering support in the underlying RISC-V platform.
§Return value
Returns the counter_idx
in sbiret.value
upon success.
In case of failure, the possible error codes returned in sbiret.error
are shown in the table below:
Return code | Description |
---|---|
SbiRet::success() | counter found and configured successfully. |
SbiRet::invalid_param() | set of counters has an invalid counter. |
SbiRet::not_supported() | none of the counters can monitor specified event. |
This function is defined in RISC-V SBI Specification chapter 11.7.