syscall.c 1.4 KB

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