setjmp.S 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2013 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <grub/symbol.h>
  19. #include <grub/dl.h>
  20. .file "setjmp.S"
  21. GRUB_MOD_LICENSE "GPLv3+"
  22. .text
  23. /*
  24. * int grub_setjmp (grub_jmp_buf env)
  25. */
  26. FUNCTION(grub_setjmp)
  27. stp x19, x20, [x0], #16
  28. stp x21, x22, [x0], #16
  29. stp x23, x24, [x0], #16
  30. stp x25, x26, [x0], #16
  31. stp x27, x28, [x0], #16
  32. stp x29, x30, [x0], #16
  33. mov x1, sp
  34. str x1, [x0]
  35. mov x0, #0
  36. ret
  37. /*
  38. * int grub_longjmp (grub_jmp_buf env, int val)
  39. */
  40. FUNCTION(grub_longjmp)
  41. ldp x19, x20, [x0], #16
  42. ldp x21, x22, [x0], #16
  43. ldp x23, x24, [x0], #16
  44. ldp x25, x26, [x0], #16
  45. ldp x27, x28, [x0], #16
  46. ldp x29, x30, [x0], #16
  47. ldr x2, [x0]
  48. mov sp, x2
  49. mov x0, #1
  50. cmp x1, #0
  51. csel x0, x1, x0, ne
  52. ret