2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
15 #ifndef _ASM_TILE_COMPAT_H
16 #define _ASM_TILE_COMPAT_H
19 * Architecture specific compatibility types
21 #include <linux/types.h>
22 #include <linux/sched.h>
24 #define COMPAT_USER_HZ 100
26 /* "long" and pointer-based types are different. */
27 typedef s32 compat_long_t;
28 typedef u32 compat_ulong_t;
29 typedef u32 compat_size_t;
30 typedef s32 compat_ssize_t;
31 typedef s32 compat_off_t;
32 typedef s32 compat_time_t;
33 typedef s32 compat_clock_t;
34 typedef u32 compat_ino_t;
35 typedef u32 compat_caddr_t;
36 typedef u32 compat_uptr_t;
38 /* Many types are "int" or otherwise the same. */
39 typedef __kernel_pid_t compat_pid_t;
40 typedef __kernel_uid_t __compat_uid_t;
41 typedef __kernel_gid_t __compat_gid_t;
42 typedef __kernel_uid32_t __compat_uid32_t;
43 typedef __kernel_uid32_t __compat_gid32_t;
44 typedef __kernel_mode_t compat_mode_t;
45 typedef __kernel_dev_t compat_dev_t;
46 typedef __kernel_loff_t compat_loff_t;
47 typedef __kernel_nlink_t compat_nlink_t;
48 typedef __kernel_ipc_pid_t compat_ipc_pid_t;
49 typedef __kernel_daddr_t compat_daddr_t;
50 typedef __kernel_fsid_t compat_fsid_t;
51 typedef __kernel_timer_t compat_timer_t;
52 typedef __kernel_key_t compat_key_t;
53 typedef int compat_int_t;
54 typedef s64 compat_s64;
55 typedef uint compat_uint_t;
56 typedef u64 compat_u64;
58 /* We use the same register dump format in 32-bit images. */
59 typedef unsigned long compat_elf_greg_t;
60 #define COMPAT_ELF_NGREG (sizeof(struct pt_regs) / sizeof(compat_elf_greg_t))
61 typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
63 struct compat_timespec {
68 struct compat_timeval {
77 unsigned int st_nlink;
87 unsigned int st_atime_nsec;
89 unsigned int st_mtime_nsec;
91 unsigned int st_ctime_nsec;
92 unsigned int __unused[2];
95 struct compat_stat64 {
99 unsigned int st_nlink;
102 unsigned long st_rdev;
104 unsigned int st_blksize;
105 unsigned long st_blocks __attribute__((packed));
106 unsigned int st_atime;
107 unsigned int st_atime_nsec;
108 unsigned int st_mtime;
109 unsigned int st_mtime_nsec;
110 unsigned int st_ctime;
111 unsigned int st_ctime_nsec;
112 unsigned int __unused8;
115 #define compat_statfs statfs
117 struct compat_sysctl {
121 unsigned int oldlenp;
124 unsigned int __unused[4];
128 struct compat_flock {
131 compat_off_t l_start;
136 #define F_GETLK64 12 /* using 'struct flock64' */
138 #define F_SETLKW64 14
140 struct compat_flock64 {
143 compat_loff_t l_start;
148 #define COMPAT_RLIM_INFINITY 0xffffffff
150 #define _COMPAT_NSIG 64
151 #define _COMPAT_NSIG_BPW 32
153 typedef u32 compat_sigset_word;
155 #define COMPAT_OFF_T_MAX 0x7fffffff
156 #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
158 struct compat_ipc64_perm {
160 __compat_uid32_t uid;
161 __compat_gid32_t gid;
162 __compat_uid32_t cuid;
163 __compat_gid32_t cgid;
165 unsigned short __pad1;
167 unsigned short __pad2;
168 compat_ulong_t unused1;
169 compat_ulong_t unused2;
172 struct compat_semid64_ds {
173 struct compat_ipc64_perm sem_perm;
174 compat_time_t sem_otime;
175 compat_ulong_t __unused1;
176 compat_time_t sem_ctime;
177 compat_ulong_t __unused2;
178 compat_ulong_t sem_nsems;
179 compat_ulong_t __unused3;
180 compat_ulong_t __unused4;
183 struct compat_msqid64_ds {
184 struct compat_ipc64_perm msg_perm;
185 compat_time_t msg_stime;
186 compat_ulong_t __unused1;
187 compat_time_t msg_rtime;
188 compat_ulong_t __unused2;
189 compat_time_t msg_ctime;
190 compat_ulong_t __unused3;
191 compat_ulong_t msg_cbytes;
192 compat_ulong_t msg_qnum;
193 compat_ulong_t msg_qbytes;
194 compat_pid_t msg_lspid;
195 compat_pid_t msg_lrpid;
196 compat_ulong_t __unused4;
197 compat_ulong_t __unused5;
200 struct compat_shmid64_ds {
201 struct compat_ipc64_perm shm_perm;
202 compat_size_t shm_segsz;
203 compat_time_t shm_atime;
204 compat_ulong_t __unused1;
205 compat_time_t shm_dtime;
206 compat_ulong_t __unused2;
207 compat_time_t shm_ctime;
208 compat_ulong_t __unused3;
209 compat_pid_t shm_cpid;
210 compat_pid_t shm_lpid;
211 compat_ulong_t shm_nattch;
212 compat_ulong_t __unused4;
213 compat_ulong_t __unused5;
217 * A pointer passed in from user mode. This should not
218 * be used for syscall parameters, just declare them
219 * as pointers because the syscall entry code will have
220 * appropriately converted them already.
223 static inline void __user *compat_ptr(compat_uptr_t uptr)
225 return (void __user *)(unsigned long)uptr;
228 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
230 return (u32)(unsigned long)uptr;
233 /* Sign-extend when storing a kernel pointer to a user's ptregs. */
234 static inline unsigned long ptr_to_compat_reg(void __user *uptr)
236 return (long)(int)(long)uptr;
239 static inline void __user *compat_alloc_user_space(long len)
241 struct pt_regs *regs = task_pt_regs(current);
242 return (void __user *)regs->sp - len;
245 static inline int is_compat_task(void)
247 return current_thread_info()->status & TS_COMPAT;
250 extern int compat_setup_rt_frame(int sig, struct k_sigaction *ka,
251 siginfo_t *info, sigset_t *set,
252 struct pt_regs *regs);
254 /* Compat syscalls. */
255 struct compat_sigaction;
256 struct compat_siginfo;
257 struct compat_sigaltstack;
258 long compat_sys_execve(char __user *path, compat_uptr_t __user *argv,
259 compat_uptr_t __user *envp);
260 long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
261 struct compat_sigaction __user *oact,
263 long compat_sys_rt_sigqueueinfo(int pid, int sig,
264 struct compat_siginfo __user *uinfo);
265 long compat_sys_rt_sigreturn(void);
266 long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
267 struct compat_sigaltstack __user *uoss_ptr);
268 long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
269 long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
270 long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
271 u32 dummy, u32 low, u32 high);
272 long compat_sys_pwrite64(unsigned int fd, char __user *ubuf, size_t count,
273 u32 dummy, u32 low, u32 high);
274 long compat_sys_lookup_dcookie(u32 low, u32 high, char __user *buf, size_t len);
275 long compat_sys_sync_file_range2(int fd, unsigned int flags,
276 u32 offset_lo, u32 offset_hi,
277 u32 nbytes_lo, u32 nbytes_hi);
278 long compat_sys_fallocate(int fd, int mode,
279 u32 offset_lo, u32 offset_hi,
280 u32 len_lo, u32 len_hi);
281 long compat_sys_stat64(char __user *filename,
282 struct compat_stat64 __user *statbuf);
283 long compat_sys_lstat64(char __user *filename,
284 struct compat_stat64 __user *statbuf);
285 long compat_sys_fstat64(unsigned int fd, struct compat_stat64 __user *statbuf);
286 long compat_sys_fstatat64(int dfd, char __user *filename,
287 struct compat_stat64 __user *statbuf, int flag);
288 long compat_sys_sched_rr_get_interval(compat_pid_t pid,
289 struct compat_timespec __user *interval);
290 ssize_t compat_sys_sendfile(int out_fd, int in_fd, compat_off_t __user *offset,
293 /* Versions of compat functions that differ from generic Linux. */
294 struct compat_msgbuf;
295 long tile_compat_sys_msgsnd(int msqid,
296 struct compat_msgbuf __user *msgp,
297 size_t msgsz, int msgflg);
298 long tile_compat_sys_msgrcv(int msqid,
299 struct compat_msgbuf __user *msgp,
300 size_t msgsz, long msgtyp, int msgflg);
301 long tile_compat_sys_ptrace(compat_long_t request, compat_long_t pid,
302 compat_long_t addr, compat_long_t data);
304 /* Tilera Linux syscalls that don't have "compat" versions. */
305 #define compat_sys_raise_fpe sys_raise_fpe
306 #define compat_sys_flush_cache sys_flush_cache
308 #endif /* _ASM_TILE_COMPAT_H */