Commit | Line | Data |
---|---|---|
3dd681d9 WD |
1 | /* |
2 | * Copyright (C) 2012 ARM Ltd. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License version 2 as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | */ | |
16 | #ifndef __ASM_COMPAT_H | |
17 | #define __ASM_COMPAT_H | |
18 | #ifdef __KERNEL__ | |
19 | #ifdef CONFIG_COMPAT | |
20 | ||
21 | /* | |
22 | * Architecture specific compatibility types | |
23 | */ | |
24 | #include <linux/types.h> | |
25 | #include <linux/sched.h> | |
26 | ||
27 | #define COMPAT_USER_HZ 100 | |
28 | #define COMPAT_UTS_MACHINE "armv8l\0\0" | |
29 | ||
30 | typedef u32 compat_size_t; | |
31 | typedef s32 compat_ssize_t; | |
32 | typedef s32 compat_time_t; | |
33 | typedef s32 compat_clock_t; | |
34 | typedef s32 compat_pid_t; | |
35 | typedef u32 __compat_uid_t; | |
36 | typedef u32 __compat_gid_t; | |
37 | typedef u32 __compat_uid32_t; | |
38 | typedef u32 __compat_gid32_t; | |
39 | typedef u32 compat_mode_t; | |
40 | typedef u32 compat_ino_t; | |
41 | typedef u32 compat_dev_t; | |
42 | typedef s32 compat_off_t; | |
43 | typedef s64 compat_loff_t; | |
44 | typedef s16 compat_nlink_t; | |
45 | typedef u16 compat_ipc_pid_t; | |
46 | typedef s32 compat_daddr_t; | |
47 | typedef u32 compat_caddr_t; | |
48 | typedef __kernel_fsid_t compat_fsid_t; | |
49 | typedef s32 compat_key_t; | |
50 | typedef s32 compat_timer_t; | |
51 | ||
52 | typedef s32 compat_int_t; | |
53 | typedef s32 compat_long_t; | |
54 | typedef s64 compat_s64; | |
55 | typedef u32 compat_uint_t; | |
56 | typedef u32 compat_ulong_t; | |
57 | typedef u64 compat_u64; | |
58 | ||
59 | struct compat_timespec { | |
60 | compat_time_t tv_sec; | |
61 | s32 tv_nsec; | |
62 | }; | |
63 | ||
64 | struct compat_timeval { | |
65 | compat_time_t tv_sec; | |
66 | s32 tv_usec; | |
67 | }; | |
68 | ||
69 | struct compat_stat { | |
70 | compat_dev_t st_dev; | |
71 | compat_ino_t st_ino; | |
72 | compat_mode_t st_mode; | |
73 | compat_nlink_t st_nlink; | |
74 | __compat_uid32_t st_uid; | |
75 | __compat_gid32_t st_gid; | |
76 | compat_dev_t st_rdev; | |
77 | compat_off_t st_size; | |
78 | compat_off_t st_blksize; | |
79 | compat_off_t st_blocks; | |
80 | compat_time_t st_atime; | |
81 | u32 st_atime_nsec; | |
82 | compat_time_t st_mtime; | |
83 | u32 st_mtime_nsec; | |
84 | compat_time_t st_ctime; | |
85 | u32 st_ctime_nsec; | |
86 | u32 __unused4[2]; | |
87 | }; | |
88 | ||
89 | struct compat_flock { | |
90 | short l_type; | |
91 | short l_whence; | |
92 | compat_off_t l_start; | |
93 | compat_off_t l_len; | |
94 | compat_pid_t l_pid; | |
95 | }; | |
96 | ||
97 | #define F_GETLK64 12 /* using 'struct flock64' */ | |
98 | #define F_SETLK64 13 | |
99 | #define F_SETLKW64 14 | |
100 | ||
101 | struct compat_flock64 { | |
102 | short l_type; | |
103 | short l_whence; | |
104 | compat_loff_t l_start; | |
105 | compat_loff_t l_len; | |
106 | compat_pid_t l_pid; | |
107 | }; | |
108 | ||
109 | struct compat_statfs { | |
110 | int f_type; | |
111 | int f_bsize; | |
112 | int f_blocks; | |
113 | int f_bfree; | |
114 | int f_bavail; | |
115 | int f_files; | |
116 | int f_ffree; | |
117 | compat_fsid_t f_fsid; | |
118 | int f_namelen; /* SunOS ignores this field. */ | |
119 | int f_frsize; | |
120 | int f_flags; | |
121 | int f_spare[4]; | |
122 | }; | |
123 | ||
124 | #define COMPAT_RLIM_INFINITY 0xffffffff | |
125 | ||
126 | typedef u32 compat_old_sigset_t; | |
127 | ||
128 | #define _COMPAT_NSIG 64 | |
129 | #define _COMPAT_NSIG_BPW 32 | |
130 | ||
131 | typedef u32 compat_sigset_word; | |
132 | ||
133 | #define COMPAT_OFF_T_MAX 0x7fffffff | |
134 | #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL | |
135 | ||
136 | /* | |
137 | * A pointer passed in from user mode. This should not | |
138 | * be used for syscall parameters, just declare them | |
139 | * as pointers because the syscall entry code will have | |
140 | * appropriately converted them already. | |
141 | */ | |
142 | typedef u32 compat_uptr_t; | |
143 | ||
144 | static inline void __user *compat_ptr(compat_uptr_t uptr) | |
145 | { | |
146 | return (void __user *)(unsigned long)uptr; | |
147 | } | |
148 | ||
149 | static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
150 | { | |
151 | return (u32)(unsigned long)uptr; | |
152 | } | |
153 | ||
154 | static inline void __user *arch_compat_alloc_user_space(long len) | |
155 | { | |
156 | struct pt_regs *regs = task_pt_regs(current); | |
157 | return (void __user *)regs->compat_sp - len; | |
158 | } | |
159 | ||
160 | struct compat_ipc64_perm { | |
161 | compat_key_t key; | |
162 | __compat_uid32_t uid; | |
163 | __compat_gid32_t gid; | |
164 | __compat_uid32_t cuid; | |
165 | __compat_gid32_t cgid; | |
166 | unsigned short mode; | |
167 | unsigned short __pad1; | |
168 | unsigned short seq; | |
169 | unsigned short __pad2; | |
170 | compat_ulong_t unused1; | |
171 | compat_ulong_t unused2; | |
172 | }; | |
173 | ||
174 | struct compat_semid64_ds { | |
175 | struct compat_ipc64_perm sem_perm; | |
176 | compat_time_t sem_otime; | |
177 | compat_ulong_t __unused1; | |
178 | compat_time_t sem_ctime; | |
179 | compat_ulong_t __unused2; | |
180 | compat_ulong_t sem_nsems; | |
181 | compat_ulong_t __unused3; | |
182 | compat_ulong_t __unused4; | |
183 | }; | |
184 | ||
185 | struct compat_msqid64_ds { | |
186 | struct compat_ipc64_perm msg_perm; | |
187 | compat_time_t msg_stime; | |
188 | compat_ulong_t __unused1; | |
189 | compat_time_t msg_rtime; | |
190 | compat_ulong_t __unused2; | |
191 | compat_time_t msg_ctime; | |
192 | compat_ulong_t __unused3; | |
193 | compat_ulong_t msg_cbytes; | |
194 | compat_ulong_t msg_qnum; | |
195 | compat_ulong_t msg_qbytes; | |
196 | compat_pid_t msg_lspid; | |
197 | compat_pid_t msg_lrpid; | |
198 | compat_ulong_t __unused4; | |
199 | compat_ulong_t __unused5; | |
200 | }; | |
201 | ||
202 | struct compat_shmid64_ds { | |
203 | struct compat_ipc64_perm shm_perm; | |
204 | compat_size_t shm_segsz; | |
205 | compat_time_t shm_atime; | |
206 | compat_ulong_t __unused1; | |
207 | compat_time_t shm_dtime; | |
208 | compat_ulong_t __unused2; | |
209 | compat_time_t shm_ctime; | |
210 | compat_ulong_t __unused3; | |
211 | compat_pid_t shm_cpid; | |
212 | compat_pid_t shm_lpid; | |
213 | compat_ulong_t shm_nattch; | |
214 | compat_ulong_t __unused4; | |
215 | compat_ulong_t __unused5; | |
216 | }; | |
217 | ||
218 | static inline int is_compat_task(void) | |
219 | { | |
220 | return test_thread_flag(TIF_32BIT); | |
221 | } | |
222 | ||
223 | static inline int is_compat_thread(struct thread_info *thread) | |
224 | { | |
225 | return test_ti_thread_flag(thread, TIF_32BIT); | |
226 | } | |
227 | ||
228 | #else /* !CONFIG_COMPAT */ | |
229 | ||
230 | static inline int is_compat_task(void) | |
231 | { | |
232 | return 0; | |
233 | } | |
234 | ||
235 | static inline int is_compat_thread(struct thread_info *thread) | |
236 | { | |
237 | return 0; | |
238 | } | |
239 | ||
240 | #endif /* CONFIG_COMPAT */ | |
241 | #endif /* __KERNEL__ */ | |
242 | #endif /* __ASM_COMPAT_H */ |