syscall.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * libc/sysdeps/linux/nios2/syscall.c -- generic syscall function for linux/nios2
  3. *
  4. * Copyright (C) 2004 Microtronix Datacom Ltd.
  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; see the file COPYING.LIB. If not, see
  18. * <http://www.gnu.org/licenses/>.
  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 _r2 __asm__("r2")=(long)TRAP_ID_SYSCALL;
  27. register long _r3 __asm__("r3")=(long)sysnum;
  28. register long _r4 __asm__("r4")=(long)(a);
  29. register long _r5 __asm__("r5")=(long)(b);
  30. register long _r6 __asm__("r6")=(long)(c);
  31. register long _r7 __asm__("r7")=(long)(d);
  32. register long _r8 __asm__("r8")=(long)(e);
  33. register long _r9 __asm__("r9")=(long)(f);
  34. __asm__ __volatile__(
  35. "trap "
  36. : "=r"(_r2), "=r"(_r3)
  37. : "0"(_r2), "1"(_r3),
  38. "r"(_r4), "r"(_r5), "r"(_r6), "r"(_r7), "r"(_r8), "r"(_r9)
  39. : "memory");
  40. __syscall_return (long, _r2);
  41. }