aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile/include/asm/compat.h
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2010-05-28 23:09:12 -0400
committerChris Metcalf <cmetcalf@tilera.com>2010-06-04 17:11:18 -0400
commit867e359b97c970a60626d5d76bbe2a8fadbf38fb (patch)
treec5ccbb7f5172e8555977119608ecb1eee3cc37e3 /arch/tile/include/asm/compat.h
parent5360bd776f73d0a7da571d72a09a03f237e99900 (diff)
arch/tile: core support for Tilera 32-bit chips.
This change is the core kernel support for TILEPro and TILE64 chips. No driver support (except the console driver) is included yet. This includes the relevant Linux headers in asm/; the low-level low-level "Tile architecture" headers in arch/, which are shared with the hypervisor, etc., and are build-system agnostic; and the relevant hypervisor headers in hv/. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Reviewed-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/tile/include/asm/compat.h')
-rw-r--r--arch/tile/include/asm/compat.h308
1 files changed, 308 insertions, 0 deletions
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
new file mode 100644
index 00000000000..e133c53f6c4
--- /dev/null
+++ b/arch/tile/include/asm/compat.h
@@ -0,0 +1,308 @@
1/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
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.
7 *
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
12 * more details.
13 */
14
15#ifndef _ASM_TILE_COMPAT_H
16#define _ASM_TILE_COMPAT_H
17
18/*
19 * Architecture specific compatibility types
20 */
21#include <linux/types.h>
22#include <linux/sched.h>
23
24#define COMPAT_USER_HZ 100
25
26/* "long" and pointer-based types are different. */
27typedef s32 compat_long_t;
28typedef u32 compat_ulong_t;
29typedef u32 compat_size_t;
30typedef s32 compat_ssize_t;
31typedef s32 compat_off_t;
32typedef s32 compat_time_t;
33typedef s32 compat_clock_t;
34typedef u32 compat_ino_t;
35typedef u32 compat_caddr_t;
36typedef u32 compat_uptr_t;
37
38/* Many types are "int" or otherwise the same. */
39typedef __kernel_pid_t compat_pid_t;
40typedef __kernel_uid_t __compat_uid_t;
41typedef __kernel_gid_t __compat_gid_t;
42typedef __kernel_uid32_t __compat_uid32_t;
43typedef __kernel_uid32_t __compat_gid32_t;
44typedef __kernel_mode_t compat_mode_t;
45typedef __kernel_dev_t compat_dev_t;
46typedef __kernel_loff_t compat_loff_t;
47typedef __kernel_nlink_t compat_nlink_t;
48typedef __kernel_ipc_pid_t compat_ipc_pid_t;
49typedef __kernel_daddr_t compat_daddr_t;
50typedef __kernel_fsid_t compat_fsid_t;
51typedef __kernel_timer_t compat_timer_t;
52typedef __kernel_key_t compat_key_t;
53typedef int compat_int_t;
54typedef s64 compat_s64;
55typedef uint compat_uint_t;
56typedef u64 compat_u64;
57
58/* We use the same register dump format in 32-bit images. */
59typedef unsigned long compat_elf_greg_t;
60#define COMPAT_ELF_NGREG (sizeof(struct pt_regs) / sizeof(compat_elf_greg_t))
61typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
62
63struct compat_timespec {
64 compat_time_t tv_sec;
65 s32 tv_nsec;
66};
67
68struct compat_timeval {
69 compat_time_t tv_sec;
70 s32 tv_usec;
71};
72
73struct compat_stat {
74 unsigned int st_dev;
75 unsigned int st_ino;
76 unsigned int st_mode;
77 unsigned int st_nlink;
78 unsigned int st_uid;
79 unsigned int st_gid;
80 unsigned int st_rdev;
81 unsigned int __pad1;
82 int st_size;
83 int st_blksize;
84 int __pad2;
85 int st_blocks;
86 int st_atime;
87 unsigned int st_atime_nsec;
88 int st_mtime;
89 unsigned int st_mtime_nsec;
90 int st_ctime;
91 unsigned int st_ctime_nsec;
92 unsigned int __unused[2];
93};
94
95struct compat_stat64 {
96 unsigned long st_dev;
97 unsigned long st_ino;
98 unsigned int st_mode;
99 unsigned int st_nlink;
100 unsigned int st_uid;
101 unsigned int st_gid;
102 unsigned long st_rdev;
103 long st_size;
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;
113};
114
115#define compat_statfs statfs
116
117struct compat_sysctl {
118 unsigned int name;
119 int nlen;
120 unsigned int oldval;
121 unsigned int oldlenp;
122 unsigned int newval;
123 unsigned int newlen;
124 unsigned int __unused[4];
125};
126
127
128struct compat_flock {
129 short l_type;
130 short l_whence;
131 compat_off_t l_start;
132 compat_off_t l_len;
133 compat_pid_t l_pid;
134};
135
136#define F_GETLK64 12 /* using 'struct flock64' */
137#define F_SETLK64 13
138#define F_SETLKW64 14
139
140struct compat_flock64 {
141 short l_type;
142 short l_whence;
143 compat_loff_t l_start;
144 compat_loff_t l_len;
145 compat_pid_t l_pid;
146};
147
148#define COMPAT_RLIM_INFINITY 0xffffffff
149
150#define _COMPAT_NSIG 64
151#define _COMPAT_NSIG_BPW 32
152
153typedef u32 compat_sigset_word;
154
155#define COMPAT_OFF_T_MAX 0x7fffffff
156#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
157
158struct compat_ipc64_perm {
159 compat_key_t key;
160 __compat_uid32_t uid;
161 __compat_gid32_t gid;
162 __compat_uid32_t cuid;
163 __compat_gid32_t cgid;
164 unsigned short mode;
165 unsigned short __pad1;
166 unsigned short seq;
167 unsigned short __pad2;
168 compat_ulong_t unused1;
169 compat_ulong_t unused2;
170};
171
172struct 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;
181};
182
183struct 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;
198};
199
200struct 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;
214};
215
216/*
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.
221 */
222
223static inline void __user *compat_ptr(compat_uptr_t uptr)
224{
225 return (void __user *)(unsigned long)uptr;
226}
227
228static inline compat_uptr_t ptr_to_compat(void __user *uptr)
229{
230 return (u32)(unsigned long)uptr;
231}
232
233/* Sign-extend when storing a kernel pointer to a user's ptregs. */
234static inline unsigned long ptr_to_compat_reg(void __user *uptr)
235{
236 return (long)(int)(long)uptr;
237}
238
239static inline void __user *compat_alloc_user_space(long len)
240{
241 struct pt_regs *regs = task_pt_regs(current);
242 return (void __user *)regs->sp - len;
243}
244
245static inline int is_compat_task(void)
246{
247 return current_thread_info()->status & TS_COMPAT;
248}
249
250extern int compat_setup_rt_frame(int sig, struct k_sigaction *ka,
251 siginfo_t *info, sigset_t *set,
252 struct pt_regs *regs);
253
254/* Compat syscalls. */
255struct compat_sigaction;
256struct compat_siginfo;
257struct compat_sigaltstack;
258long compat_sys_execve(char __user *path, compat_uptr_t __user *argv,
259 compat_uptr_t __user *envp);
260long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
261 struct compat_sigaction __user *oact,
262 size_t sigsetsize);
263long compat_sys_rt_sigqueueinfo(int pid, int sig,
264 struct compat_siginfo __user *uinfo);
265long compat_sys_rt_sigreturn(void);
266long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
267 struct compat_sigaltstack __user *uoss_ptr);
268long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
269long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
270long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
271 u32 dummy, u32 low, u32 high);
272long compat_sys_pwrite64(unsigned int fd, char __user *ubuf, size_t count,
273 u32 dummy, u32 low, u32 high);
274long compat_sys_lookup_dcookie(u32 low, u32 high, char __user *buf, size_t len);
275long compat_sys_sync_file_range2(int fd, unsigned int flags,
276 u32 offset_lo, u32 offset_hi,
277 u32 nbytes_lo, u32 nbytes_hi);
278long compat_sys_fallocate(int fd, int mode,
279 u32 offset_lo, u32 offset_hi,
280 u32 len_lo, u32 len_hi);
281long compat_sys_stat64(char __user *filename,
282 struct compat_stat64 __user *statbuf);
283long compat_sys_lstat64(char __user *filename,
284 struct compat_stat64 __user *statbuf);
285long compat_sys_fstat64(unsigned int fd, struct compat_stat64 __user *statbuf);
286long compat_sys_fstatat64(int dfd, char __user *filename,
287 struct compat_stat64 __user *statbuf, int flag);
288long compat_sys_sched_rr_get_interval(compat_pid_t pid,
289 struct compat_timespec __user *interval);
290ssize_t compat_sys_sendfile(int out_fd, int in_fd, compat_off_t __user *offset,
291 size_t count);
292
293/* Versions of compat functions that differ from generic Linux. */
294struct compat_msgbuf;
295long tile_compat_sys_msgsnd(int msqid,
296 struct compat_msgbuf __user *msgp,
297 size_t msgsz, int msgflg);
298long tile_compat_sys_msgrcv(int msqid,
299 struct compat_msgbuf __user *msgp,
300 size_t msgsz, long msgtyp, int msgflg);
301long tile_compat_sys_ptrace(compat_long_t request, compat_long_t pid,
302 compat_long_t addr, compat_long_t data);
303
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
307
308#endif /* _ASM_TILE_COMPAT_H */