uboot/arch/x86/cpu/i386/setjmp.S
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   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
   6 */
   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 */
  52#endif
  53        movl (%edx), %ebx
  54        movl 4(%edx), %esp
  55        movl 8(%edx), %ebp
  56        movl 12(%edx), %esi
  57        movl 16(%edx), %edi
  58        jmp *20(%edx)
  59
  60        .size longjmp, .-longjmp
  61