xref: /linux/arch/powerpc/include/asm/syscalls.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_POWERPC_SYSCALLS_H
3 #define __ASM_POWERPC_SYSCALLS_H
4 #ifdef __KERNEL__
5 
6 #include <linux/compiler.h>
7 #include <linux/linkage.h>
8 #include <linux/types.h>
9 #include <linux/compat.h>
10 
11 #include <asm/syscall.h>
12 #ifdef CONFIG_PPC64
13 #include <asm/syscalls_32.h>
14 #endif
15 #include <asm/unistd.h>
16 #include <asm/ucontext.h>
17 
18 #ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
19 long sys_ni_syscall(void);
20 #else
21 long sys_ni_syscall(const struct pt_regs *regs);
22 #endif
23 
24 struct rtas_args;
25 
26 /*
27  * long long munging:
28  * The 32 bit ABI passes long longs in an odd even register pair.
29  * High and low parts are swapped depending on endian mode,
30  * so define a macro (similar to mips linux32) to handle that.
31  */
32 #ifdef __LITTLE_ENDIAN__
33 #define merge_64(low, high) (((u64)high << 32) | low)
34 #else
35 #define merge_64(high, low) (((u64)high << 32) | low)
36 #endif
37 
38 /*
39  * PowerPC architecture-specific syscalls
40  */
41 
42 #ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
43 
44 long sys_rtas(struct rtas_args __user *uargs);
45 
46 #ifdef CONFIG_PPC64
47 long sys_ppc64_personality(unsigned long personality);
48 #ifdef CONFIG_COMPAT
49 long compat_sys_ppc64_personality(unsigned long personality);
50 #endif /* CONFIG_COMPAT */
51 #endif /* CONFIG_PPC64 */
52 
53 long sys_swapcontext(struct ucontext __user *old_ctx,
54 		     struct ucontext __user *new_ctx, long ctx_size);
55 long sys_mmap(unsigned long addr, size_t len,
56 	      unsigned long prot, unsigned long flags,
57 	      unsigned long fd, off_t offset);
58 long sys_mmap2(unsigned long addr, size_t len,
59 	       unsigned long prot, unsigned long flags,
60 	       unsigned long fd, unsigned long pgoff);
61 long sys_switch_endian(void);
62 
63 #ifdef CONFIG_PPC32
64 long sys_sigreturn(void);
65 long sys_debug_setcontext(struct ucontext __user *ctx, int ndbg,
66 			  struct sig_dbg_op __user *dbg);
67 #endif
68 
69 long sys_rt_sigreturn(void);
70 
71 long sys_subpage_prot(unsigned long addr,
72 		      unsigned long len, u32 __user *map);
73 
74 #ifdef CONFIG_COMPAT
75 long compat_sys_swapcontext(struct ucontext32 __user *old_ctx,
76 			    struct ucontext32 __user *new_ctx,
77 			    int ctx_size);
78 long compat_sys_old_getrlimit(unsigned int resource,
79 			      struct compat_rlimit __user *rlim);
80 long compat_sys_sigreturn(void);
81 long compat_sys_rt_sigreturn(void);
82 #endif /* CONFIG_COMPAT */
83 
84 /*
85  * Architecture specific signatures required by long long munging:
86  * The 32 bit ABI passes long longs in an odd even register pair.
87  * The following signatures provide a machine long parameter for
88  * each register that will be supplied. The implementation is
89  * responsible for combining parameter pairs.
90  */
91 
92 #ifdef CONFIG_PPC32
93 long sys_ppc_pread64(unsigned int fd,
94 		     char __user *ubuf, compat_size_t count,
95 		     u32 reg6, u32 pos1, u32 pos2);
96 long sys_ppc_pwrite64(unsigned int fd,
97 		      const char __user *ubuf, compat_size_t count,
98 		      u32 reg6, u32 pos1, u32 pos2);
99 long sys_ppc_readahead(int fd, u32 r4,
100 		       u32 offset1, u32 offset2, u32 count);
101 long sys_ppc_truncate64(const char __user *path, u32 reg4,
102 		        unsigned long len1, unsigned long len2);
103 long sys_ppc_ftruncate64(unsigned int fd, u32 reg4,
104 			 unsigned long len1, unsigned long len2);
105 long sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
106 			 size_t len, int advice);
107 long sys_ppc_sync_file_range2(int fd, unsigned int flags,
108 			      unsigned int offset1,
109 			      unsigned int offset2,
110 			      unsigned int nbytes1,
111 			      unsigned int nbytes2);
112 long sys_ppc_fallocate(int fd, int mode, u32 offset1, u32 offset2,
113 		       u32 len1, u32 len2);
114 #endif
115 #ifdef CONFIG_COMPAT
116 long compat_sys_mmap2(unsigned long addr, size_t len,
117 		      unsigned long prot, unsigned long flags,
118 		      unsigned long fd, unsigned long pgoff);
119 long compat_sys_ppc_pread64(unsigned int fd,
120 			    char __user *ubuf, compat_size_t count,
121 			    u32 reg6, u32 pos1, u32 pos2);
122 long compat_sys_ppc_pwrite64(unsigned int fd,
123 			     const char __user *ubuf, compat_size_t count,
124 			     u32 reg6, u32 pos1, u32 pos2);
125 long compat_sys_ppc_readahead(int fd, u32 r4,
126 			      u32 offset1, u32 offset2, u32 count);
127 long compat_sys_ppc_truncate64(const char __user *path, u32 reg4,
128 			       unsigned long len1, unsigned long len2);
129 long compat_sys_ppc_ftruncate64(unsigned int fd, u32 reg4,
130 				unsigned long len1, unsigned long len2);
131 long compat_sys_ppc32_fadvise64(int fd, u32 unused, u32 offset1, u32 offset2,
132 				size_t len, int advice);
133 long compat_sys_ppc_sync_file_range2(int fd, unsigned int flags,
134 				     unsigned int offset1,
135 				     unsigned int offset2,
136 				     unsigned int nbytes1,
137 				     unsigned int nbytes2);
138 #endif /* CONFIG_COMPAT */
139 
140 #if defined(CONFIG_PPC32) || defined(CONFIG_COMPAT)
141 long sys_ppc_fadvise64_64(int fd, int advice,
142 			  u32 offset_high, u32 offset_low,
143 			  u32 len_high, u32 len_low);
144 #endif
145 
146 #else
147 
148 #define __SYSCALL_WITH_COMPAT(nr, native, compat)	__SYSCALL(nr, native)
149 #define __SYSCALL(nr, entry) \
150 	long entry(const struct pt_regs *regs);
151 
152 #ifdef CONFIG_PPC64
153 #include <asm/syscall_table_64.h>
154 #else
155 #include <asm/syscall_table_32.h>
156 #endif /* CONFIG_PPC64 */
157 
158 #endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
159 
160 #endif /* __KERNEL__ */
161 #endif /* __ASM_POWERPC_SYSCALLS_H */
162