Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-2.6] / include / asm-s390 / 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 u32             compat_uint_t;
64 typedef u32             compat_ulong_t;
65
66 struct compat_timespec {
67         compat_time_t   tv_sec;
68         s32             tv_nsec;
69 };
70
71 struct compat_timeval {
72         compat_time_t   tv_sec;
73         s32             tv_usec;
74 };
75
76 struct compat_stat {
77         compat_dev_t    st_dev;
78         u16             __pad1;
79         compat_ino_t    st_ino;
80         compat_mode_t   st_mode;
81         compat_nlink_t  st_nlink;
82         __compat_uid_t  st_uid;
83         __compat_gid_t  st_gid;
84         compat_dev_t    st_rdev;
85         u16             __pad2;
86         u32             st_size;
87         u32             st_blksize;
88         u32             st_blocks;
89         u32             st_atime;
90         u32             st_atime_nsec;
91         u32             st_mtime;
92         u32             st_mtime_nsec;
93         u32             st_ctime;
94         u32             st_ctime_nsec;
95         u32             __unused4;
96         u32             __unused5;
97 };
98
99 struct compat_flock {
100         short           l_type;
101         short           l_whence;
102         compat_off_t    l_start;
103         compat_off_t    l_len;
104         compat_pid_t    l_pid;
105 };
106
107 #define F_GETLK64       12
108 #define F_SETLK64       13
109 #define F_SETLKW64      14    
110
111 struct compat_flock64 {
112         short           l_type;
113         short           l_whence;
114         compat_loff_t   l_start;
115         compat_loff_t   l_len;
116         compat_pid_t    l_pid;
117 };
118
119 struct compat_statfs {
120         s32             f_type;
121         s32             f_bsize;
122         s32             f_blocks;
123         s32             f_bfree;
124         s32             f_bavail;
125         s32             f_files;
126         s32             f_ffree;
127         compat_fsid_t   f_fsid;
128         s32             f_namelen;
129         s32             f_frsize;
130         s32             f_spare[6];
131 };
132
133 #define COMPAT_RLIM_OLD_INFINITY        0x7fffffff
134 #define COMPAT_RLIM_INFINITY            0xffffffff
135
136 typedef u32             compat_old_sigset_t;    /* at least 32 bits */
137
138 #define _COMPAT_NSIG            64
139 #define _COMPAT_NSIG_BPW        32
140
141 typedef u32             compat_sigset_word;
142
143 #define COMPAT_OFF_T_MAX        0x7fffffff
144 #define COMPAT_LOFF_T_MAX       0x7fffffffffffffffL
145
146 /*
147  * A pointer passed in from user mode. This should not
148  * be used for syscall parameters, just declare them
149  * as pointers because the syscall entry code will have
150  * appropriately comverted them already.
151  */
152 typedef u32             compat_uptr_t;
153
154 static inline void __user *compat_ptr(compat_uptr_t uptr)
155 {
156         return (void __user *)(unsigned long)(uptr & 0x7fffffffUL);
157 }
158
159 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
160 {
161         return (u32)(unsigned long)uptr;
162 }
163
164 static inline void __user *compat_alloc_user_space(long len)
165 {
166         unsigned long stack;
167
168         stack = KSTK_ESP(current);
169         if (test_thread_flag(TIF_31BIT))
170                 stack &= 0x7fffffffUL;
171         return (void __user *) (stack - len);
172 }
173
174 struct compat_ipc64_perm {
175         compat_key_t key;
176         __compat_uid32_t uid;
177         __compat_gid32_t gid;
178         __compat_uid32_t cuid;
179         __compat_gid32_t cgid;
180         compat_mode_t mode;
181         unsigned short __pad1;
182         unsigned short seq;
183         unsigned short __pad2;
184         unsigned int __unused1;
185         unsigned int __unused2;
186 };
187
188 struct compat_semid64_ds {
189         struct compat_ipc64_perm sem_perm;
190         compat_time_t  sem_otime;
191         compat_ulong_t __pad1;
192         compat_time_t  sem_ctime;
193         compat_ulong_t __pad2;
194         compat_ulong_t sem_nsems;
195         compat_ulong_t __unused1;
196         compat_ulong_t __unused2;
197 };
198
199 struct compat_msqid64_ds {
200         struct compat_ipc64_perm msg_perm;
201         compat_time_t   msg_stime;
202         compat_ulong_t __pad1;
203         compat_time_t   msg_rtime;
204         compat_ulong_t __pad2;
205         compat_time_t   msg_ctime;
206         compat_ulong_t __pad3;
207         compat_ulong_t msg_cbytes;
208         compat_ulong_t msg_qnum;
209         compat_ulong_t msg_qbytes;
210         compat_pid_t   msg_lspid;
211         compat_pid_t   msg_lrpid;
212         compat_ulong_t __unused1;
213         compat_ulong_t __unused2;
214 };
215
216 struct compat_shmid64_ds {
217         struct compat_ipc64_perm shm_perm;
218         compat_size_t  shm_segsz;
219         compat_time_t  shm_atime;
220         compat_ulong_t __pad1;
221         compat_time_t  shm_dtime;
222         compat_ulong_t __pad2;
223         compat_time_t  shm_ctime;
224         compat_ulong_t __pad3;
225         compat_pid_t   shm_cpid;
226         compat_pid_t   shm_lpid;
227         compat_ulong_t shm_nattch;
228         compat_ulong_t __unused1;
229         compat_ulong_t __unused2;
230 };
231 #endif /* _ASM_S390X_COMPAT_H */