syscall.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* syscall for arm/uClibc
  2. *
  3. * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include <features.h>
  8. #include <errno.h>
  9. #include <sys/types.h>
  10. #include <sys/syscall.h>
  11. long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
  12. {
  13. #if !defined(__thumb__)
  14. register long _r0 __asm__("r0")=(long)(sysnum);
  15. register long _r6 __asm__("r6")=(long)(f);
  16. register long _r5 __asm__("r5")=(long)(e);
  17. register long _r4 __asm__("r4")=(long)(d);
  18. register long _r3 __asm__("r3")=(long)(c);
  19. register long _r2 __asm__("r2")=(long)(b);
  20. register long _r1 __asm__("r1")=(long)(a);
  21. __asm__ __volatile__(
  22. "swi %1"
  23. : "=r"(_r0)
  24. : "i"(__NR_syscall), "r"(_r0), "r"(_r1),
  25. "r"(_r2), "r"(_r3), "r"(_r4), "r"(_r5),
  26. "r"(_r6)
  27. : "memory");
  28. #else
  29. register long _r7 __asm__("r7")=(long)(sysnum);
  30. register long _r5 __asm__("r5")=(long)(f);
  31. register long _r4 __asm__("r4")=(long)(e);
  32. register long _r3 __asm__("r3")=(long)(d);
  33. register long _r2 __asm__("r2")=(long)(c);
  34. register long _r1 __asm__("r1")=(long)(b);
  35. register long _r0 __asm__("r0")=(long)(a);
  36. __asm__ __volatile__(
  37. "swi 0"
  38. : "=r"(_r0)
  39. : "r"(_r0), "r"(_r1), "r"(_r2), "r"(_r3),
  40. "r"(_r4), "r"(_r5), "r"(_r7)
  41. : "memory");
  42. #endif
  43. if(_r0 >=(unsigned long) -4095) {
  44. long err = _r0;
  45. (*__errno_location())=(-err);
  46. _r0=(unsigned long) -1;
  47. }
  48. return (long) _r0;
  49. }