summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/runtime_services/cactus_test_cmds.h62
-rw-r--r--spm/cactus/cactus.mk1
-rw-r--r--spm/cactus/cactus_tests/cactus_test_notifications.c56
3 files changed, 119 insertions, 0 deletions
diff --git a/include/runtime_services/cactus_test_cmds.h b/include/runtime_services/cactus_test_cmds.h
index 16bb36b..b6af28b 100644
--- a/include/runtime_services/cactus_test_cmds.h
+++ b/include/runtime_services/cactus_test_cmds.h
@@ -312,4 +312,66 @@ static inline smc_ret_values cactus_send_dma_cmd(
return cactus_send_cmd(source, dest, CACTUS_DMA_SMMUv3_CMD, 0, 0, 0,
0);
}
+
+/*
+ * Request SP to bind a notification to a FF-A endpoint. In case of error
+ * when using the FFA_NOTIFICATION_BIND interface, include the error code
+ * in the response to the command's request. The receiver and sender arguments
+ * are propagated through the command's arguments, to allow the test of
+ * erroneous uses of the FFA_NOTIFICATION_BIND interface.
+ *
+ * The command id is the hex representation of the string "bind".
+ */
+#define CACTUS_NOTIFICATION_BIND_CMD U(0x62696e64)
+
+static inline smc_ret_values cactus_notification_bind_send_cmd(
+ ffa_id_t source, ffa_id_t dest, ffa_id_t receiver,
+ ffa_id_t sender, ffa_notification_bitmap_t notifications, uint32_t flags)
+{
+ return cactus_send_cmd(source, dest, CACTUS_NOTIFICATION_BIND_CMD,
+ receiver, sender, notifications, flags);
+}
+
+/**
+ * Request to SP unbind a notification. In case of error when using the
+ * FFA_NOTIFICATION_UNBIND interface, the test includes the error code in the
+ * response. The receiver and sender arguments are propagated throught the
+ * command's arguments, to allow the test of erroneous uses of the
+ * FFA_NOTIFICATION_BIND interface.
+ *
+ * The command id is the hex representation of the string "unbind".
+ */
+#define CACTUS_NOTIFICATION_UNBIND_CMD U(0x756e62696e64)
+
+static inline smc_ret_values cactus_notification_unbind_send_cmd(
+ ffa_id_t source, ffa_id_t dest, ffa_id_t receiver,
+ ffa_id_t sender, ffa_notification_bitmap_t notifications)
+{
+ return cactus_send_cmd(source, dest, CACTUS_NOTIFICATION_UNBIND_CMD,
+ receiver, sender, notifications, 0);
+}
+
+static inline ffa_id_t cactus_notification_get_receiver(
+ smc_ret_values ret)
+{
+ return (ffa_id_t)ret.ret4;
+}
+
+static inline ffa_id_t cactus_notification_get_sender(
+ smc_ret_values ret)
+{
+ return (ffa_id_t)ret.ret5;
+}
+
+static inline ffa_notification_bitmap_t cactus_notification_get_notifications(
+ smc_ret_values ret)
+{
+ return (uint64_t)ret.ret6;
+}
+
+static inline uint32_t cactus_notification_get_flags(smc_ret_values ret)
+{
+ return (uint32_t)ret.ret7;
+}
+
#endif
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index c21f44b..6252d2d 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -50,6 +50,7 @@ CACTUS_SOURCES := \
cactus_test_interrupts.c \
cactus_test_memory_sharing.c \
cactus_tests_smmuv3.c \
+ cactus_test_notifications.c \
)
# TODO: Remove dependency on TFTF files.
diff --git a/spm/cactus/cactus_tests/cactus_test_notifications.c b/spm/cactus/cactus_tests/cactus_test_notifications.c
new file mode 100644
index 0000000..dc6c256
--- /dev/null
+++ b/spm/cactus/cactus_tests/cactus_test_notifications.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "cactus_message_loop.h"
+#include "cactus_test_cmds.h"
+#include "cactus_tests.h"
+#include <debug.h>
+#include <ffa_helpers.h>
+
+CACTUS_CMD_HANDLER(notifications_bind, CACTUS_NOTIFICATION_BIND_CMD)
+{
+ ffa_id_t source = ffa_dir_msg_source(*args);
+ ffa_id_t vm_id = ffa_dir_msg_dest(*args);
+ ffa_id_t receiver = cactus_notification_get_receiver(*args);
+ ffa_id_t sender = cactus_notification_get_sender(*args);
+ ffa_notification_bitmap_t notifications =
+ cactus_notification_get_notifications(*args);
+ uint32_t flags = cactus_notification_get_flags(*args);
+ smc_ret_values ret;
+
+ VERBOSE("Partition %x requested to bind notifications '%llx' to %x\n",
+ source, notifications, receiver);
+
+ ret = ffa_notification_bind(sender, receiver, flags, notifications);
+
+ if (is_ffa_call_error(ret)) {
+ return cactus_error_resp(vm_id, source, ffa_error_code(ret));
+ }
+
+ return cactus_response(vm_id, source, CACTUS_SUCCESS);
+}
+
+CACTUS_CMD_HANDLER(notifications_unbind, CACTUS_NOTIFICATION_UNBIND_CMD)
+{
+ ffa_id_t source = ffa_dir_msg_source(*args);
+ ffa_id_t vm_id = ffa_dir_msg_dest(*args);
+ ffa_id_t receiver = cactus_notification_get_receiver(*args);
+ ffa_id_t sender = cactus_notification_get_sender(*args);
+ ffa_notification_bitmap_t notifications =
+ cactus_notification_get_notifications(*args);
+ smc_ret_values ret;
+
+ VERBOSE("Partition %x requested to unbind notifications '%llx' to %x\n",
+ source, notifications, receiver);
+
+ ret = ffa_notification_unbind(sender, receiver, notifications);
+
+ if (is_ffa_call_error(ret)) {
+ return cactus_error_resp(vm_id, source, ffa_error_code(ret));
+ }
+
+ return cactus_response(vm_id, source, CACTUS_SUCCESS);
+}