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 
8 #include <features.h>
9 #include <errno.h>
10 #include <sys/types.h>
11 #include <sys/syscall.h>
12 
syscall(long sysnum,long arg1,long arg2,long arg3,long arg4,long arg5,long arg6)13 long syscall(long sysnum,
14 	     long arg1, long arg2, long arg3,
15 	     long arg4, long arg5, long arg6)
16 {
17 
18 	register long __call __asm__ ("D1Re0") = sysnum;
19 	register long __res __asm__ ("D0Re0");
20 	register long __a __asm__ ("D1Ar1") = arg1;
21 	register long __b __asm__ ("D0Ar2") = arg2;
22 	register long __c __asm__ ("D1Ar3") = arg3;
23 	register long __d __asm__ ("D0Ar4") = arg4;
24 	register long __e __asm__ ("D1Ar5") = arg5;
25 	register long __f __asm__ ("D0Ar6") = arg6;
26 
27 
28 	__asm__ __volatile__ ("SWITCH  #0x440001"
29 			      : "=d" (__res)
30 			      : "d" (__call), "d" (__a), "d" (__b),
31 				"d" (__c), "d" (__d), "d" (__e) , "d" (__f)
32 			      : "memory");
33 
34 	if(__res >= (unsigned long) -4095) {
35 		long err = __res;
36 		(*__errno_location()) = (-err);
37 		__res = (unsigned long) -1;
38 	}
39 	return (long) __res;
40 }
41