Simon Glass | 7078563 | 2016-10-17 20:29:07 -0600 | [diff] [blame^] | 1 | /* |
| 2 | * Written by H. Peter Anvin <hpa@zytor.com> |
| 3 | * Brought in from Linux v4.4 and modified for U-Boot |
| 4 | * From Linux arch/um/sys-i386/setjmp.S |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0 |
| 7 | */ |
| 8 | |
| 9 | #define _REGPARM |
| 10 | |
| 11 | /* |
| 12 | * The jmp_buf is assumed to contain the following, in order: |
| 13 | * %ebx |
| 14 | * %esp |
| 15 | * %ebp |
| 16 | * %esi |
| 17 | * %edi |
| 18 | * <return address> |
| 19 | */ |
| 20 | |
| 21 | .text |
| 22 | .align 4 |
| 23 | .globl setjmp |
| 24 | .type setjmp, @function |
| 25 | setjmp: |
| 26 | #ifdef _REGPARM |
| 27 | movl %eax, %edx |
| 28 | #else |
| 29 | movl 4(%esp), %edx |
| 30 | #endif |
| 31 | popl %ecx /* Return address, and adjust the stack */ |
| 32 | xorl %eax, %eax /* Return value */ |
| 33 | movl %ebx, (%edx) |
| 34 | movl %esp, 4(%edx) /* Post-return %esp! */ |
| 35 | pushl %ecx /* Make the call/return stack happy */ |
| 36 | movl %ebp, 8(%edx) |
| 37 | movl %esi, 12(%edx) |
| 38 | movl %edi, 16(%edx) |
| 39 | movl %ecx, 20(%edx) /* Return address */ |
| 40 | ret |
| 41 | |
| 42 | /* Provide function size if needed */ |
| 43 | .size setjmp, .-setjmp |
| 44 | |
| 45 | .align 4 |
| 46 | .globl longjmp |
| 47 | .type longjmp, @function |
| 48 | longjmp: |
| 49 | #ifdef _REGPARM |
| 50 | xchgl %eax, %edx |
| 51 | #else |
| 52 | movl 4(%esp), %edx /* jmp_ptr address */ |
| 53 | #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 |
| 59 | jmp *20(%edx) |
| 60 | |
| 61 | .size longjmp, .-longjmp |