pub use crate::error::SUCCESS;
pub const NOT_SUPPORTED: i32 = -1;
pub const NOT_REQUIRED: i32 = -2;
pub const INVALID_PARAMETER: i32 = -3;
#[derive(Copy, Clone, Debug, Eq, PartialEq, thiserror::Error)]
pub enum Error {
#[error("SMCCC call not supported")]
NotSupported,
#[error("SMCCC call not required")]
NotRequired,
#[error("SMCCC call received non-supported value")]
InvalidParameter,
#[error("Unknown SMCCC return value {0} ({0:#x})")]
Unknown(i32),
}
impl From<Error> for i32 {
fn from(error: Error) -> i32 {
match error {
Error::NotSupported => NOT_SUPPORTED,
Error::NotRequired => NOT_REQUIRED,
Error::InvalidParameter => INVALID_PARAMETER,
Error::Unknown(value) => value,
}
}
}
impl From<i32> for Error {
fn from(value: i32) -> Self {
match value {
NOT_SUPPORTED => Error::NotSupported,
NOT_REQUIRED => Error::NotRequired,
INVALID_PARAMETER => Error::InvalidParameter,
_ => Error::Unknown(value),
}
}
}