syscall.c 862 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* vi: set sw=4 ts=4: */
  2. /* syscall for blackfin/uClibc
  3. *
  4. * Copyright (C) 2004 by Analog Devices Inc.
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <features.h>
  10. #include <errno.h>
  11. #include <sys/types.h>
  12. #include <sys/syscall.h>
  13. long syscall(long sysnum, long a, long b, long c, long d, long e)
  14. {
  15. int _r0 = 0;
  16. asm volatile(
  17. "p0 = %1;" /*SysCall Number*/
  18. "r0 = %2;"
  19. "r1 = %3;"
  20. "r2 = %4;"
  21. "r3 = %6;"
  22. "r4 = %5;"
  23. "excpt 0;" /*Call the System Call*/
  24. "%0 = r0;" /*Store the result of syscall*/
  25. : "=r"(_r0)
  26. : "r"(sysnum), "r"(a), "r"(b),
  27. "r"(c), "r"(d), "r"(e)
  28. : "memory");
  29. if(_r0 >=(unsigned long) -4095) {
  30. (*__errno_location())=(-_r0);
  31. _r0=(unsigned long) -1;
  32. }
  33. return (long) _r0;
  34. }