setjmp.S 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #define _REGPARM
  8. /*
  9. * The jmp_buf is assumed to contain the following, in order:
  10. * %ebx
  11. * %esp
  12. * %ebp
  13. * %esi
  14. * %edi
  15. * <return address>
  16. */
  17. .text
  18. .align 4
  19. .globl setjmp
  20. .type setjmp, @function
  21. setjmp:
  22. #ifdef _REGPARM
  23. movl %eax, %edx
  24. #else
  25. movl 4(%esp), %edx
  26. #endif
  27. popl %ecx /* Return address, and adjust the stack */
  28. xorl %eax, %eax /* Return value */
  29. movl %ebx, (%edx)
  30. movl %esp, 4(%edx) /* Post-return %esp! */
  31. pushl %ecx /* Make the call/return stack happy */
  32. movl %ebp, 8(%edx)
  33. movl %esi, 12(%edx)
  34. movl %edi, 16(%edx)
  35. movl %ecx, 20(%edx) /* Return address */
  36. ret
  37. /* Provide function size if needed */
  38. .size setjmp, .-setjmp
  39. .align 4
  40. .globl longjmp
  41. .type longjmp, @function
  42. longjmp:
  43. #ifdef _REGPARM
  44. xchgl %eax, %edx
  45. #else
  46. movl 4(%esp), %edx /* jmp_ptr address */
  47. #endif
  48. movl (%edx), %ebx
  49. movl 4(%edx), %esp
  50. movl 8(%edx), %ebp
  51. movl 12(%edx), %esi
  52. movl 16(%edx), %edi
  53. jmp *20(%edx)
  54. .size longjmp, .-longjmp