blob: 81bef5787191cbd68c5aadcf2612f5c1cf8ff3af [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Philipp Tomsiche5a246f2017-10-10 16:21:13 +02002/*
3 * (C) 2017 Theobroma Systems Design und Consulting GmbH
Philipp Tomsiche5a246f2017-10-10 16:21:13 +02004 */
5
6#include <config.h>
7#include <asm/assembler.h>
8#include <linux/linkage.h>
9
10.pushsection .text.setjmp, "ax"
11ENTRY(setjmp)
12 /*
13 * A subroutine must preserve the contents of the registers
14 * r4-r8, r10, r11 (v1-v5, v7 and v8) and SP (and r9 in PCS
15 * variants that designate r9 as v6).
16 */
17 mov ip, sp
18 stm a1, {v1-v8, ip, lr}
19 mov a1, #0
Sergei Antonov85f8c352022-08-21 16:34:20 +030020 ret lr
Philipp Tomsiche5a246f2017-10-10 16:21:13 +020021ENDPROC(setjmp)
22.popsection
23
24.pushsection .text.longjmp, "ax"
25ENTRY(longjmp)
26 ldm a1, {v1-v8, ip, lr}
27 mov sp, ip
28 mov a1, a2
29 /* If we were passed a return value of zero, return one instead */
30 cmp a1, #0
31 bne 1f
32 mov a1, #1
331:
Sergei Antonov85f8c352022-08-21 16:34:20 +030034 ret lr
Philipp Tomsiche5a246f2017-10-10 16:21:13 +020035ENDPROC(longjmp)
36.popsection
Jerome Forissierfe8aebb2025-04-18 16:09:30 +020037
38.pushsection .text.initjmp, "ax"
39ENTRY(initjmp)
40 stm a1, {v1-v8}
41 /* a2: entry point address, a3: stack base, a4: stack size */
42 add a3, a3, a4
43 str a3, [a1, #32] /* where setjmp would save sp */
44 str a2, [a1, #36] /* where setjmp would save lr */
45 mov a1, #0
46 ret lr
47ENDPROC(initjmp)
48.popsection