syscall.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* syscall for META/uClibc
  2. *
  3. * Copyright (C) 2013 Imagination Technologies
  4. *
  5. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  6. */
  7. #include <features.h>
  8. #include <errno.h>
  9. #include <sys/types.h>
  10. #include <sys/syscall.h>
  11. long syscall(long sysnum,
  12. long arg1, long arg2, long arg3,
  13. long arg4, long arg5, long arg6)
  14. {
  15. register long __call __asm__ ("D1Re0") = sysnum;
  16. register long __res __asm__ ("D0Re0");
  17. register long __a __asm__ ("D1Ar1") = arg1;
  18. register long __b __asm__ ("D0Ar2") = arg2;
  19. register long __c __asm__ ("D1Ar3") = arg3;
  20. register long __d __asm__ ("D0Ar4") = arg4;
  21. register long __e __asm__ ("D1Ar5") = arg5;
  22. register long __f __asm__ ("D0Ar6") = arg6;
  23. __asm__ __volatile__ ("SWITCH #0x440001"
  24. : "=d" (__res)
  25. : "d" (__call), "d" (__a), "d" (__b),
  26. "d" (__c), "d" (__d), "d" (__e) , "d" (__f)
  27. : "memory");
  28. if(__res >= (unsigned long) -4095) {
  29. long err = __res;
  30. (*__errno_location()) = (-err);
  31. __res = (unsigned long) -1;
  32. }
  33. return (long) __res;
  34. }