blob: d4cede99820c350c527a37a07860bfe9d0e95e29 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
Olivier Deprez3e1a2952020-03-12 15:44:17 +01002 * Copyright (c) 2013-2020, Arm Limited. All rights reserved.
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <asm_macros.S>
8
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02009 .section .text, "ax"
10
Olivier Deprez3e1a2952020-03-12 15:44:17 +010011 .macro smccc_conduit _conduit
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020012
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020013 /*
14 * According to the AAPCS64, x8 is the indirect result location
15 * register. It contains the address of the memory block that the caller
16 * has reserved to hold the result, i.e. the smc_ret_values structure
17 * in our case.
18 * x8 might be clobbered across the SMC call so save it on the stack.
19 * Although x8 contains an 8 byte value, we are allocating 16bytes on the stack
20 * to respect 16byte stack-alignment.
21 */
22 str x8, [sp, #-16]!
23
Olivier Deprez3e1a2952020-03-12 15:44:17 +010024 /* "Conduit" arguments are already stored in x0-x7 */
25 \_conduit #0
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020026
27 /* Pop x8 into a caller-saved register */
28 ldr x9, [sp], #16
29
30 /*
Madhukar Pappireddyc783c0b2019-11-14 23:52:37 -060031 * Return values are stored in x0-x7, put them in the 'smc_ret_values'
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020032 * return structure
33 */
34 stp x0, x1, [x9, #0]
35 stp x2, x3, [x9, #16]
Madhukar Pappireddyc783c0b2019-11-14 23:52:37 -060036 stp x4, x5, [x9, #32]
37 stp x6, x7, [x9, #48]
Olivier Deprez3e1a2952020-03-12 15:44:17 +010038
39 .endm
40
Juan Pablo Condec79338a2024-10-28 18:48:25 -050041 .macro smccc_conduit_nox8 _conduit
42
43 /*
44 * Store address pointing at the smc_ret_values structure in the stack
45 */
46 str x1, [sp, #-16]!
47
48 /*
49 * Store arguments in x0..x17. Start from highest registers so address
50 * pointed by x0 is preserved until it is no longer needed.
51 */
52 ldp x16, x17, [x0, #128]
53 ldp x14, x15, [x0, #112]
54 ldp x12, x13, [x0, #96]
55 ldp x10, x11, [x0, #80]
56 ldp x8, x9, [x0, #64]
57 ldp x6, x7, [x0, #48]
58 ldp x4, x5, [x0, #32]
59 ldp x2, x3, [x0, #16]
60 ldp x0, x1, [x0, #0]
61
62 /* "Conduit" arguments are already stored in x0..x17 */
63 \_conduit #0
64
65 /*
66 * Store value received in x0 as x0 will be used to compute addresses
67 * to store the results.
68 */
69 str x0, [sp, #-16]!
70
71 /* Load address of smc_ret_values structure into x0 */
72 ldr x0, [sp, #16]
73
74 /* Store values x1..x17 in the smc_ret_values structure */
75 stp x16, x17, [x0, #128]
76 stp x14, x15, [x0, #112]
77 stp x12, x13, [x0, #96]
78 stp x10, x11, [x0, #80]
79 stp x8, x9, [x0, #64]
80 stp x6, x7, [x0, #48]
81 stp x4, x5, [x0, #32]
82 stp x2, x3, [x0, #16]
83 str x1, [x0, #8]
84
85 /*
86 * Load previously stored value of x0 into x1 and store it in the
87 * smc_ret_values structure. Return sp to its original position.
88 */
89 ldr x1, [sp], #32
90 str x1, [x0, #0]
91
92 .endm
93
Olivier Deprez3e1a2952020-03-12 15:44:17 +010094/* ---------------------------------------------------------------------------
95 * smc_ret_values asm_tftf_smc64(uint32_t fid,
96 * u_register_t arg1,
97 * u_register_t arg2,
98 * u_register_t arg3,
99 * u_register_t arg4,
100 * u_register_t arg5,
101 * u_register_t arg6,
102 * u_register_t arg7);
103 * ---------------------------------------------------------------------------
104 */
105 .globl asm_tftf_smc64
106
107func asm_tftf_smc64
108 smccc_conduit smc
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200109 ret
110endfunc asm_tftf_smc64
Olivier Deprez3e1a2952020-03-12 15:44:17 +0100111
Juan Pablo Condec79338a2024-10-28 18:48:25 -0500112 .globl asm_tftf_smc64_no_retval_x8
113
114/* ---------------------------------------------------------------------------
115 * void asm_tftf_smc64_no_retval_x8(smc_args *args, smc_ret_values *ret);
116 * ---------------------------------------------------------------------------
117 */
118func asm_tftf_smc64_no_retval_x8
119 smccc_conduit_nox8 smc
120 ret
121endfunc asm_tftf_smc64_no_retval_x8
122
Olivier Deprez3e1a2952020-03-12 15:44:17 +0100123/* ---------------------------------------------------------------------------
124 * hvc_ret_values asm_tftf_hvcc64(uint32_t fid,
125 * u_register_t arg1,
126 * u_register_t arg2,
127 * u_register_t arg3,
128 * u_register_t arg4,
129 * u_register_t arg5,
130 * u_register_t arg6,
131 * u_register_t arg7);
132 * ---------------------------------------------------------------------------
133 */
134 .globl asm_tftf_hvc64
135
136func asm_tftf_hvc64
137 smccc_conduit hvc
138 ret
139endfunc asm_tftf_hvc64