syscall.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* vi: set sw=4 ts=4: */
  2. /* syscall for blackfin/uClibc
  3. *
  4. * Copyright (C) 2004-2006 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, long f)
  26. {
  27. int _r0 = 0;
  28. __asm__ __volatile__ (
  29. "R5 = %7;"
  30. "R4 = %6;"
  31. "R3 = %5;"
  32. "R2 = %4;"
  33. "R1 = %3;"
  34. "R0 = %2;"
  35. "P0 = %1;"
  36. "excpt 0;"
  37. "%0 = R0;"
  38. : "=r" (_r0)
  39. : "rm" (sysnum),
  40. "rm" (a),
  41. "rm" (b),
  42. "rm" (c),
  43. "rm" (d),
  44. "rm" (e),
  45. "rm" (f)
  46. : "memory","CC","R0","R1","R2","R3","R4","R5","P0");
  47. if (_r0 >= (unsigned long) -4095) {
  48. (*__errno_location()) = (-_r0);
  49. _r0 = (unsigned long) -1;
  50. }
  51. return (long)_r0;
  52. }