use super::{
SMCCC_ARCH_FEATURES, SMCCC_ARCH_SOC_ID, SMCCC_ARCH_WORKAROUND_1, SMCCC_ARCH_WORKAROUND_2,
SMCCC_ARCH_WORKAROUND_3, SMCCC_VERSION, SocIdType, Version, error::Error,
};
use crate::{
Call,
error::{positive_or_error_32, success_or_error_32},
};
pub fn version<C: Call>() -> Result<Version, Error> {
(C::call32(SMCCC_VERSION, [0; 7])[0] as i32).try_into()
}
pub fn features<C: Call>(arch_func_id: u32) -> Result<u32, Error> {
positive_or_error_32(C::call32(SMCCC_ARCH_FEATURES, [arch_func_id, 0, 0, 0, 0, 0, 0])[0])
}
pub fn soc_id<C: Call>(soc_id_type: SocIdType) -> Result<u32, Error> {
positive_or_error_32(C::call32(SMCCC_ARCH_SOC_ID, [soc_id_type.into(), 0, 0, 0, 0, 0, 0])[0])
}
pub fn arch_workaround_1<C: Call>() -> Result<(), Error> {
success_or_error_32(C::call32(SMCCC_ARCH_WORKAROUND_1, [0; 7])[0])
}
pub fn arch_workaround_2<C: Call>(enable: bool) -> Result<(), Error> {
success_or_error_32(C::call32(SMCCC_ARCH_WORKAROUND_2, [enable.into(), 0, 0, 0, 0, 0, 0])[0])
}
pub fn arch_workaround_3<C: Call>() -> Result<(), Error> {
success_or_error_32(C::call32(SMCCC_ARCH_WORKAROUND_3, [0; 7])[0])
}