xref: /openbmc/linux/arch/parisc/include/asm/unistd.h (revision a2818ee4)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_PARISC_UNISTD_H_
3 #define _ASM_PARISC_UNISTD_H_
4 
5 #include <uapi/asm/unistd.h>
6 
7 #define __NR_Linux_syscalls	__NR_syscalls
8 
9 #ifndef __ASSEMBLY__
10 
11 #define SYS_ify(syscall_name)   __NR_##syscall_name
12 
13 #define __IGNORE_select			/* newselect */
14 #define __IGNORE_fadvise64		/* fadvise64_64 */
15 #define __IGNORE_pkey_mprotect
16 #define __IGNORE_pkey_alloc
17 #define __IGNORE_pkey_free
18 
19 #ifndef ASM_LINE_SEP
20 # define ASM_LINE_SEP ;
21 #endif
22 
23 /* Definition taken from glibc 2.3.3
24  * sysdeps/unix/sysv/linux/hppa/sysdep.h
25  */
26 
27 #ifdef PIC
28 /* WARNING: CANNOT BE USED IN A NOP! */
29 # define K_STW_ASM_PIC	"       copy %%r19, %%r4\n"
30 # define K_LDW_ASM_PIC	"       copy %%r4, %%r19\n"
31 # define K_USING_GR4	"%r4",
32 #else
33 # define K_STW_ASM_PIC	" \n"
34 # define K_LDW_ASM_PIC	" \n"
35 # define K_USING_GR4
36 #endif
37 
38 /* GCC has to be warned that a syscall may clobber all the ABI
39    registers listed as "caller-saves", see page 8, Table 2
40    in section 2.2.6 of the PA-RISC RUN-TIME architecture
41    document. However! r28 is the result and will conflict with
42    the clobber list so it is left out. Also the input arguments
43    registers r20 -> r26 will conflict with the list so they
44    are treated specially. Although r19 is clobbered by the syscall
45    we cannot say this because it would violate ABI, thus we say
46    r4 is clobbered and use that register to save/restore r19
47    across the syscall. */
48 
49 #define K_CALL_CLOB_REGS "%r1", "%r2", K_USING_GR4 \
50 	        	 "%r20", "%r29", "%r31"
51 
52 #undef K_INLINE_SYSCALL
53 #define K_INLINE_SYSCALL(name, nr, args...)	({			\
54 	long __sys_res;							\
55 	{								\
56 		register unsigned long __res __asm__("r28");		\
57 		K_LOAD_ARGS_##nr(args)					\
58 		/* FIXME: HACK stw/ldw r19 around syscall */		\
59 		__asm__ volatile(					\
60 			K_STW_ASM_PIC					\
61 			"	ble  0x100(%%sr2, %%r0)\n"		\
62 			"	ldi %1, %%r20\n"			\
63 			K_LDW_ASM_PIC					\
64 			: "=r" (__res)					\
65 			: "i" (SYS_ify(name)) K_ASM_ARGS_##nr   	\
66 			: "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_##nr	\
67 		);							\
68 		__sys_res = (long)__res;				\
69 	}								\
70 	if ( (unsigned long)__sys_res >= (unsigned long)-4095 ){	\
71 		errno = -__sys_res;		        		\
72 		__sys_res = -1;						\
73 	}								\
74 	__sys_res;							\
75 })
76 
77 #define K_LOAD_ARGS_0()
78 #define K_LOAD_ARGS_1(r26)					\
79 	register unsigned long __r26 __asm__("r26") = (unsigned long)(r26);   \
80 	K_LOAD_ARGS_0()
81 #define K_LOAD_ARGS_2(r26,r25)					\
82 	register unsigned long __r25 __asm__("r25") = (unsigned long)(r25);   \
83 	K_LOAD_ARGS_1(r26)
84 #define K_LOAD_ARGS_3(r26,r25,r24)				\
85 	register unsigned long __r24 __asm__("r24") = (unsigned long)(r24);   \
86 	K_LOAD_ARGS_2(r26,r25)
87 #define K_LOAD_ARGS_4(r26,r25,r24,r23)				\
88 	register unsigned long __r23 __asm__("r23") = (unsigned long)(r23);   \
89 	K_LOAD_ARGS_3(r26,r25,r24)
90 #define K_LOAD_ARGS_5(r26,r25,r24,r23,r22)			\
91 	register unsigned long __r22 __asm__("r22") = (unsigned long)(r22);   \
92 	K_LOAD_ARGS_4(r26,r25,r24,r23)
93 #define K_LOAD_ARGS_6(r26,r25,r24,r23,r22,r21)			\
94 	register unsigned long __r21 __asm__("r21") = (unsigned long)(r21);   \
95 	K_LOAD_ARGS_5(r26,r25,r24,r23,r22)
96 
97 /* Even with zero args we use r20 for the syscall number */
98 #define K_ASM_ARGS_0
99 #define K_ASM_ARGS_1 K_ASM_ARGS_0, "r" (__r26)
100 #define K_ASM_ARGS_2 K_ASM_ARGS_1, "r" (__r25)
101 #define K_ASM_ARGS_3 K_ASM_ARGS_2, "r" (__r24)
102 #define K_ASM_ARGS_4 K_ASM_ARGS_3, "r" (__r23)
103 #define K_ASM_ARGS_5 K_ASM_ARGS_4, "r" (__r22)
104 #define K_ASM_ARGS_6 K_ASM_ARGS_5, "r" (__r21)
105 
106 /* The registers not listed as inputs but clobbered */
107 #define K_CLOB_ARGS_6
108 #define K_CLOB_ARGS_5 K_CLOB_ARGS_6, "%r21"
109 #define K_CLOB_ARGS_4 K_CLOB_ARGS_5, "%r22"
110 #define K_CLOB_ARGS_3 K_CLOB_ARGS_4, "%r23"
111 #define K_CLOB_ARGS_2 K_CLOB_ARGS_3, "%r24"
112 #define K_CLOB_ARGS_1 K_CLOB_ARGS_2, "%r25"
113 #define K_CLOB_ARGS_0 K_CLOB_ARGS_1, "%r26"
114 
115 #define _syscall0(type,name)						\
116 type name(void)								\
117 {									\
118     return K_INLINE_SYSCALL(name, 0);	                                \
119 }
120 
121 #define _syscall1(type,name,type1,arg1)					\
122 type name(type1 arg1)							\
123 {									\
124     return K_INLINE_SYSCALL(name, 1, arg1);	                        \
125 }
126 
127 #define _syscall2(type,name,type1,arg1,type2,arg2)			\
128 type name(type1 arg1, type2 arg2)					\
129 {									\
130     return K_INLINE_SYSCALL(name, 2, arg1, arg2);	                \
131 }
132 
133 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)		\
134 type name(type1 arg1, type2 arg2, type3 arg3)				\
135 {									\
136     return K_INLINE_SYSCALL(name, 3, arg1, arg2, arg3);	                \
137 }
138 
139 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
140 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4)		\
141 {									\
142     return K_INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4);	        \
143 }
144 
145 /* select takes 5 arguments */
146 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
147 type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)	\
148 {									\
149     return K_INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5);	\
150 }
151 
152 #define __ARCH_WANT_NEW_STAT
153 #define __ARCH_WANT_OLD_READDIR
154 #define __ARCH_WANT_STAT64
155 #define __ARCH_WANT_SYS_ALARM
156 #define __ARCH_WANT_SYS_GETHOSTNAME
157 #define __ARCH_WANT_SYS_PAUSE
158 #define __ARCH_WANT_SYS_SIGNAL
159 #define __ARCH_WANT_SYS_TIME
160 #define __ARCH_WANT_COMPAT_SYS_TIME
161 #define __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL
162 #define __ARCH_WANT_SYS_UTIME
163 #define __ARCH_WANT_SYS_UTIME32
164 #define __ARCH_WANT_SYS_WAITPID
165 #define __ARCH_WANT_SYS_SOCKETCALL
166 #define __ARCH_WANT_SYS_FADVISE64
167 #define __ARCH_WANT_SYS_GETPGRP
168 #define __ARCH_WANT_SYS_NICE
169 #define __ARCH_WANT_SYS_OLDUMOUNT
170 #define __ARCH_WANT_SYS_SIGPENDING
171 #define __ARCH_WANT_SYS_SIGPROCMASK
172 #define __ARCH_WANT_SYS_FORK
173 #define __ARCH_WANT_SYS_VFORK
174 #define __ARCH_WANT_SYS_CLONE
175 #define __ARCH_WANT_COMPAT_SYS_SENDFILE
176 
177 #endif /* __ASSEMBLY__ */
178 
179 #undef STR
180 
181 #endif /* _ASM_PARISC_UNISTD_H_ */
182