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_ipc_pid_t compat_ipc_pid_t
;
48 typedef __kernel_daddr_t compat_daddr_t
;
49 typedef __kernel_fsid_t compat_fsid_t
;
50 typedef __kernel_timer_t compat_timer_t
;
51 typedef __kernel_key_t compat_key_t
;
52 typedef int compat_int_t
;
53 typedef s64 compat_s64
;
54 typedef uint compat_uint_t
;
55 typedef u64 compat_u64
;
57 /* We use the same register dump format in 32-bit images. */
58 typedef unsigned long compat_elf_greg_t
;
59 #define COMPAT_ELF_NGREG (sizeof(struct pt_regs) / sizeof(compat_elf_greg_t))
60 typedef compat_elf_greg_t compat_elf_gregset_t
[COMPAT_ELF_NGREG
];
62 struct compat_timespec
{
67 struct compat_timeval
{
72 #define compat_stat stat
73 #define compat_statfs statfs
75 struct compat_sysctl
{
82 unsigned int __unused
[4];
94 #define F_GETLK64 12 /* using 'struct flock64' */
98 struct compat_flock64
{
101 compat_loff_t l_start
;
106 #define COMPAT_RLIM_INFINITY 0xffffffff
108 #define _COMPAT_NSIG 64
109 #define _COMPAT_NSIG_BPW 32
111 typedef u32 compat_sigset_word
;
113 typedef union compat_sigval
{
114 compat_int_t sival_int
;
115 compat_uptr_t sival_ptr
;
118 #define COMPAT_SI_PAD_SIZE (128/sizeof(int) - 3)
120 typedef struct compat_siginfo
{
126 int _pad
[COMPAT_SI_PAD_SIZE
];
130 unsigned int _pid
; /* sender's pid */
131 unsigned int _uid
; /* sender's uid */
134 /* POSIX.1b timers */
136 compat_timer_t _tid
; /* timer id */
137 int _overrun
; /* overrun count */
138 compat_sigval_t _sigval
; /* same as below */
139 int _sys_private
; /* not to be passed to user */
140 int _overrun_incr
; /* amount to add to overrun */
143 /* POSIX.1b signals */
145 unsigned int _pid
; /* sender's pid */
146 unsigned int _uid
; /* sender's uid */
147 compat_sigval_t _sigval
;
152 unsigned int _pid
; /* which child */
153 unsigned int _uid
; /* sender's uid */
154 int _status
; /* exit code */
155 compat_clock_t _utime
;
156 compat_clock_t _stime
;
159 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
161 unsigned int _addr
; /* faulting insn/memory ref. */
162 #ifdef __ARCH_SI_TRAPNO
163 int _trapno
; /* TRAP # which caused the signal */
169 int _band
; /* POLL_IN, POLL_OUT, POLL_MSG */
175 #define COMPAT_OFF_T_MAX 0x7fffffff
176 #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
178 struct compat_ipc64_perm
{
180 __compat_uid32_t uid
;
181 __compat_gid32_t gid
;
182 __compat_uid32_t cuid
;
183 __compat_gid32_t cgid
;
185 unsigned short __pad1
;
187 unsigned short __pad2
;
188 compat_ulong_t unused1
;
189 compat_ulong_t unused2
;
192 struct compat_semid64_ds
{
193 struct compat_ipc64_perm sem_perm
;
194 compat_time_t sem_otime
;
195 compat_ulong_t __unused1
;
196 compat_time_t sem_ctime
;
197 compat_ulong_t __unused2
;
198 compat_ulong_t sem_nsems
;
199 compat_ulong_t __unused3
;
200 compat_ulong_t __unused4
;
203 struct compat_msqid64_ds
{
204 struct compat_ipc64_perm msg_perm
;
205 compat_time_t msg_stime
;
206 compat_ulong_t __unused1
;
207 compat_time_t msg_rtime
;
208 compat_ulong_t __unused2
;
209 compat_time_t msg_ctime
;
210 compat_ulong_t __unused3
;
211 compat_ulong_t msg_cbytes
;
212 compat_ulong_t msg_qnum
;
213 compat_ulong_t msg_qbytes
;
214 compat_pid_t msg_lspid
;
215 compat_pid_t msg_lrpid
;
216 compat_ulong_t __unused4
;
217 compat_ulong_t __unused5
;
220 struct compat_shmid64_ds
{
221 struct compat_ipc64_perm shm_perm
;
222 compat_size_t shm_segsz
;
223 compat_time_t shm_atime
;
224 compat_ulong_t __unused1
;
225 compat_time_t shm_dtime
;
226 compat_ulong_t __unused2
;
227 compat_time_t shm_ctime
;
228 compat_ulong_t __unused3
;
229 compat_pid_t shm_cpid
;
230 compat_pid_t shm_lpid
;
231 compat_ulong_t shm_nattch
;
232 compat_ulong_t __unused4
;
233 compat_ulong_t __unused5
;
237 * A pointer passed in from user mode. This should not
238 * be used for syscall parameters, just declare them
239 * as pointers because the syscall entry code will have
240 * appropriately converted them already.
243 static inline void __user
*compat_ptr(compat_uptr_t uptr
)
245 return (void __user
*)(long)(s32
)uptr
;
248 static inline compat_uptr_t
ptr_to_compat(void __user
*uptr
)
250 return (u32
)(unsigned long)uptr
;
253 /* Sign-extend when storing a kernel pointer to a user's ptregs. */
254 static inline unsigned long ptr_to_compat_reg(void __user
*uptr
)
256 return (long)(int)(long __force
)uptr
;
259 static inline void __user
*arch_compat_alloc_user_space(long len
)
261 struct pt_regs
*regs
= task_pt_regs(current
);
262 return (void __user
*)regs
->sp
- len
;
265 static inline int is_compat_task(void)
267 return current_thread_info()->status
& TS_COMPAT
;
270 extern int compat_setup_rt_frame(struct ksignal
*ksig
, sigset_t
*set
,
271 struct pt_regs
*regs
);
273 /* Compat syscalls. */
274 struct compat_siginfo
;
275 struct compat_sigaltstack
;
276 long compat_sys_rt_sigreturn(void);
277 long compat_sys_truncate64(char __user
*filename
, u32 dummy
, u32 low
, u32 high
);
278 long compat_sys_ftruncate64(unsigned int fd
, u32 dummy
, u32 low
, u32 high
);
279 long compat_sys_pread64(unsigned int fd
, char __user
*ubuf
, size_t count
,
280 u32 dummy
, u32 low
, u32 high
);
281 long compat_sys_pwrite64(unsigned int fd
, char __user
*ubuf
, size_t count
,
282 u32 dummy
, u32 low
, u32 high
);
283 long compat_sys_sync_file_range2(int fd
, unsigned int flags
,
284 u32 offset_lo
, u32 offset_hi
,
285 u32 nbytes_lo
, u32 nbytes_hi
);
286 long compat_sys_fallocate(int fd
, int mode
,
287 u32 offset_lo
, u32 offset_hi
,
288 u32 len_lo
, u32 len_hi
);
289 long compat_sys_llseek(unsigned int fd
, unsigned int offset_high
,
290 unsigned int offset_low
, loff_t __user
* result
,
291 unsigned int origin
);
293 /* Assembly trampoline to avoid clobbering r0. */
294 long _compat_sys_rt_sigreturn(void);
296 #endif /* _ASM_TILE_COMPAT_H */