1/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#include <asm_macros.S>
7
8.globl monitor_call
9.globl monitor_call_with_res
10
11func monitor_call
12	/* As this is a function call, the arguments must already be in
13	 * place in accordance to SMCCC.
14	 */
15	smc #0
16	ret
17endfunc monitor_call
18
19/*
20 * Issue an SMC call to EL3 monitor with the ability to return more than 1
21 * result register.
22 * The arguments to this function are :
23 *    x0 - x6 - SMC call arguments
24 *    x7 - Reference to smc_result structure allocated by caller
25 * Return :
26 *    x0 - x3 Return values from SMC
27 * The return args are also copied to smc_result data structure.
28 */
29func monitor_call_with_res
30	/*
31	 * Push the value of x7 to the stack, as the SMC might change the
32	 * content. (push two registers to maintain 16 bit aligned stack)
33	 */
34	stp x7, x8, [sp, #-16]!
35	/* Call SMC */
36	smc #0
37	/* Pop the saved values from stack */
38	ldp x7, x8, [sp], #16
39	/* Fill the smc_result structure */
40	stp x0, x1, [x7, #0]
41	stp x2, x3, [x7, #16]
42	ret
43endfunc monitor_call_with_res
44