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