blob: eceeafa7c8b779cd1bec9f76e1a541a59ee8fe15 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Simon Glass70785632016-10-17 20:29:07 -06002/*
3 * Written by H. Peter Anvin <hpa@zytor.com>
4 * Brought in from Linux v4.4 and modified for U-Boot
5 * From Linux arch/um/sys-i386/setjmp.S
Simon Glass70785632016-10-17 20:29:07 -06006 */
7
8#define _REGPARM
9
10/*
11 * The jmp_buf is assumed to contain the following, in order:
12 * %ebx
13 * %esp
14 * %ebp
15 * %esi
16 * %edi
17 * <return address>
18 */
19
20 .text
21 .align 4
22 .globl setjmp
23 .type setjmp, @function
24setjmp:
25#ifdef _REGPARM
26 movl %eax, %edx
27#else
28 movl 4(%esp), %edx
29#endif
30 popl %ecx /* Return address, and adjust the stack */
31 xorl %eax, %eax /* Return value */
32 movl %ebx, (%edx)
33 movl %esp, 4(%edx) /* Post-return %esp! */
34 pushl %ecx /* Make the call/return stack happy */
35 movl %ebp, 8(%edx)
36 movl %esi, 12(%edx)
37 movl %edi, 16(%edx)
38 movl %ecx, 20(%edx) /* Return address */
39 ret
40
41 /* Provide function size if needed */
42 .size setjmp, .-setjmp
43
44 .align 4
45 .globl longjmp
46 .type longjmp, @function
47longjmp:
48#ifdef _REGPARM
49 xchgl %eax, %edx
50#else
51 movl 4(%esp), %edx /* jmp_ptr address */
Heinrich Schuchardt17101ce2022-10-01 15:00:21 +020052 movl 8(%esp), %eax /* Return value */
Simon Glass70785632016-10-17 20:29:07 -060053#endif
54 movl (%edx), %ebx
55 movl 4(%edx), %esp
56 movl 8(%edx), %ebp
57 movl 12(%edx), %esi
58 movl 16(%edx), %edi
Heinrich Schuchardt17101ce2022-10-01 15:00:21 +020059 test %eax, %eax
60 jnz nz
61 inc %eax
62nz:
Simon Glass70785632016-10-17 20:29:07 -060063 jmp *20(%edx)
64
65 .size longjmp, .-longjmp