syscall.S 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2004-2007 Atmel Corporation
  3. *
  4. * This file is subject to the terms and conditions of the GNU Lesser General
  5. * Public License. See the file "COPYING.LIB" in the main directory of this
  6. * archive for more details.
  7. */
  8. #include <features.h>
  9. .text
  10. /*
  11. * long int syscall(long int sysno, ...)
  12. */
  13. .global syscall
  14. .type syscall, @function
  15. .align 2
  16. syscall:
  17. stm --sp, r3,r5,r6,lr
  18. sub lr, sp, -16
  19. mov r8, r12
  20. ldm lr, r3,r5,r9-r12
  21. scall
  22. cp.w r12, -4095
  23. brlo .Ldone
  24. #ifdef __PIC__
  25. lddpc r6, .Lgot
  26. .Lgotcalc:
  27. rsub r6, pc
  28. # ifdef __UCLIBC_HAS_THREADS__
  29. rsub r3, r12, 0
  30. mcall r6[__errno_location@got]
  31. st.w r12[0], r3
  32. # else
  33. ld.w r3, r6[errno@got]
  34. neg r12
  35. st.w r3[0], r12
  36. # endif
  37. #else
  38. # ifdef __UCLIBC_HAS_THREADS__
  39. rsub r3, r12, 0
  40. mcall .Lerrno_location
  41. st.w r12[0], r3
  42. # else
  43. lddpc r3, .Lerrno
  44. neg r12
  45. st.w r3[0], r12
  46. # endif
  47. #endif
  48. mov r12, -1
  49. .Ldone:
  50. ldm sp++, r3,r5,r6,pc
  51. .align 2
  52. #ifdef __PIC__
  53. .Lgot:
  54. .long .Lgotcalc - _GLOBAL_OFFSET_TABLE_
  55. #else
  56. # ifdef __UCLIBC_HAS_THREADS__
  57. .Lerrno_location:
  58. .long __errno_location
  59. # else
  60. .Lerrno:
  61. .long errno
  62. # endif
  63. #endif
  64. .size syscall, . - syscall