Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_COMPAT_H |
| 2 | #define _ASM_COMPAT_H |
| 3 | /* |
| 4 | * Architecture specific compatibility types |
| 5 | */ |
Ralf Baechle | 4302e5d | 2009-03-05 11:45:48 +0100 | [diff] [blame] | 6 | #include <linux/thread_info.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/types.h> |
| 8 | #include <asm/page.h> |
Ralf Baechle | b723782 | 2006-12-11 00:43:58 +0000 | [diff] [blame] | 9 | #include <asm/ptrace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 11 | #define COMPAT_USER_HZ 100 |
| 12 | |
| 13 | typedef u32 compat_size_t; |
| 14 | typedef s32 compat_ssize_t; |
| 15 | typedef s32 compat_time_t; |
| 16 | typedef s32 compat_clock_t; |
| 17 | typedef s32 compat_suseconds_t; |
| 18 | |
| 19 | typedef s32 compat_pid_t; |
Ralf Baechle | 4ee1303 | 2005-10-29 19:32:40 +0100 | [diff] [blame] | 20 | typedef s32 __compat_uid_t; |
| 21 | typedef s32 __compat_gid_t; |
| 22 | typedef __compat_uid_t __compat_uid32_t; |
| 23 | typedef __compat_gid_t __compat_gid32_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | typedef u32 compat_mode_t; |
| 25 | typedef u32 compat_ino_t; |
| 26 | typedef u32 compat_dev_t; |
| 27 | typedef s32 compat_off_t; |
| 28 | typedef s64 compat_loff_t; |
| 29 | typedef u32 compat_nlink_t; |
| 30 | typedef s32 compat_ipc_pid_t; |
| 31 | typedef s32 compat_daddr_t; |
| 32 | typedef s32 compat_caddr_t; |
| 33 | typedef struct { |
| 34 | s32 val[2]; |
| 35 | } compat_fsid_t; |
Stephen Rothwell | 0d77e5a | 2005-06-23 00:10:14 -0700 | [diff] [blame] | 36 | typedef s32 compat_timer_t; |
Atsushi Nemoto | 05e4396 | 2006-11-07 18:02:44 +0900 | [diff] [blame] | 37 | typedef s32 compat_key_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | typedef s32 compat_int_t; |
| 40 | typedef s32 compat_long_t; |
Arnd Bergmann | 4b77758 | 2007-07-15 23:41:11 -0700 | [diff] [blame] | 41 | typedef s64 compat_s64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | typedef u32 compat_uint_t; |
| 43 | typedef u32 compat_ulong_t; |
Arnd Bergmann | 4b77758 | 2007-07-15 23:41:11 -0700 | [diff] [blame] | 44 | typedef u64 compat_u64; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
| 46 | struct compat_timespec { |
| 47 | compat_time_t tv_sec; |
| 48 | s32 tv_nsec; |
| 49 | }; |
| 50 | |
| 51 | struct compat_timeval { |
| 52 | compat_time_t tv_sec; |
| 53 | s32 tv_usec; |
| 54 | }; |
| 55 | |
| 56 | struct compat_stat { |
| 57 | compat_dev_t st_dev; |
| 58 | s32 st_pad1[3]; |
| 59 | compat_ino_t st_ino; |
| 60 | compat_mode_t st_mode; |
| 61 | compat_nlink_t st_nlink; |
Ralf Baechle | 4ee1303 | 2005-10-29 19:32:40 +0100 | [diff] [blame] | 62 | __compat_uid_t st_uid; |
| 63 | __compat_gid_t st_gid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | compat_dev_t st_rdev; |
| 65 | s32 st_pad2[2]; |
| 66 | compat_off_t st_size; |
| 67 | s32 st_pad3; |
| 68 | compat_time_t st_atime; |
| 69 | s32 st_atime_nsec; |
| 70 | compat_time_t st_mtime; |
| 71 | s32 st_mtime_nsec; |
| 72 | compat_time_t st_ctime; |
| 73 | s32 st_ctime_nsec; |
| 74 | s32 st_blksize; |
| 75 | s32 st_blocks; |
| 76 | s32 st_pad4[14]; |
| 77 | }; |
| 78 | |
| 79 | struct compat_flock { |
| 80 | short l_type; |
| 81 | short l_whence; |
| 82 | compat_off_t l_start; |
| 83 | compat_off_t l_len; |
| 84 | s32 l_sysid; |
| 85 | compat_pid_t l_pid; |
| 86 | short __unused; |
| 87 | s32 pad[4]; |
| 88 | }; |
| 89 | |
| 90 | #define F_GETLK64 33 |
| 91 | #define F_SETLK64 34 |
| 92 | #define F_SETLKW64 35 |
| 93 | |
| 94 | struct compat_flock64 { |
| 95 | short l_type; |
| 96 | short l_whence; |
| 97 | compat_loff_t l_start; |
| 98 | compat_loff_t l_len; |
| 99 | compat_pid_t l_pid; |
| 100 | }; |
| 101 | |
| 102 | struct compat_statfs { |
| 103 | int f_type; |
| 104 | int f_bsize; |
| 105 | int f_frsize; |
| 106 | int f_blocks; |
| 107 | int f_bfree; |
| 108 | int f_files; |
| 109 | int f_ffree; |
| 110 | int f_bavail; |
| 111 | compat_fsid_t f_fsid; |
| 112 | int f_namelen; |
| 113 | int f_spare[6]; |
| 114 | }; |
| 115 | |
| 116 | #define COMPAT_RLIM_INFINITY 0x7fffffffUL |
| 117 | |
| 118 | typedef u32 compat_old_sigset_t; /* at least 32 bits */ |
| 119 | |
| 120 | #define _COMPAT_NSIG 128 /* Don't ask !$@#% ... */ |
| 121 | #define _COMPAT_NSIG_BPW 32 |
| 122 | |
| 123 | typedef u32 compat_sigset_word; |
| 124 | |
| 125 | #define COMPAT_OFF_T_MAX 0x7fffffff |
| 126 | #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL |
| 127 | |
| 128 | /* |
| 129 | * A pointer passed in from user mode. This should not |
| 130 | * be used for syscall parameters, just declare them |
| 131 | * as pointers because the syscall entry code will have |
Marcin Ĺšlusarz | 8b3de0d | 2008-02-03 16:32:51 +0200 | [diff] [blame] | 132 | * appropriately converted them already. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | */ |
| 134 | typedef u32 compat_uptr_t; |
| 135 | |
Atsushi Nemoto | 219ac73 | 2006-02-21 16:05:11 +0900 | [diff] [blame] | 136 | static inline void __user *compat_ptr(compat_uptr_t uptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
Atsushi Nemoto | 01bebc6 | 2007-07-13 23:51:38 +0900 | [diff] [blame] | 138 | /* cast to a __user pointer via "unsigned long" makes sparse happy */ |
| 139 | return (void __user *)(unsigned long)(long)uptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Ingo Molnar | 62ac285 | 2006-03-27 01:16:13 -0800 | [diff] [blame] | 142 | static inline compat_uptr_t ptr_to_compat(void __user *uptr) |
| 143 | { |
| 144 | return (u32)(unsigned long)uptr; |
| 145 | } |
| 146 | |
Atsushi Nemoto | 219ac73 | 2006-02-21 16:05:11 +0900 | [diff] [blame] | 147 | static inline void __user *compat_alloc_user_space(long len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | { |
| 149 | struct pt_regs *regs = (struct pt_regs *) |
| 150 | ((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1; |
| 151 | |
Atsushi Nemoto | 219ac73 | 2006-02-21 16:05:11 +0900 | [diff] [blame] | 152 | return (void __user *) (regs->regs[29] - len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
Atsushi Nemoto | 05e4396 | 2006-11-07 18:02:44 +0900 | [diff] [blame] | 155 | struct compat_ipc64_perm { |
| 156 | compat_key_t key; |
| 157 | __compat_uid32_t uid; |
| 158 | __compat_gid32_t gid; |
| 159 | __compat_uid32_t cuid; |
| 160 | __compat_gid32_t cgid; |
| 161 | compat_mode_t mode; |
| 162 | unsigned short seq; |
| 163 | unsigned short __pad2; |
| 164 | compat_ulong_t __unused1; |
| 165 | compat_ulong_t __unused2; |
| 166 | }; |
| 167 | |
| 168 | struct compat_semid64_ds { |
| 169 | struct compat_ipc64_perm sem_perm; |
| 170 | compat_time_t sem_otime; |
| 171 | compat_time_t sem_ctime; |
| 172 | compat_ulong_t sem_nsems; |
| 173 | compat_ulong_t __unused1; |
| 174 | compat_ulong_t __unused2; |
| 175 | }; |
| 176 | |
| 177 | struct compat_msqid64_ds { |
| 178 | struct compat_ipc64_perm msg_perm; |
| 179 | #ifndef CONFIG_CPU_LITTLE_ENDIAN |
| 180 | compat_ulong_t __unused1; |
| 181 | #endif |
| 182 | compat_time_t msg_stime; |
| 183 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
| 184 | compat_ulong_t __unused1; |
| 185 | #endif |
| 186 | #ifndef CONFIG_CPU_LITTLE_ENDIAN |
| 187 | compat_ulong_t __unused2; |
| 188 | #endif |
| 189 | compat_time_t msg_rtime; |
| 190 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
| 191 | compat_ulong_t __unused2; |
| 192 | #endif |
| 193 | #ifndef CONFIG_CPU_LITTLE_ENDIAN |
| 194 | compat_ulong_t __unused3; |
| 195 | #endif |
| 196 | compat_time_t msg_ctime; |
| 197 | #ifdef CONFIG_CPU_LITTLE_ENDIAN |
| 198 | compat_ulong_t __unused3; |
| 199 | #endif |
| 200 | compat_ulong_t msg_cbytes; |
| 201 | compat_ulong_t msg_qnum; |
| 202 | compat_ulong_t msg_qbytes; |
| 203 | compat_pid_t msg_lspid; |
| 204 | compat_pid_t msg_lrpid; |
| 205 | compat_ulong_t __unused4; |
| 206 | compat_ulong_t __unused5; |
| 207 | }; |
| 208 | |
| 209 | struct compat_shmid64_ds { |
| 210 | struct compat_ipc64_perm shm_perm; |
| 211 | compat_size_t shm_segsz; |
| 212 | compat_time_t shm_atime; |
| 213 | compat_time_t shm_dtime; |
| 214 | compat_time_t shm_ctime; |
| 215 | compat_pid_t shm_cpid; |
| 216 | compat_pid_t shm_lpid; |
| 217 | compat_ulong_t shm_nattch; |
| 218 | compat_ulong_t __unused1; |
| 219 | compat_ulong_t __unused2; |
| 220 | }; |
| 221 | |
Ralf Baechle | 4302e5d | 2009-03-05 11:45:48 +0100 | [diff] [blame] | 222 | static inline int is_compat_task(void) |
| 223 | { |
| 224 | return test_thread_flag(TIF_32BIT); |
| 225 | } |
| 226 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | #endif /* _ASM_COMPAT_H */ |