test(realm): add plane PSI interface

Add Plane service routine interface.
Aux plane can communicate with primary plane using PSI
PSI uses hvc conduit from aux plane.
Add initial printf support for planes

Signed-off-by: Shruti Gupta <shruti.gupta@arm.com>
Change-Id: I484cbd32791970c6e22c5d63e13b43807f4f3c06
diff --git a/realm/realm_helpers.c b/realm/realm_helpers.c
index 6a3c57d..bf47efc 100644
--- a/realm/realm_helpers.c
+++ b/realm/realm_helpers.c
@@ -5,6 +5,10 @@
  */
 
 #include <stdlib.h>
+#include <realm_helpers.h>
+#include <realm_psi.h>
+#include <realm_rsi.h>
+#include <smccc.h>
 
 /* Generate 64-bit random number */
 unsigned long long realm_rand64(void)
@@ -12,3 +16,26 @@
 	return ((unsigned long long)rand() << 32) | rand();
 }
 
+/* This function will call the Host to request IPA of the NS shared buffer */
+u_register_t realm_get_ns_buffer(void)
+{
+	smc_ret_values res = {};
+	struct rsi_host_call host_cal __aligned(sizeof(struct rsi_host_call));
+
+	host_cal.imm = HOST_CALL_GET_SHARED_BUFF_CMD;
+	res = tftf_smc(&(smc_args) {RSI_HOST_CALL, (u_register_t)&host_cal,
+		0UL, 0UL, 0UL, 0UL, 0UL, 0UL});
+
+	if (res.ret0 != RSI_SUCCESS) {
+		/* retry with PSI */
+		hvc_ret_values ret = tftf_hvc(&(hvc_args) {PSI_CALL_GET_SHARED_BUFF_CMD, 0UL, 0UL,
+			0UL, 0UL, 0UL, 0UL, 0UL});
+
+		if (ret.ret0 != RSI_SUCCESS) {
+			return 0U;
+		}
+		return ret.ret1;
+	}
+
+	return host_cal.gprs[0];
+}