feat(ff-a): notifications bind and unbind ABIs

Defined wrappers for FF-A calls:
- FFA_NOTIFICATION_BIND;
- FFA_NOTIFICATION_UNBIND;

Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I556faa2ef457f11e4469ca61b98ee4c06915fd01
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index 07bc33a..c371c55 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -27,6 +27,7 @@
 
 #ifndef __ASSEMBLY__
 
+#include <cassert.h>
 #include <stdint.h>
 
 /** Partition property: partition supports receipt of direct requests. */
@@ -59,6 +60,16 @@
 	return (ffa_id_t) val.ret2 & 0xffff;
 }
 
+typedef uint64_t ffa_notification_bitmap_t;
+
+#define FFA_NOTIFICATION(ID)		(UINT64_C(1) << ID)
+
+#define MAX_FFA_NOTIFICATIONS		UINT32_C(64)
+
+#define FFA_NOTIFICATIONS_FLAG_PER_VCPU	UINT32_C(0x1 << 0)
+
+#define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) UINT32_C((id & 0xFFFF) << 16)
+
 enum ffa_data_access {
 	FFA_DATA_ACCESS_NOT_SPECIFIED,
 	FFA_DATA_ACCESS_RO,
@@ -318,7 +329,8 @@
 
 static inline ffa_memory_handle_t ffa_assemble_handle(uint32_t h1, uint32_t h2)
 {
-	return (uint64_t)h1 | (uint64_t)h2 << 32;
+	return (ffa_notification_bitmap_t)h1 |
+	       (ffa_notification_bitmap_t)h2 << 32;
 }
 
 static inline ffa_memory_handle_t ffa_mem_success_handle(smc_ret_values r)
@@ -428,7 +440,11 @@
 smc_ret_values ffa_notification_bitmap_create(ffa_id_t vm_id,
 					      ffa_vcpu_count_t vcpu_count);
 smc_ret_values ffa_notification_bitmap_destroy(ffa_id_t vm_id);
-
+smc_ret_values ffa_notification_bind(ffa_id_t sender, ffa_id_t receiver,
+				     uint32_t flags,
+				     ffa_notification_bitmap_t notifications);
+smc_ret_values ffa_notification_unbind(ffa_id_t sender, ffa_id_t receiver,
+				       ffa_notification_bitmap_t notifications);
 #endif /* __ASSEMBLY__ */
 
 #endif /* FFA_HELPERS_H */
diff --git a/include/runtime_services/ffa_svc.h b/include/runtime_services/ffa_svc.h
index 3190e76..621b000 100644
--- a/include/runtime_services/ffa_svc.h
+++ b/include/runtime_services/ffa_svc.h
@@ -131,6 +131,8 @@
 	FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_BITMAP_CREATE)
 #define FFA_NOTIFICATION_BITMAP_DESTROY	\
 	FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_BITMAP_DESTROY)
+#define FFA_NOTIFICATION_BIND	FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_BIND)
+#define FFA_NOTIFICATION_UNBIND FFA_FID(SMC_32, FFA_FNUM_NOTIFICATION_UNBIND)
 #define FFA_SPM_ID_GET		FFA_FID(SMC_32, FFA_FNUM_SPM_ID_GET)
 
 /* FFA SMC64 FIDs */
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index 99f0318..d029e44 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -535,3 +535,40 @@
 	return tftf_smc(&args);
 }
 
+/** Bind VM to all the notifications in the bitmap */
+smc_ret_values ffa_notification_bind(ffa_id_t sender, ffa_id_t receiver,
+				     uint32_t flags,
+				     ffa_notification_bitmap_t bitmap)
+{
+	smc_args args = {
+		.fid = FFA_NOTIFICATION_BIND,
+		.arg1 = (sender << 16) | (receiver),
+		.arg2 = flags,
+		.arg3 = (uint32_t)(bitmap & 0xFFFFFFFFU),
+		.arg4 = (uint32_t)(bitmap >> 32),
+		.arg5 = FFA_PARAM_MBZ,
+		.arg6 = FFA_PARAM_MBZ,
+		.arg7 = FFA_PARAM_MBZ,
+	};
+
+	return tftf_smc(&args);
+}
+
+/** Unbind previously bound VM from notifications in bitmap */
+smc_ret_values ffa_notification_unbind(ffa_id_t sender,
+				       ffa_id_t receiver,
+				       ffa_notification_bitmap_t bitmap)
+{
+	smc_args args = {
+		.fid = FFA_NOTIFICATION_UNBIND,
+		.arg1 = (sender << 16) | (receiver),
+		.arg2 = FFA_PARAM_MBZ,
+		.arg3 = (uint32_t)(bitmap),
+		.arg4 = (uint32_t)(bitmap >> 32),
+		.arg5 = FFA_PARAM_MBZ,
+		.arg6 = FFA_PARAM_MBZ,
+		.arg7 = FFA_PARAM_MBZ,
+	};
+
+	return tftf_smc(&args);
+}