syscall.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* vi: set sw=4 ts=4: */
  2. /* syscall for blackfin/uClibc
  3. *
  4. * Copyright (C) 2004 by Analog Devices Inc.
  5. * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Library General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  15. * for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public License
  18. * along with this program; if not, write to the Free Software Foundation,
  19. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <features.h>
  22. #include <errno.h>
  23. #include <sys/types.h>
  24. #include <sys/syscall.h>
  25. long syscall(long sysnum, long a, long b, long c, long d, long e)
  26. {
  27. int _r0 = 0;
  28. asm volatile(
  29. "p0 = %1;" /*SysCall Number*/
  30. "r0 = %2;"
  31. "r1 = %3;"
  32. "r2 = %4;"
  33. "r3 = %6;"
  34. "r4 = %5;"
  35. "excpt 0;" /*Call the System Call*/
  36. "%0 = r0;" /*Store the result of syscall*/
  37. : "=r"(_r0)
  38. : "r"(sysnum), "r"(a), "r"(b),
  39. "r"(c), "r"(d), "r"(e)
  40. : "memory");
  41. if(_r0 >=(unsigned long) -4095) {
  42. (*__errno_location())=(-_r0);
  43. _r0=(unsigned long) -1;
  44. }
  45. return (long) _r0;
  46. }