feat(ff-a): create function helper to setup FF-A mailbox

Fix test dependencies issue when SPM test is used individually.
Provide an API function from SPM test suite to initialize the FF-A
mailbox and enable FF-A based message with SP.

Signed-off-by: Nabil Kahlouche <nabil.kahlouche@arm.com>
Change-Id: I246491907f1641c47937a9a1c91cfd4a9b8bfe20
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h
index e838270..7a14079 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -244,6 +244,14 @@
 		}								\
 	} while (false);
 
+#define INIT_TFTF_MAILBOX(mb)							\
+	do {									\
+		if (!mailbox_init(mb)) {					\
+			ERROR("Mailbox not configured properly!\n");		\
+			return TEST_RESULT_FAIL;				\
+		}								\
+	} while (false);
+
 #define CHECK_SPMC_TESTING_SETUP(ffa_major, ffa_minor, expected_uuids)		\
 	do {									\
 		SKIP_TEST_IF_AARCH32();						\
@@ -407,4 +415,9 @@
  */
 bool spm_set_managed_exit_int(ffa_id_t sp_id, bool enable);
 
+/**
+ * Initializes the Mailbox for other SPM related tests that need to use
+ * RXTX buffers.
+ */
+bool mailbox_init(struct mailbox_buffers mb);
 #endif /* __TEST_HELPERS_H__ */
diff --git a/tftf/tests/common/test_helpers.c b/tftf/tests/common/test_helpers.c
index b7eeb15..1a6ea64 100644
--- a/tftf/tests/common/test_helpers.c
+++ b/tftf/tests/common/test_helpers.c
@@ -256,3 +256,22 @@
 
 	return true;
 }
+
+/*
+ * Initializes the Mailbox for other SPM related tests that need to use
+ * RXTX buffers.
+ */
+bool mailbox_init(struct mailbox_buffers mb)
+{
+	smc_ret_values ret;
+
+	ffa_rxtx_unmap();
+	CONFIGURE_AND_MAP_MAILBOX(mb, PAGE_SIZE, ret);
+	if (ffa_func_id(ret) != FFA_SUCCESS_SMC32) {
+		ERROR("Failed to map RXTX buffers %x!\n", ffa_error_code(ret));
+		return false;
+	}
+	set_tftf_mailbox(&mb);
+	return true;
+}
+