xref: /openbmc/linux/arch/powerpc/include/asm/syscalls.h (revision e237506238352f3bfa9cf3983cdab873e35651eb)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2b8b572e1SStephen Rothwell #ifndef __ASM_POWERPC_SYSCALLS_H
3b8b572e1SStephen Rothwell #define __ASM_POWERPC_SYSCALLS_H
4b8b572e1SStephen Rothwell #ifdef __KERNEL__
5b8b572e1SStephen Rothwell 
6b8b572e1SStephen Rothwell #include <linux/compiler.h>
7b8b572e1SStephen Rothwell #include <linux/linkage.h>
8b8b572e1SStephen Rothwell #include <linux/types.h>
9cc47ad40SCédric Le Goater #include <linux/compat.h>
10b8b572e1SStephen Rothwell 
118640de0dSRohan McLure #include <asm/syscall.h>
128cd1def4SRohan McLure #ifdef CONFIG_PPC64
138cd1def4SRohan McLure #include <asm/syscalls_32.h>
148cd1def4SRohan McLure #endif
158cd1def4SRohan McLure #include <asm/unistd.h>
168cd1def4SRohan McLure #include <asm/ucontext.h>
178cd1def4SRohan McLure 
187e92e01bSRohan McLure #ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
197e92e01bSRohan McLure long sys_ni_syscall(void);
207e92e01bSRohan McLure #else
217e92e01bSRohan McLure long sys_ni_syscall(const struct pt_regs *regs);
227e92e01bSRohan McLure #endif
237e92e01bSRohan McLure 
248cd1def4SRohan McLure struct rtas_args;
258cd1def4SRohan McLure 
26016ff72bSRohan McLure /*
27016ff72bSRohan McLure  * long long munging:
28016ff72bSRohan McLure  * The 32 bit ABI passes long longs in an odd even register pair.
29016ff72bSRohan McLure  * High and low parts are swapped depending on endian mode,
30016ff72bSRohan McLure  * so define a macro (similar to mips linux32) to handle that.
31016ff72bSRohan McLure  */
32016ff72bSRohan McLure #ifdef __LITTLE_ENDIAN__
33016ff72bSRohan McLure #define merge_64(low, high) (((u64)high << 32) | low)
34016ff72bSRohan McLure #else
35016ff72bSRohan McLure #define merge_64(high, low) (((u64)high << 32) | low)
36016ff72bSRohan McLure #endif
37016ff72bSRohan McLure 
388cd1def4SRohan McLure /*
398cd1def4SRohan McLure  * PowerPC architecture-specific syscalls
408cd1def4SRohan McLure  */
418cd1def4SRohan McLure 
427e92e01bSRohan McLure #ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
437e92e01bSRohan McLure 
448cd1def4SRohan McLure long sys_rtas(struct rtas_args __user *uargs);
458cd1def4SRohan McLure 
468cd1def4SRohan McLure #ifdef CONFIG_PPC64
478cd1def4SRohan McLure long sys_ppc64_personality(unsigned long personality);
488cd1def4SRohan McLure #ifdef CONFIG_COMPAT
498cd1def4SRohan McLure long compat_sys_ppc64_personality(unsigned long personality);
508cd1def4SRohan McLure #endif /* CONFIG_COMPAT */
518cd1def4SRohan McLure #endif /* CONFIG_PPC64 */
528cd1def4SRohan McLure 
538cd1def4SRohan McLure long sys_swapcontext(struct ucontext __user *old_ctx,
548cd1def4SRohan McLure 		     struct ucontext __user *new_ctx, long ctx_size);
555ba6c9a9SRohan McLure long sys_mmap(unsigned long addr, size_t len,
56b8b572e1SStephen Rothwell 	      unsigned long prot, unsigned long flags,
57b8b572e1SStephen Rothwell 	      unsigned long fd, off_t offset);
585ba6c9a9SRohan McLure long sys_mmap2(unsigned long addr, size_t len,
59b8b572e1SStephen Rothwell 	       unsigned long prot, unsigned long flags,
60b8b572e1SStephen Rothwell 	       unsigned long fd, unsigned long pgoff);
618cd1def4SRohan McLure long sys_switch_endian(void);
628cd1def4SRohan McLure 
638cd1def4SRohan McLure #ifdef CONFIG_PPC32
648cd1def4SRohan McLure long sys_sigreturn(void);
658cd1def4SRohan McLure long sys_debug_setcontext(struct ucontext __user *ctx, int ndbg,
668cd1def4SRohan McLure 			  struct sig_dbg_op __user *dbg);
678cd1def4SRohan McLure #endif
688cd1def4SRohan McLure 
698cd1def4SRohan McLure long sys_rt_sigreturn(void);
708cd1def4SRohan McLure 
718cd1def4SRohan McLure long sys_subpage_prot(unsigned long addr,
728cd1def4SRohan McLure 		      unsigned long len, u32 __user *map);
738cd1def4SRohan McLure 
748cd1def4SRohan McLure #ifdef CONFIG_COMPAT
758cd1def4SRohan McLure long compat_sys_swapcontext(struct ucontext32 __user *old_ctx,
768cd1def4SRohan McLure 			    struct ucontext32 __user *new_ctx,
778cd1def4SRohan McLure 			    int ctx_size);
788cd1def4SRohan McLure long compat_sys_old_getrlimit(unsigned int resource,
798cd1def4SRohan McLure 			      struct compat_rlimit __user *rlim);
808cd1def4SRohan McLure long compat_sys_sigreturn(void);
818cd1def4SRohan McLure long compat_sys_rt_sigreturn(void);
828cd1def4SRohan McLure #endif /* CONFIG_COMPAT */
838cd1def4SRohan McLure 
848cd1def4SRohan McLure /*
858cd1def4SRohan McLure  * Architecture specific signatures required by long long munging:
868cd1def4SRohan McLure  * The 32 bit ABI passes long longs in an odd even register pair.
878cd1def4SRohan McLure  * The following signatures provide a machine long parameter for
888cd1def4SRohan McLure  * each register that will be supplied. The implementation is
898cd1def4SRohan McLure  * responsible for combining parameter pairs.
908cd1def4SRohan McLure  */
91b8b572e1SStephen Rothwell 
92*e2375062SNicholas Piggin #ifdef CONFIG_PPC32
93*e2375062SNicholas Piggin long sys_ppc_pread64(unsigned int fd,
94*e2375062SNicholas Piggin 		     char __user *ubuf, compat_size_t count,
95*e2375062SNicholas Piggin 		     u32 reg6, u32 pos1, u32 pos2);
96*e2375062SNicholas Piggin long sys_ppc_pwrite64(unsigned int fd,
97*e2375062SNicholas Piggin 		      const char __user *ubuf, compat_size_t count,
98*e2375062SNicholas Piggin 		      u32 reg6, u32 pos1, u32 pos2);
99*e2375062SNicholas Piggin long sys_ppc_readahead(int fd, u32 r4,
100*e2375062SNicholas Piggin 		       u32 offset1, u32 offset2, u32 count);
101*e2375062SNicholas Piggin long sys_ppc_truncate64(const char __user *path, u32 reg4,
102*e2375062SNicholas Piggin 		        unsigned long len1, unsigned long len2);
103*e2375062SNicholas Piggin long sys_ppc_ftruncate64(unsigned int fd, u32 reg4,
104*e2375062SNicholas Piggin 			 unsigned long len1, unsigned long len2);
105*e2375062SNicholas Piggin long sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
106*e2375062SNicholas Piggin 			 size_t len, int advice);
107*e2375062SNicholas Piggin #endif
108cc47ad40SCédric Le Goater #ifdef CONFIG_COMPAT
109b7fa9ce8SRohan McLure long compat_sys_mmap2(unsigned long addr, size_t len,
110cc47ad40SCédric Le Goater 		      unsigned long prot, unsigned long flags,
111cc47ad40SCédric Le Goater 		      unsigned long fd, unsigned long pgoff);
1128cd1def4SRohan McLure long compat_sys_ppc_pread64(unsigned int fd,
1138cd1def4SRohan McLure 			    char __user *ubuf, compat_size_t count,
114cc47ad40SCédric Le Goater 			    u32 reg6, u32 pos1, u32 pos2);
1158cd1def4SRohan McLure long compat_sys_ppc_pwrite64(unsigned int fd,
1168cd1def4SRohan McLure 			     const char __user *ubuf, compat_size_t count,
117cc47ad40SCédric Le Goater 			     u32 reg6, u32 pos1, u32 pos2);
1188cd1def4SRohan McLure long compat_sys_ppc_readahead(int fd, u32 r4,
1198cd1def4SRohan McLure 			      u32 offset1, u32 offset2, u32 count);
1208cd1def4SRohan McLure long compat_sys_ppc_truncate64(const char __user *path, u32 reg4,
121cc47ad40SCédric Le Goater 			       unsigned long len1, unsigned long len2);
1228cd1def4SRohan McLure long compat_sys_ppc_ftruncate64(unsigned int fd, u32 reg4,
1238cd1def4SRohan McLure 				unsigned long len1, unsigned long len2);
124dec20c50SRohan McLure long compat_sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
125cc47ad40SCédric Le Goater 				size_t len, int advice);
1268cd1def4SRohan McLure long compat_sys_ppc_sync_file_range2(int fd, unsigned int flags,
1278cd1def4SRohan McLure 				     unsigned int offset1,
1288cd1def4SRohan McLure 				     unsigned int offset2,
1298cd1def4SRohan McLure 				     unsigned int nbytes1,
1308cd1def4SRohan McLure 				     unsigned int nbytes2);
1318cd1def4SRohan McLure #endif /* CONFIG_COMPAT */
132cc47ad40SCédric Le Goater 
1338cd1def4SRohan McLure #if defined(CONFIG_PPC32) || defined(CONFIG_COMPAT)
1348cd1def4SRohan McLure long sys_ppc_fadvise64_64(int fd, int advice,
1358cd1def4SRohan McLure 			  u32 offset_high, u32 offset_low,
1368cd1def4SRohan McLure 			  u32 len_high, u32 len_low);
137cc47ad40SCédric Le Goater #endif
138cc47ad40SCédric Le Goater 
1397e92e01bSRohan McLure #else
1407e92e01bSRohan McLure 
1417e92e01bSRohan McLure #define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, native)
1427e92e01bSRohan McLure #define __SYSCALL(nr, entry) \
14394746890SMichael Ellerman 	long entry(const struct pt_regs *regs);
1447e92e01bSRohan McLure 
1457e92e01bSRohan McLure #ifdef CONFIG_PPC64
1467e92e01bSRohan McLure #include <asm/syscall_table_64.h>
1477e92e01bSRohan McLure #else
1487e92e01bSRohan McLure #include <asm/syscall_table_32.h>
1497e92e01bSRohan McLure #endif /* CONFIG_PPC64 */
1507e92e01bSRohan McLure 
1517e92e01bSRohan McLure #endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
1527e92e01bSRohan McLure 
153b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
154b8b572e1SStephen Rothwell #endif /* __ASM_POWERPC_SYSCALLS_H */
155