tftf: provide hvc conduit facility

Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I3ad6e6767c2ca915f4a4fe8c5accc07e3e255387
diff --git a/include/lib/tftf_lib.h b/include/lib/tftf_lib.h
index 7f6786a..c3ad105 100644
--- a/include/lib/tftf_lib.h
+++ b/include/lib/tftf_lib.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -159,6 +159,15 @@
 smc_ret_values tftf_smc(const smc_args *args);
 
 /*
+ * Trigger an HVC call.
+ */
+typedef smc_args hvc_args;
+
+typedef smc_ret_values hvc_ret_values;
+
+hvc_ret_values tftf_hvc(const hvc_args *args);
+
+/*
  * Write a formatted string in the test output buffer.
  * Just like the standard libc's printf() function, the string produced is under
  * the control of a format string that specifies how subsequent arguments are
diff --git a/lib/smc/aarch64/asm_smc.S b/lib/smc/aarch64/asm_smc.S
index c3044a4..b11baa8 100644
--- a/lib/smc/aarch64/asm_smc.S
+++ b/lib/smc/aarch64/asm_smc.S
@@ -1,28 +1,15 @@
 /*
- * Copyright (c) 2013-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2013-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include <asm_macros.S>
 
-	.globl	asm_tftf_smc64
-
 	.section        .text, "ax"
 
+	.macro smccc_conduit _conduit
 
-/* ---------------------------------------------------------------------------
- * smc_ret_values asm_tftf_smc64(uint32_t fid,
- *				 u_register_t arg1,
- *				 u_register_t arg2,
- *				 u_register_t arg3,
- *				 u_register_t arg4,
- *				 u_register_t arg5,
- *				 u_register_t arg6,
- *				 u_register_t arg7);
- * ---------------------------------------------------------------------------
- */
-func asm_tftf_smc64
 	/*
 	 * According to the AAPCS64, x8 is the indirect result location
 	 * register. It contains the address of the memory block that the caller
@@ -34,8 +21,8 @@
 	 */
 	str	x8, [sp, #-16]!
 
-	/* SMC arguments are already stored in x0-x7 */
-	smc	#0
+	/* "Conduit" arguments are already stored in x0-x7 */
+	\_conduit	#0
 
 	/* Pop x8 into a caller-saved register */
 	ldr	x9, [sp], #16
@@ -48,5 +35,41 @@
 	stp	x2, x3, [x9, #16]
 	stp	x4, x5, [x9, #32]
 	stp	x6, x7, [x9, #48]
+
+	.endm
+
+/* ---------------------------------------------------------------------------
+ * smc_ret_values asm_tftf_smc64(uint32_t fid,
+ *				 u_register_t arg1,
+ *				 u_register_t arg2,
+ *				 u_register_t arg3,
+ *				 u_register_t arg4,
+ *				 u_register_t arg5,
+ *				 u_register_t arg6,
+ *				 u_register_t arg7);
+ * ---------------------------------------------------------------------------
+ */
+	.globl	asm_tftf_smc64
+
+func asm_tftf_smc64
+	smccc_conduit smc
 	ret
 endfunc asm_tftf_smc64
+
+/* ---------------------------------------------------------------------------
+ * hvc_ret_values asm_tftf_hvcc64(uint32_t fid,
+ *				 u_register_t arg1,
+ *				 u_register_t arg2,
+ *				 u_register_t arg3,
+ *				 u_register_t arg4,
+ *				 u_register_t arg5,
+ *				 u_register_t arg6,
+ *				 u_register_t arg7);
+ * ---------------------------------------------------------------------------
+ */
+	.globl	asm_tftf_hvc64
+
+func asm_tftf_hvc64
+	smccc_conduit hvc
+	ret
+endfunc asm_tftf_hvc64
diff --git a/lib/smc/aarch64/hvc.c b/lib/smc/aarch64/hvc.c
new file mode 100644
index 0000000..c833864
--- /dev/null
+++ b/lib/smc/aarch64/hvc.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stdint.h>
+#include <tftf.h>
+
+hvc_ret_values asm_tftf_hvc64(uint32_t fid,
+			      u_register_t arg1,
+			      u_register_t arg2,
+			      u_register_t arg3,
+			      u_register_t arg4,
+			      u_register_t arg5,
+			      u_register_t arg6,
+			      u_register_t arg7);
+
+hvc_ret_values tftf_hvc(const hvc_args *args)
+{
+	return asm_tftf_hvc64(args->fid,
+			      args->arg1,
+			      args->arg2,
+			      args->arg3,
+			      args->arg4,
+			      args->arg5,
+			      args->arg6,
+			      args->arg7);
+}