feat(ff-a): define framework notification helpers
Defined the helpers to process framework notifiactions.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I979162363898b4f9bf1a3d57327078364883b896
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index d086f91..c34384d 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -354,30 +354,64 @@
#define FFA_NOTIFICATIONS_FLAG_BITMAP_SPM UINT32_C(0x1 << 2)
#define FFA_NOTIFICATIONS_FLAG_BITMAP_HYP UINT32_C(0x1 << 3)
+#define FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK FFA_NOTIFICATION(0)
+#define FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK FFA_NOTIFICATION(32)
+
/**
* The following is an SGI ID, that the SPMC configures as non-secure, as
* suggested by the FF-A v1.1 specification, in section 9.4.1.
*/
#define FFA_SCHEDULE_RECEIVER_INTERRUPT_ID 8
-#define FFA_NOTIFICATIONS_BITMAP(lo, hi) \
- (ffa_notification_bitmap_t)(lo) | \
- (((ffa_notification_bitmap_t)hi << 32) & 0xFFFFFFFF00000000ULL)
-
-#define FFA_NOTIFICATIONS_FLAGS_VCPU_ID(id) UINT32_C((id & 0xFFFF) << 16)
-
-static inline ffa_notification_bitmap_t ffa_notifications_get_from_sp(
- struct ffa_value val)
+/**
+ * Helper function to assemble a 64-bit sized bitmap, from the 32-bit sized lo
+ * and hi.
+ * Helpful as FF-A specification defines that the notifications interfaces
+ * arguments are 32-bit registers.
+ */
+static inline ffa_notification_bitmap_t ffa_notification_bitmap(uint32_t lo,
+ uint32_t hi)
{
- return FFA_NOTIFICATIONS_BITMAP(val.arg2, val.arg3);
+ return (ffa_notification_bitmap_t)hi << 32U | lo;
}
-static inline ffa_notification_bitmap_t ffa_notifications_get_from_vm(
+static inline ffa_notification_bitmap_t ffa_notification_get_from_sp(
struct ffa_value val)
{
- return FFA_NOTIFICATIONS_BITMAP(val.arg4, val.arg5);
+ return ffa_notification_bitmap((uint32_t)val.arg2,
+ (uint32_t)val.arg3);
}
+static inline ffa_notification_bitmap_t ffa_notification_get_from_vm(
+ struct ffa_value val)
+{
+ return ffa_notification_bitmap((uint32_t)val.arg4,
+ (uint32_t)val.arg5);
+}
+
+static inline ffa_notification_bitmap_t ffa_notification_get_from_framework(
+ struct ffa_value val)
+{
+ return ffa_notification_bitmap((uint32_t)val.arg6,
+ (uint32_t)val.arg7);
+}
+
+ /**
+ * Helper functions to check for buffer full notification.
+ */
+static inline bool is_ffa_hyp_buffer_full_notification(
+ ffa_notification_bitmap_t framework)
+{
+ return (framework & FFA_NOTIFICATION_HYP_BUFFER_FULL_MASK) != 0U;
+}
+
+static inline bool is_ffa_spm_buffer_full_notification(
+ ffa_notification_bitmap_t framework)
+{
+ return (framework & FFA_NOTIFICATION_SPM_BUFFER_FULL_MASK) != 0U;
+}
+
+
/*
* FFA_NOTIFICATION_INFO_GET is a SMC64 interface.
* The following macros are defined for SMC64 implementation.
@@ -391,21 +425,21 @@
#define FFA_NOTIFICATIONS_LIST_SHIFT(l) (2 * (l - 1) + 12)
#define FFA_NOTIFICATIONS_LIST_SIZE_MASK 0x3U
-static inline uint32_t ffa_notifications_info_get_lists_count(
+static inline uint32_t ffa_notification_info_get_lists_count(
struct ffa_value ret)
{
return (uint32_t)(ret.arg2 >> FFA_NOTIFICATIONS_LISTS_COUNT_SHIFT)
& FFA_NOTIFICATIONS_LISTS_COUNT_MASK;
}
-static inline uint32_t ffa_notifications_info_get_list_size(
+static inline uint32_t ffa_notification_info_get_list_size(
struct ffa_value ret, uint32_t list)
{
return (uint32_t)(ret.arg2 >> FFA_NOTIFICATIONS_LIST_SHIFT(list)) &
FFA_NOTIFICATIONS_LIST_SIZE_MASK;
}
-static inline bool ffa_notifications_info_get_more_pending(struct ffa_value ret)
+static inline bool ffa_notification_info_get_more_pending(struct ffa_value ret)
{
return (ret.arg2 & FFA_NOTIFICATIONS_INFO_GET_FLAG_MORE_PENDING) != 0U;
}
diff --git a/spm/cactus/cactus_tests/cactus_test_notifications.c b/spm/cactus/cactus_tests/cactus_test_notifications.c
index 6d7b41b..420f942 100644
--- a/spm/cactus/cactus_tests/cactus_test_notifications.c
+++ b/spm/cactus/cactus_tests/cactus_test_notifications.c
@@ -109,8 +109,8 @@
VERBOSE("Notifications returned:\n"
" from sp: %llx\n"
" from vm: %llx\n",
- ffa_notifications_get_from_sp(ret),
- ffa_notifications_get_from_vm(ret));
+ ffa_notification_get_from_sp(ret),
+ ffa_notification_get_from_vm(ret));
/* If requested to check the status of NPI, for the respective CPU. */
if (cactus_notifications_check_npi_handled(*args)) {
@@ -126,8 +126,8 @@
}
return cactus_notifications_get_success_resp(
- vm_id, source, ffa_notifications_get_from_sp(ret),
- ffa_notifications_get_from_vm(ret));
+ vm_id, source, ffa_notification_get_from_sp(ret),
+ ffa_notification_get_from_vm(ret));
}
CACTUS_CMD_HANDLER(notifications_set, CACTUS_NOTIFICATIONS_SET_CMD)
diff --git a/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c b/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
index 9ca337a..7aa48c7 100644
--- a/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
+++ b/tftf/tests/runtime_services/secure_service/test_ffa_notifications.c
@@ -548,8 +548,8 @@
* ffa_notification_get.
*/
success_ret = (ffa_func_id(*ret) == FFA_SUCCESS_SMC32);
- from_sp = ffa_notifications_get_from_sp(*ret);
- from_vm = ffa_notifications_get_from_vm(*ret);
+ from_sp = ffa_notification_get_from_sp(*ret);
+ from_vm = ffa_notification_get_from_vm(*ret);
}
if (success_ret != true ||
@@ -569,19 +569,19 @@
struct ffa_value *ret, uint16_t *ids, uint32_t *lists_sizes,
const uint32_t max_ids_count, uint32_t lists_count, bool more_pending)
{
- if (lists_count != ffa_notifications_info_get_lists_count(*ret) ||
- more_pending != ffa_notifications_info_get_more_pending(*ret)) {
+ if (lists_count != ffa_notification_info_get_lists_count(*ret) ||
+ more_pending != ffa_notification_info_get_more_pending(*ret)) {
ERROR("Notification info get not as expected.\n"
" Lists counts: %u; more pending %u\n",
- ffa_notifications_info_get_lists_count(*ret),
- ffa_notifications_info_get_more_pending(*ret));
+ ffa_notification_info_get_lists_count(*ret),
+ ffa_notification_info_get_more_pending(*ret));
dump_ffa_value(*ret);
return false;
}
for (uint32_t i = 0; i < lists_count; i++) {
uint32_t cur_size =
- ffa_notifications_info_get_list_size(*ret,
+ ffa_notification_info_get_list_size(*ret,
i + 1);
if (lists_sizes[i] != cur_size) {