syscall-eabi.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (C) 2005 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <sys/syscall.h>
  15. #include <bits/arm_asm.h>
  16. #include <bits/arm_bx.h>
  17. /* In the EABI syscall interface, we don't need a special syscall to
  18. implement syscall(). It won't work reliably with 64-bit arguments
  19. (but that is true on many modern platforms). */
  20. .text
  21. .global syscall
  22. .type syscall,%function
  23. .align 4
  24. #if defined(THUMB1_ONLY)
  25. .thumb_func
  26. syscall:
  27. push {r4, r5, r6, r7}
  28. mov ip, r0
  29. mov r0, r1
  30. mov r1, r2
  31. mov r2, r3
  32. add r7, sp, #(4 * 4)
  33. ldmia r7!, {r3, r4, r5, r6}
  34. mov r7, ip
  35. swi 0x0
  36. pop {r4, r5, r6, r7}
  37. ldr r1, =0xfffff000
  38. cmp r0, r1
  39. bcs 1f
  40. bx lr
  41. 1:
  42. push {r3, lr}
  43. bl __syscall_error
  44. POP_RET
  45. .pool
  46. #else
  47. syscall:
  48. mov ip, sp
  49. stmfd sp!, {r4, r5, r6, r7}
  50. mov r7, r0
  51. mov r0, r1
  52. mov r1, r2
  53. mov r2, r3
  54. ldmfd ip, {r3, r4, r5, r6}
  55. swi 0x0
  56. ldmfd sp!, {r4, r5, r6, r7}
  57. cmn r0, #4096
  58. IT(t, cc)
  59. #if defined(__USE_BX__)
  60. bxcc lr
  61. #else
  62. movcc pc, lr
  63. #endif
  64. b __syscall_error
  65. #endif
  66. .size syscall,.-syscall