__longjmp.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Copyright (C) 2011-2018 Free Software Foundation, Inc.
  2. The GNU C Library is free software; you can redistribute it and/or
  3. modify it under the terms of the GNU Lesser General Public
  4. License as published by the Free Software Foundation; either
  5. version 2.1 of the License, or (at your option) any later version.
  6. The GNU C Library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Lesser General Public License for more details.
  10. You should have received a copy of the GNU Lesser General Public
  11. License along with the GNU C Library. If not, see
  12. <http://www.gnu.org/licenses/>. */
  13. #include <sysdep.h>
  14. #include <jmpbuf-offsets.h>
  15. #include <arch/spr_def.h>
  16. /* PL to return to via iret in longjmp */
  17. #define RETURN_PL 0
  18. .text
  19. ENTRY (__longjmp)
  20. #define RESTORE(r) { ld r, r0 ; ADDI_PTR r0, r0, REGSIZE }
  21. FOR_EACH_CALLEE_SAVED_REG(RESTORE)
  22. /* Make longjmp(buf, 0) return "1" instead.
  23. At the same time, construct our iret context; we set ICS so
  24. we can validly load EX_CONTEXT for iret without being
  25. interrupted halfway through. */
  26. {
  27. ld r2, r0 /* retrieve ICS bit from jmp_buf */
  28. movei r3, 1
  29. cmpeqi r0, r1, 0
  30. }
  31. {
  32. mtspr INTERRUPT_CRITICAL_SECTION, r3
  33. shli r2, r2, SPR_EX_CONTEXT_0_1__ICS_SHIFT
  34. }
  35. {
  36. mtspr EX_CONTEXT_0_0, lr
  37. ori r2, r2, RETURN_PL
  38. }
  39. {
  40. or r0, r1, r0
  41. mtspr EX_CONTEXT_0_1, r2
  42. }
  43. iret
  44. jrp lr /* Keep the backtracer happy. */
  45. END (__longjmp)
  46. libc_hidden_def(__longjmp)