setjmp.S 1.1 KB

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