Translate secure/non-secure virtual addresses

This patch adds functionality to translate virtual addresses from
secure or non-secure worlds. This functionality helps Trusted Apps
to share virtual addresses directly and allows the NS world to
pass virtual addresses to TLK directly.

Change-Id: I77b0892963e0e839c448b5d0532920fb7e54dc8e
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
diff --git a/services/spd/tlkd/tlkd_main.c b/services/spd/tlkd/tlkd_main.c
index 8d2d437..eb6b89d 100644
--- a/services/spd/tlkd/tlkd_main.c
+++ b/services/spd/tlkd/tlkd_main.c
@@ -188,6 +188,7 @@
 {
 	cpu_context_t *ns_cpu_context;
 	uint32_t ns;
+	uint64_t vaddr, type, par;
 
 	/* Passing a NULL context is a critical programming error */
 	assert(handle);
@@ -247,6 +248,24 @@
 		SMC_RET0(&tlk_ctx.cpu_ctx);
 
 	/*
+	 * Translate NS/EL1-S virtual addresses
+	 */
+	case TLK_VA_TRANSLATE:
+		if (ns || !tlk_args_results_buf)
+			SMC_RET1(handle, SMC_UNK);
+
+		/* virtual address and type: ns/s */
+		vaddr = tlk_args_results_buf->args[0];
+		type = tlk_args_results_buf->args[1];
+
+		par = tlkd_va_translate(vaddr, type);
+
+		/* Save PA for use by the SP on return */
+		store_tlk_args_results(par, 0, 0, 0);
+
+		SMC_RET0(handle);
+
+	/*
 	 * This is a request from the SP to mark completion of
 	 * a standard function ID.
 	 */