syscall.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU Library General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  14. * for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <features.h>
  21. #include <errno.h>
  22. #include <sys/types.h>
  23. #include <sys/syscall.h>
  24. long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
  25. {
  26. register long _r0 asm("r0")=(long)(sysnum);
  27. register long _r6 asm("r6")=(long)(f);
  28. register long _r5 asm("r5")=(long)(e);
  29. register long _r4 asm("r4")=(long)(d);
  30. register long _r3 asm("r3")=(long)(c);
  31. register long _r2 asm("r2")=(long)(b);
  32. register long _r1 asm("r1")=(long)(a);
  33. asm volatile(
  34. "swi %1"
  35. : "=r"(_r0)
  36. : "i"(__NR_syscall), "r"(_r0), "r"(_r1),
  37. "r"(_r2), "r"(_r3), "r"(_r4), "r"(_r5),
  38. "r"(_r6)
  39. : "memory");
  40. if(_r0 >=(unsigned long) -4095) {
  41. (*__errno_location())=(-_r0);
  42. _r0=(unsigned long) -1;
  43. }
  44. return (long) _r0;
  45. }