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. }