Add success type for FFA_FEATURES
Add specialized success type for converting between FFA_FEATURES
return arguments and generic success arguments.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I39d62255fe5856a84b5420043ff016bd2057c632
diff --git a/src/lib.rs b/src/lib.rs
index 349b457..e3c9778 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -202,6 +202,9 @@
/// the interface that initiated the request. The application code has knowledge of the request, so
/// it has to convert `SuccessArgs` into/from a specific success args structure that matches the
/// request.
+///
+/// The current specialized success arguments types are:
+/// * `FFA_FEATURES` - [`SuccessArgsFeatures`]
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum SuccessArgs {
Args32([u32; 6]),
@@ -333,6 +336,31 @@
}
}
+/// `FFA_FEATURES` specific success argument structure. This type needs further specialization based
+/// on 'FF-A function ID or Feature ID' field of the preceeding `FFA_FEATURES` request.
+#[derive(Debug, Eq, PartialEq, Clone, Copy)]
+pub struct SuccessArgsFeatures {
+ pub properties: [u32; 2],
+}
+
+impl From<SuccessArgsFeatures> for SuccessArgs {
+ fn from(value: SuccessArgsFeatures) -> Self {
+ Self::Args32([value.properties[0], value.properties[1], 0, 0, 0, 0])
+ }
+}
+
+impl TryFrom<SuccessArgs> for SuccessArgsFeatures {
+ type Error = Error;
+
+ fn try_from(value: SuccessArgs) -> Result<Self, Self::Error> {
+ let args = value.try_get_args32()?;
+
+ Ok(Self {
+ properties: [args[0], args[1]],
+ })
+ }
+}
+
/// RXTX buffer descriptor, used by `FFA_RXTX_MAP`.
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum RxTxAddr {