Merge branch 'drm-vmwgfx-fixes' of git://people.freedesktop.org/~syeh/repos_linux...
[sfrench/cifs-2.6.git] / arch / parisc / include / asm / compat.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_PARISC_COMPAT_H
3 #define _ASM_PARISC_COMPAT_H
4 /*
5  * Architecture specific compatibility types
6  */
7 #include <linux/types.h>
8 #include <linux/sched.h>
9 #include <linux/thread_info.h>
10
11 #define COMPAT_USER_HZ          100
12 #define COMPAT_UTS_MACHINE      "parisc\0\0"
13
14 typedef u32     compat_size_t;
15 typedef s32     compat_ssize_t;
16 typedef s32     compat_time_t;
17 typedef s32     compat_clock_t;
18 typedef s32     compat_pid_t;
19 typedef u32     __compat_uid_t;
20 typedef u32     __compat_gid_t;
21 typedef u32     __compat_uid32_t;
22 typedef u32     __compat_gid32_t;
23 typedef u16     compat_mode_t;
24 typedef u32     compat_ino_t;
25 typedef u32     compat_dev_t;
26 typedef s32     compat_off_t;
27 typedef s64     compat_loff_t;
28 typedef u16     compat_nlink_t;
29 typedef u16     compat_ipc_pid_t;
30 typedef s32     compat_daddr_t;
31 typedef u32     compat_caddr_t;
32 typedef s32     compat_key_t;
33 typedef s32     compat_timer_t;
34
35 typedef s32     compat_int_t;
36 typedef s32     compat_long_t;
37 typedef s64     compat_s64;
38 typedef u32     compat_uint_t;
39 typedef u32     compat_ulong_t;
40 typedef u64     compat_u64;
41 typedef u32     compat_uptr_t;
42
43 struct compat_timespec {
44         compat_time_t           tv_sec;
45         s32                     tv_nsec;
46 };
47
48 struct compat_timeval {
49         compat_time_t           tv_sec;
50         s32                     tv_usec;
51 };
52
53 struct compat_stat {
54         compat_dev_t            st_dev; /* dev_t is 32 bits on parisc */
55         compat_ino_t            st_ino; /* 32 bits */
56         compat_mode_t           st_mode;        /* 16 bits */
57         compat_nlink_t          st_nlink;       /* 16 bits */
58         u16                     st_reserved1;   /* old st_uid */
59         u16                     st_reserved2;   /* old st_gid */
60         compat_dev_t            st_rdev;
61         compat_off_t            st_size;
62         compat_time_t           st_atime;
63         u32                     st_atime_nsec;
64         compat_time_t           st_mtime;
65         u32                     st_mtime_nsec;
66         compat_time_t           st_ctime;
67         u32                     st_ctime_nsec;
68         s32                     st_blksize;
69         s32                     st_blocks;
70         u32                     __unused1;      /* ACL stuff */
71         compat_dev_t            __unused2;      /* network */
72         compat_ino_t            __unused3;      /* network */
73         u32                     __unused4;      /* cnodes */
74         u16                     __unused5;      /* netsite */
75         short                   st_fstype;
76         compat_dev_t            st_realdev;
77         u16                     st_basemode;
78         u16                     st_spareshort;
79         __compat_uid32_t        st_uid;
80         __compat_gid32_t        st_gid;
81         u32                     st_spare4[3];
82 };
83
84 struct compat_flock {
85         short                   l_type;
86         short                   l_whence;
87         compat_off_t            l_start;
88         compat_off_t            l_len;
89         compat_pid_t            l_pid;
90 };
91
92 struct compat_flock64 {
93         short                   l_type;
94         short                   l_whence;
95         compat_loff_t           l_start;
96         compat_loff_t           l_len;
97         compat_pid_t            l_pid;
98 };
99
100 struct compat_statfs {
101         s32             f_type;
102         s32             f_bsize;
103         s32             f_blocks;
104         s32             f_bfree;
105         s32             f_bavail;
106         s32             f_files;
107         s32             f_ffree;
108         __kernel_fsid_t f_fsid;
109         s32             f_namelen;
110         s32             f_frsize;
111         s32             f_flags;
112         s32             f_spare[4];
113 };
114
115 struct compat_sigcontext {
116         compat_int_t sc_flags;
117         compat_int_t sc_gr[32]; /* PSW in sc_gr[0] */
118         u64 sc_fr[32];
119         compat_int_t sc_iasq[2];
120         compat_int_t sc_iaoq[2];
121         compat_int_t sc_sar; /* cr11 */
122 };
123
124 #define COMPAT_RLIM_INFINITY 0xffffffff
125
126 typedef u32             compat_old_sigset_t;    /* at least 32 bits */
127
128 #define _COMPAT_NSIG            64
129 #define _COMPAT_NSIG_BPW        32
130
131 typedef u32             compat_sigset_word;
132
133 typedef union compat_sigval {
134         compat_int_t    sival_int;
135         compat_uptr_t   sival_ptr;
136 } compat_sigval_t;
137
138 typedef struct compat_siginfo {
139         int si_signo;
140         int si_errno;
141         int si_code;
142
143         union {
144                 int _pad[128/sizeof(int) - 3];
145
146                 /* kill() */
147                 struct {
148                         unsigned int _pid;      /* sender's pid */
149                         unsigned int _uid;      /* sender's uid */
150                 } _kill;
151
152                 /* POSIX.1b timers */
153                 struct {
154                         compat_timer_t _tid;            /* timer id */
155                         int _overrun;           /* overrun count */
156                         char _pad[sizeof(unsigned int) - sizeof(int)];
157                         compat_sigval_t _sigval;        /* same as below */
158                         int _sys_private;       /* not to be passed to user */
159                 } _timer;
160
161                 /* POSIX.1b signals */
162                 struct {
163                         unsigned int _pid;      /* sender's pid */
164                         unsigned int _uid;      /* sender's uid */
165                         compat_sigval_t _sigval;
166                 } _rt;
167
168                 /* SIGCHLD */
169                 struct {
170                         unsigned int _pid;      /* which child */
171                         unsigned int _uid;      /* sender's uid */
172                         int _status;            /* exit code */
173                         compat_clock_t _utime;
174                         compat_clock_t _stime;
175                 } _sigchld;
176
177                 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
178                 struct {
179                         unsigned int _addr;     /* faulting insn/memory ref. */
180                 } _sigfault;
181
182                 /* SIGPOLL */
183                 struct {
184                         int _band;      /* POLL_IN, POLL_OUT, POLL_MSG */
185                         int _fd;
186                 } _sigpoll;
187
188                 /* SIGSYS */
189                 struct {
190                         compat_uptr_t _call_addr; /* calling user insn */
191                         int _syscall;   /* triggering system call number */
192                         compat_uint_t _arch;    /* AUDIT_ARCH_* of syscall */
193                 } _sigsys;
194         } _sifields;
195 } compat_siginfo_t;
196
197 #define COMPAT_OFF_T_MAX        0x7fffffff
198 #define COMPAT_LOFF_T_MAX       0x7fffffffffffffffL
199
200 struct compat_ipc64_perm {
201         compat_key_t key;
202         __compat_uid_t uid;
203         __compat_gid_t gid;
204         __compat_uid_t cuid;
205         __compat_gid_t cgid;
206         unsigned short int __pad1;
207         compat_mode_t mode;
208         unsigned short int __pad2;
209         unsigned short int seq;
210         unsigned int __pad3;
211         unsigned long __unused1;        /* yes they really are 64bit pads */
212         unsigned long __unused2;
213 };
214
215 struct compat_semid64_ds {
216         struct compat_ipc64_perm sem_perm;
217         unsigned int __unused1;
218         compat_time_t sem_otime;
219         unsigned int __unused2;
220         compat_time_t sem_ctime;
221         compat_ulong_t sem_nsems;
222         compat_ulong_t __unused3;
223         compat_ulong_t __unused4;
224 };
225
226 struct compat_msqid64_ds {
227         struct compat_ipc64_perm msg_perm;
228         unsigned int __unused1;
229         compat_time_t msg_stime;
230         unsigned int __unused2;
231         compat_time_t msg_rtime;
232         unsigned int __unused3;
233         compat_time_t msg_ctime;
234         compat_ulong_t msg_cbytes;
235         compat_ulong_t msg_qnum;
236         compat_ulong_t msg_qbytes;
237         compat_pid_t msg_lspid;
238         compat_pid_t msg_lrpid;
239         compat_ulong_t __unused4;
240         compat_ulong_t __unused5;
241 };
242
243 struct compat_shmid64_ds {
244         struct compat_ipc64_perm shm_perm;
245         unsigned int __unused1;
246         compat_time_t shm_atime;
247         unsigned int __unused2;
248         compat_time_t shm_dtime;
249         unsigned int __unused3;
250         compat_time_t shm_ctime;
251         unsigned int __unused4;
252         compat_size_t shm_segsz;
253         compat_pid_t shm_cpid;
254         compat_pid_t shm_lpid;
255         compat_ulong_t shm_nattch;
256         compat_ulong_t __unused5;
257         compat_ulong_t __unused6;
258 };
259
260 /*
261  * A pointer passed in from user mode. This should not
262  * be used for syscall parameters, just declare them
263  * as pointers because the syscall entry code will have
264  * appropriately converted them already.
265  */
266
267 static inline void __user *compat_ptr(compat_uptr_t uptr)
268 {
269         return (void __user *)(unsigned long)uptr;
270 }
271
272 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
273 {
274         return (u32)(unsigned long)uptr;
275 }
276
277 static __inline__ void __user *arch_compat_alloc_user_space(long len)
278 {
279         struct pt_regs *regs = &current->thread.regs;
280         return (void __user *)regs->gr[30];
281 }
282
283 static inline int __is_compat_task(struct task_struct *t)
284 {
285         return test_ti_thread_flag(task_thread_info(t), TIF_32BIT);
286 }
287
288 static inline int is_compat_task(void)
289 {
290         return __is_compat_task(current);
291 }
292
293 #endif /* _ASM_PARISC_COMPAT_H */