Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6] / arch / s390 / include / asm / compat.h
1 #ifndef _ASM_S390X_COMPAT_H
2 #define _ASM_S390X_COMPAT_H
3 /*
4  * Architecture specific compatibility types
5  */
6 #include <linux/types.h>
7 #include <linux/sched.h>
8
9 #define PSW32_MASK_PER          0x40000000UL
10 #define PSW32_MASK_DAT          0x04000000UL
11 #define PSW32_MASK_IO           0x02000000UL
12 #define PSW32_MASK_EXT          0x01000000UL
13 #define PSW32_MASK_KEY          0x00F00000UL
14 #define PSW32_MASK_MCHECK       0x00040000UL
15 #define PSW32_MASK_WAIT         0x00020000UL
16 #define PSW32_MASK_PSTATE       0x00010000UL
17 #define PSW32_MASK_ASC          0x0000C000UL
18 #define PSW32_MASK_CC           0x00003000UL
19 #define PSW32_MASK_PM           0x00000f00UL
20
21 #define PSW32_ADDR_AMODE31      0x80000000UL
22 #define PSW32_ADDR_INSN         0x7FFFFFFFUL
23
24 #define PSW32_BASE_BITS         0x00080000UL
25
26 #define PSW32_ASC_PRIMARY       0x00000000UL
27 #define PSW32_ASC_ACCREG        0x00004000UL
28 #define PSW32_ASC_SECONDARY     0x00008000UL
29 #define PSW32_ASC_HOME          0x0000C000UL
30
31 #define PSW32_MASK_MERGE(CURRENT,NEW) \
32         (((CURRENT) & ~(PSW32_MASK_CC|PSW32_MASK_PM)) | \
33          ((NEW) & (PSW32_MASK_CC|PSW32_MASK_PM)))
34
35 extern long psw32_user_bits;
36
37 #define COMPAT_USER_HZ  100
38
39 typedef u32             compat_size_t;
40 typedef s32             compat_ssize_t;
41 typedef s32             compat_time_t;
42 typedef s32             compat_clock_t;
43 typedef s32             compat_pid_t;
44 typedef u16             __compat_uid_t;
45 typedef u16             __compat_gid_t;
46 typedef u32             __compat_uid32_t;
47 typedef u32             __compat_gid32_t;
48 typedef u16             compat_mode_t;
49 typedef u32             compat_ino_t;
50 typedef u16             compat_dev_t;
51 typedef s32             compat_off_t;
52 typedef s64             compat_loff_t;
53 typedef u16             compat_nlink_t;
54 typedef u16             compat_ipc_pid_t;
55 typedef s32             compat_daddr_t;
56 typedef u32             compat_caddr_t;
57 typedef __kernel_fsid_t compat_fsid_t;
58 typedef s32             compat_key_t;
59 typedef s32             compat_timer_t;
60
61 typedef s32             compat_int_t;
62 typedef s32             compat_long_t;
63 typedef s64             compat_s64;
64 typedef u32             compat_uint_t;
65 typedef u32             compat_ulong_t;
66 typedef u64             compat_u64;
67
68 struct compat_timespec {
69         compat_time_t   tv_sec;
70         s32             tv_nsec;
71 };
72
73 struct compat_timeval {
74         compat_time_t   tv_sec;
75         s32             tv_usec;
76 };
77
78 struct compat_stat {
79         compat_dev_t    st_dev;
80         u16             __pad1;
81         compat_ino_t    st_ino;
82         compat_mode_t   st_mode;
83         compat_nlink_t  st_nlink;
84         __compat_uid_t  st_uid;
85         __compat_gid_t  st_gid;
86         compat_dev_t    st_rdev;
87         u16             __pad2;
88         u32             st_size;
89         u32             st_blksize;
90         u32             st_blocks;
91         u32             st_atime;
92         u32             st_atime_nsec;
93         u32             st_mtime;
94         u32             st_mtime_nsec;
95         u32             st_ctime;
96         u32             st_ctime_nsec;
97         u32             __unused4;
98         u32             __unused5;
99 };
100
101 struct compat_flock {
102         short           l_type;
103         short           l_whence;
104         compat_off_t    l_start;
105         compat_off_t    l_len;
106         compat_pid_t    l_pid;
107 };
108
109 #define F_GETLK64       12
110 #define F_SETLK64       13
111 #define F_SETLKW64      14    
112
113 struct compat_flock64 {
114         short           l_type;
115         short           l_whence;
116         compat_loff_t   l_start;
117         compat_loff_t   l_len;
118         compat_pid_t    l_pid;
119 };
120
121 struct compat_statfs {
122         s32             f_type;
123         s32             f_bsize;
124         s32             f_blocks;
125         s32             f_bfree;
126         s32             f_bavail;
127         s32             f_files;
128         s32             f_ffree;
129         compat_fsid_t   f_fsid;
130         s32             f_namelen;
131         s32             f_frsize;
132         s32             f_spare[6];
133 };
134
135 #define COMPAT_RLIM_OLD_INFINITY        0x7fffffff
136 #define COMPAT_RLIM_INFINITY            0xffffffff
137
138 typedef u32             compat_old_sigset_t;    /* at least 32 bits */
139
140 #define _COMPAT_NSIG            64
141 #define _COMPAT_NSIG_BPW        32
142
143 typedef u32             compat_sigset_word;
144
145 #define COMPAT_OFF_T_MAX        0x7fffffff
146 #define COMPAT_LOFF_T_MAX       0x7fffffffffffffffL
147
148 /*
149  * A pointer passed in from user mode. This should not
150  * be used for syscall parameters, just declare them
151  * as pointers because the syscall entry code will have
152  * appropriately converted them already.
153  */
154 typedef u32             compat_uptr_t;
155
156 static inline void __user *compat_ptr(compat_uptr_t uptr)
157 {
158         return (void __user *)(unsigned long)(uptr & 0x7fffffffUL);
159 }
160
161 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
162 {
163         return (u32)(unsigned long)uptr;
164 }
165
166 static inline void __user *compat_alloc_user_space(long len)
167 {
168         unsigned long stack;
169
170         stack = KSTK_ESP(current);
171         if (test_thread_flag(TIF_31BIT))
172                 stack &= 0x7fffffffUL;
173         return (void __user *) (stack - len);
174 }
175
176 struct compat_ipc64_perm {
177         compat_key_t key;
178         __compat_uid32_t uid;
179         __compat_gid32_t gid;
180         __compat_uid32_t cuid;
181         __compat_gid32_t cgid;
182         compat_mode_t mode;
183         unsigned short __pad1;
184         unsigned short seq;
185         unsigned short __pad2;
186         unsigned int __unused1;
187         unsigned int __unused2;
188 };
189
190 struct compat_semid64_ds {
191         struct compat_ipc64_perm sem_perm;
192         compat_time_t  sem_otime;
193         compat_ulong_t __pad1;
194         compat_time_t  sem_ctime;
195         compat_ulong_t __pad2;
196         compat_ulong_t sem_nsems;
197         compat_ulong_t __unused1;
198         compat_ulong_t __unused2;
199 };
200
201 struct compat_msqid64_ds {
202         struct compat_ipc64_perm msg_perm;
203         compat_time_t   msg_stime;
204         compat_ulong_t __pad1;
205         compat_time_t   msg_rtime;
206         compat_ulong_t __pad2;
207         compat_time_t   msg_ctime;
208         compat_ulong_t __pad3;
209         compat_ulong_t msg_cbytes;
210         compat_ulong_t msg_qnum;
211         compat_ulong_t msg_qbytes;
212         compat_pid_t   msg_lspid;
213         compat_pid_t   msg_lrpid;
214         compat_ulong_t __unused1;
215         compat_ulong_t __unused2;
216 };
217
218 struct compat_shmid64_ds {
219         struct compat_ipc64_perm shm_perm;
220         compat_size_t  shm_segsz;
221         compat_time_t  shm_atime;
222         compat_ulong_t __pad1;
223         compat_time_t  shm_dtime;
224         compat_ulong_t __pad2;
225         compat_time_t  shm_ctime;
226         compat_ulong_t __pad3;
227         compat_pid_t   shm_cpid;
228         compat_pid_t   shm_lpid;
229         compat_ulong_t shm_nattch;
230         compat_ulong_t __unused1;
231         compat_ulong_t __unused2;
232 };
233 #endif /* _ASM_S390X_COMPAT_H */