syscall.S 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (C) 2016 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. #include <sys/syscall.h>
  6. #include <sysdep.h>
  7. .text
  8. #ifdef PIC
  9. .pic
  10. #endif
  11. .align 2
  12. #ifdef PIC
  13. #ifdef __NDS32_N1213_43U1H__
  14. 1:
  15. ret
  16. 99:
  17. addi $r2, $lp, 0
  18. jal 1b
  19. sethi $r1, hi20(_GLOBAL_OFFSET_TABLE_)
  20. ori $r1, $r1, lo12(_GLOBAL_OFFSET_TABLE_+4)
  21. add $r1, $lp, $r1
  22. addi $lp, $r2, 0
  23. #else /* !__NDS32_N1213_43U1H__ */
  24. 99:
  25. mfusr $r15, $PC
  26. sethi $r1, hi20(_GLOBAL_OFFSET_TABLE_ + 4)
  27. ori $r1, $r1, lo12(_GLOBAL_OFFSET_TABLE_ + 8)
  28. add $r1, $r15, $r1
  29. #endif /* end of __NDS32_N1213_43U1H__ */
  30. sethi $r15, hi20(__syscall_error@PLT)
  31. ori $r15, $r15, lo12(__syscall_error@PLT)
  32. add $r15, $r15, $r1
  33. jr $r15
  34. #else /* !PIC */
  35. 99:
  36. j __syscall_error
  37. #endif /* end of PIC */
  38. #ifdef PIC
  39. .pic
  40. #endif
  41. .align 2
  42. .globl syscall
  43. .func syscall
  44. .type syscall, @function
  45. syscall:
  46. syscall __NR_syscall
  47. bgez $r0, 2f
  48. sltsi $r1, $r0, -4096;
  49. beqz $r1, 99b;
  50. 2:
  51. ret
  52. .endfunc
  53. .size syscall, .-syscall