Function sbi_rt::pmu_counter_start

source ·
pub fn pmu_counter_start<T>(
    counter_idx_base: usize,
    counter_idx_mask: usize,
    start_flags: T,
    initial_value: u64
) -> SbiRet
where T: StartFlags,
Expand description

Start or enable a set of counters on the calling hart with the specified initial value.

§Parameters

The counter_idx_base and counter_idx_mask parameters represent the set of counters. whereas the initial_value parameter specifies the initial value of the counter.

The bit definitions of the start_flags parameter are shown in the table below:

Flag NameBitsDescription
SBI_PMU_START_SET_INIT_VALUE0:0Set the value of counters based on the initial_value parameter.
RESERVED1:(XLEN-1)All non-zero values are reserved for future use.

NOTE: When SBI_PMU_START_SET_INIT_VALUE is not set in start_flags, the value of counter will not be modified, and event counting will start from the current value of counter.

§Return value

The possible return error codes returned in SbiRet.error are shown in the table below:

Return codeDescription
SbiRet::success()counter started successfully.
SbiRet::invalid_param()some of the counters specified in parameters are invalid.
SbiRet::already_started()some of the counters specified in parameters are already started.

This function is defined in RISC-V SBI Specification chapter 11.8.