Skip to content

Commit 5cce39b

Browse files
committed
xtensa: definitions for call0 ABI
Add assembly macros for calls, call arguments, preserved registers, function entry and return for windowed and call0 ABIs. Signed-off-by: Max Filippov <[email protected]>
1 parent 61a6b91 commit 5cce39b

File tree

3 files changed

+102
-6
lines changed

3 files changed

+102
-6
lines changed

arch/xtensa/include/asm/asmmacro.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@
194194
#define XTENSA_STACK_ALIGNMENT 16
195195

196196
#if defined(__XTENSA_WINDOWED_ABI__)
197+
198+
/* Assembly instructions for windowed kernel ABI. */
199+
#define KABI_W
200+
/* Assembly instructions for call0 kernel ABI (will be ignored). */
201+
#define KABI_C0 #
202+
197203
#define XTENSA_FRAME_SIZE_RESERVE 16
198204
#define XTENSA_SPILL_STACK_RESERVE 32
199205

@@ -206,8 +212,34 @@
206212
#define abi_ret(frame_size) retw
207213
#define abi_ret_default retw
208214

215+
/* direct call */
216+
#define abi_call call4
217+
/* indirect call */
218+
#define abi_callx callx4
219+
/* outgoing call argument registers */
220+
#define abi_arg0 a6
221+
#define abi_arg1 a7
222+
#define abi_arg2 a8
223+
#define abi_arg3 a9
224+
#define abi_arg4 a10
225+
#define abi_arg5 a11
226+
/* return value */
227+
#define abi_rv a6
228+
/* registers preserved across call */
229+
#define abi_saved0 a2
230+
#define abi_saved1 a3
231+
232+
/* none of the above */
233+
#define abi_tmp0 a4
234+
#define abi_tmp1 a5
235+
209236
#elif defined(__XTENSA_CALL0_ABI__)
210237

238+
/* Assembly instructions for windowed kernel ABI (will be ignored). */
239+
#define KABI_W #
240+
/* Assembly instructions for call0 kernel ABI. */
241+
#define KABI_C0
242+
211243
#define XTENSA_SPILL_STACK_RESERVE 0
212244

213245
#define abi_entry(frame_size) __abi_entry (frame_size)
@@ -233,10 +265,43 @@
233265

234266
#define abi_ret_default ret
235267

268+
/* direct call */
269+
#define abi_call call0
270+
/* indirect call */
271+
#define abi_callx callx0
272+
/* outgoing call argument registers */
273+
#define abi_arg0 a2
274+
#define abi_arg1 a3
275+
#define abi_arg2 a4
276+
#define abi_arg3 a5
277+
#define abi_arg4 a6
278+
#define abi_arg5 a7
279+
/* return value */
280+
#define abi_rv a2
281+
/* registers preserved across call */
282+
#define abi_saved0 a12
283+
#define abi_saved1 a13
284+
285+
/* none of the above */
286+
#define abi_tmp0 a8
287+
#define abi_tmp1 a9
288+
236289
#else
237290
#error Unsupported Xtensa ABI
238291
#endif
239292

293+
#if defined(USER_SUPPORT_WINDOWED)
294+
/* Assembly instructions for windowed user ABI. */
295+
#define UABI_W
296+
/* Assembly instructions for call0 user ABI (will be ignored). */
297+
#define UABI_C0 #
298+
#else
299+
/* Assembly instructions for windowed user ABI (will be ignored). */
300+
#define UABI_W #
301+
/* Assembly instructions for call0 user ABI. */
302+
#define UABI_C0
303+
#endif
304+
240305
#define __XTENSA_HANDLER .section ".exception.text", "ax"
241306

242307
#endif /* _XTENSA_ASMMACRO_H */

arch/xtensa/include/asm/core.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@
2626
#define XCHAL_SPANNING_WAY 0
2727
#endif
2828

29+
#if XCHAL_HAVE_WINDOWED
30+
#if defined(CONFIG_USER_ABI_DEFAULT) || defined(CONFIG_USER_ABI_CALL0_PROBE)
31+
/* Whether windowed ABI is supported in userspace. */
32+
#define USER_SUPPORT_WINDOWED
33+
#endif
34+
#if defined(__XTENSA_WINDOWED_ABI__) || defined(USER_SUPPORT_WINDOWED)
35+
/* Whether windowed ABI is supported either in userspace or in the kernel. */
36+
#define SUPPORT_WINDOWED
37+
#endif
38+
#endif
39+
2940
#endif

arch/xtensa/include/asm/processor.h

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
#include <asm/types.h>
1919
#include <asm/regs.h>
2020

21-
/* Assertions. */
22-
23-
#if (XCHAL_HAVE_WINDOWED != 1)
24-
# error Linux requires the Xtensa Windowed Registers Option.
25-
#endif
26-
2721
/* Xtensa ABI requires stack alignment to be at least 16 */
2822

2923
#define STACK_ALIGN (XCHAL_DATA_WIDTH > 16 ? XCHAL_DATA_WIDTH : 16)
@@ -105,8 +99,18 @@
10599
#define WSBITS (XCHAL_NUM_AREGS / 4) /* width of WINDOWSTART in bits */
106100
#define WBBITS (XCHAL_NUM_AREGS_LOG2 - 2) /* width of WINDOWBASE in bits */
107101

102+
#if defined(__XTENSA_WINDOWED_ABI__)
103+
#define KERNEL_PS_WOE_MASK PS_WOE_MASK
104+
#elif defined(__XTENSA_CALL0_ABI__)
105+
#define KERNEL_PS_WOE_MASK 0
106+
#else
107+
#error Unsupported xtensa ABI
108+
#endif
109+
108110
#ifndef __ASSEMBLY__
109111

112+
#if defined(__XTENSA_WINDOWED_ABI__)
113+
110114
/* Build a valid return address for the specified call winsize.
111115
* winsize must be 1 (call4), 2 (call8), or 3 (call12)
112116
*/
@@ -117,6 +121,22 @@
117121
*/
118122
#define MAKE_PC_FROM_RA(ra,sp) (((ra) & 0x3fffffff) | ((sp) & 0xc0000000))
119123

124+
#elif defined(__XTENSA_CALL0_ABI__)
125+
126+
/* Build a valid return address for the specified call winsize.
127+
* winsize must be 1 (call4), 2 (call8), or 3 (call12)
128+
*/
129+
#define MAKE_RA_FOR_CALL(ra, ws) (ra)
130+
131+
/* Convert return address to a valid pc
132+
* Note: We assume that the stack pointer is in the same 1GB ranges as the ra
133+
*/
134+
#define MAKE_PC_FROM_RA(ra, sp) (ra)
135+
136+
#else
137+
#error Unsupported Xtensa ABI
138+
#endif
139+
120140
/* Spill slot location for the register reg in the spill area under the stack
121141
* pointer sp. reg must be in the range [0..4).
122142
*/

0 commit comments

Comments
 (0)