1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * (C) 2017 Theobroma Systems Design und Consulting GmbH
4 */
5
6#include <config.h>
7#include <asm/macro.h>
8#include <linux/linkage.h>
9
10.pushsection .text.setjmp, "ax"
11ENTRY(setjmp)
12	/* Preserve all callee-saved registers and the SP */
13	stp  x19, x20, [x0,#0]
14	stp  x21, x22, [x0,#16]
15	stp  x23, x24, [x0,#32]
16	stp  x25, x26, [x0,#48]
17	stp  x27, x28, [x0,#64]
18	stp  x29, x30, [x0,#80]
19	mov  x2, sp
20	str  x2, [x0, #96]
21	mov  x0, #0
22	ret
23ENDPROC(setjmp)
24.popsection
25
26.pushsection .text.longjmp, "ax"
27ENTRY(longjmp)
28	ldp  x19, x20, [x0,#0]
29	ldp  x21, x22, [x0,#16]
30	ldp  x23, x24, [x0,#32]
31	ldp  x25, x26, [x0,#48]
32	ldp  x27, x28, [x0,#64]
33	ldp  x29, x30, [x0,#80]
34	ldr  x2, [x0,#96]
35	mov  sp, x2
36	/* Move the return value in place, but return 1 if passed 0. */
37	adds x0, xzr, x1
38	csinc x0, x0, xzr, ne
39	ret
40ENDPROC(longjmp)
41.popsection
42