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