1 #ifndef _PPC64_PPC32_H
2 #define _PPC64_PPC32_H
3 
4 #include <asm/siginfo.h>
5 #include <asm/signal.h>
6 
7 /*
8  * Data types and macros for providing 32b PowerPC support.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version
13  * 2 of the License, or (at your option) any later version.
14  */
15 
16 #ifndef __KERNEL_STRICT_NAMES
17 #include <linux/types.h>
18 typedef __kernel_fsid_t __kernel_fsid_t32;
19 #endif
20 
21 /* Use this to get at 32-bit user passed pointers. */
22 /* Things to consider: the low-level assembly stub does
23    srl x, 0, x for first four arguments, so if you have
24    pointer to something in the first four arguments, just
25    declare it as a pointer, not u32. On the other side,
26    arguments from 5th onwards should be declared as u32
27    for pointers, and need AA() around each usage.
28    A() macro should be used for places where you e.g.
29    have some internal variable u32 and just want to get
30    rid of a compiler warning. AA() has to be used in
31    places where you want to convert a function argument
32    to 32bit pointer or when you e.g. access pt_regs
33    structure and want to consider 32bit registers only.
34    -
35  */
36 #define A(__x) ((unsigned long)(__x))
37 #define AA(__x)				\
38 ({	unsigned long __ret;		\
39 	__asm__ ("clrldi	%0, %0, 32"	\
40 		 : "=r" (__ret)		\
41 		 : "0" (__x));		\
42 	__ret;				\
43 })
44 
45 /* These are here to support 32-bit syscalls on a 64-bit kernel. */
46 typedef unsigned int	__kernel_size_t32;
47 typedef int		__kernel_ssize_t32;
48 typedef int		__kernel_ptrdiff_t32;
49 typedef int		__kernel_time_t32;
50 typedef int		__kernel_clock_t32;
51 typedef int		__kernel_pid_t32;
52 typedef unsigned short	__kernel_ipc_pid_t32;
53 typedef unsigned int	__kernel_uid_t32;
54 typedef unsigned int	__kernel_gid_t32;
55 typedef unsigned int	__kernel_dev_t32;
56 typedef unsigned int	__kernel_ino_t32;
57 typedef unsigned int	__kernel_mode_t32;
58 typedef unsigned int	__kernel_umode_t32;
59 typedef short		__kernel_nlink_t32;
60 typedef int		__kernel_daddr_t32;
61 typedef int		__kernel_off_t32;
62 typedef unsigned int	__kernel_caddr_t32;
63 typedef int		__kernel_loff_t32;
64 typedef int		__kernel_key_t32;
65 
66 struct statfs32 {
67 	int f_type;
68 	int f_bsize;
69 	int f_blocks;
70 	int f_bfree;
71 	int f_bavail;
72 	int f_files;
73 	int f_ffree;
74 	__kernel_fsid_t32 f_fsid;
75 	int f_namelen;  /* SunOS ignores this field. */
76 	int f_spare[6];
77 };
78 
79 struct ustat32 {
80 	__kernel_daddr_t32      f_tfree;
81 	__kernel_ino_t32        f_tinode;
82 	char                    f_fname[6];
83 	char                    f_fpack[6];
84 };
85 
86 typedef union sigval32 {
87 	int sival_int;
88 	unsigned int sival_ptr;
89 } sigval_t32;
90 
91 typedef struct siginfo32 {
92 	int si_signo;
93 	int si_errno;
94 	int si_code;
95 
96 	union {
97 		int _pad[SI_PAD_SIZE32];
98 
99 		/* kill() */
100 		struct {
101 			__kernel_pid_t32 _pid;		/* sender's pid */
102 			__kernel_uid_t32 _uid;		/* sender's uid */
103 		} _kill;
104 
105 		/* POSIX.1b timers */
106 		struct {
107 			unsigned int _timer1;
108 			unsigned int _timer2;
109 		} _timer;
110 
111 		/* POSIX.1b signals */
112 		struct {
113 			__kernel_pid_t32 _pid;		/* sender's pid */
114 			__kernel_uid_t32 _uid;		/* sender's uid */
115 			sigval_t32 _sigval;
116 		} _rt;
117 
118 		/* SIGCHLD */
119 		struct {
120 			__kernel_pid_t32 _pid;		/* which child */
121 			__kernel_uid_t32 _uid;		/* sender's uid */
122 			int _status;			/* exit code */
123 			__kernel_clock_t32 _utime;
124 			__kernel_clock_t32 _stime;
125 		} _sigchld;
126 
127 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
128 		struct {
129 			unsigned int _addr; /* faulting insn/memory ref. */
130 		} _sigfault;
131 
132 		/* SIGPOLL */
133 		struct {
134 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
135 			int _fd;
136 		} _sigpoll;
137 	} _sifields;
138 } siginfo_t32;
139 
140 #define __old_sigset_t32	old_sigset_t32
141 #define __old_sigaction32	old_sigaction32
142 
143 typedef unsigned int __old_sigset_t32;
144 struct __old_sigaction32 {
145 	unsigned int		sa_handler;
146 	__old_sigset_t32  	sa_mask;
147 	unsigned int    	sa_flags;
148 	unsigned int		sa_restorer;     /* not used by Linux/SPARC yet */
149 };
150 
151 
152 
153 #define _PPC32_NSIG	       64
154 #define _PPC32_NSIG_BPW	       32
155 #define _PPC32_NSIG_WORDS	       (_PPC32_NSIG / _PPC32_NSIG_BPW)
156 
157 typedef struct {
158        unsigned int sig[_PPC32_NSIG_WORDS];
159 } sigset32_t;
160 
161 struct sigaction32 {
162        unsigned int  sa_handler;	/* Really a pointer, but need to deal with 32 bits */
163        unsigned int sa_flags;
164        unsigned int sa_restorer;	/* Another 32 bit pointer */
165        sigset32_t sa_mask;		/* A 32 bit mask */
166 };
167 
168 typedef struct sigaltstack_32 {
169 	unsigned int ss_sp;
170 	int ss_flags;
171 	__kernel_size_t32 ss_size;
172 } stack_32_t;
173 
174 struct flock32 {
175 	short l_type;
176 	short l_whence;
177 	__kernel_off_t32 l_start;
178 	__kernel_off_t32 l_len;
179 	__kernel_pid_t32 l_pid;
180 	short __unused;
181 };
182 
183 struct stat32 {
184 	__kernel_dev_t32   st_dev; /* 2 */
185 	/* __kernel_dev_t32 __pad1; */ /* 2 */
186 	__kernel_ino_t32   st_ino; /* 4  */
187 	__kernel_mode_t32  st_mode; /* 2  */
188 	short   	   st_nlink; /* 2 */
189 	__kernel_uid_t32   st_uid; /* 2 */
190 	__kernel_gid_t32   st_gid; /* 2 */
191 	__kernel_dev_t32   st_rdev; /* 2 */
192 	/* __kernel_dev_t32 __pad2; */ /* 2 */
193 	__kernel_off_t32   st_size; /* 4 */
194 	__kernel_off_t32   st_blksize; /* 4 */
195 	__kernel_off_t32   st_blocks; /* 4 */
196 	__kernel_time_t32  st_atime; /* 4 */
197 	unsigned int       __unused1; /* 4 */
198 	__kernel_time_t32  st_mtime; /* 4 */
199 	unsigned int       __unused2; /* 4 */
200 	__kernel_time_t32  st_ctime; /* 4 */
201 	unsigned int       __unused3; /* 4 */
202 	unsigned int  __unused4[2]; /* 2*4 */
203 };
204 
205 struct __old_kernel_stat32
206 {
207 	unsigned short st_dev;
208 	unsigned short st_ino;
209 	unsigned short st_mode;
210 	unsigned short st_nlink;
211 	unsigned short st_uid;
212 	unsigned short st_gid;
213 	unsigned short st_rdev;
214 	unsigned int   st_size;
215 	unsigned int   st_atime;
216 	unsigned int   st_mtime;
217 	unsigned int   st_ctime;
218 };
219 
220 struct sigcontext32 {
221 	unsigned int	_unused[4];
222 	int		signal;
223 	unsigned int	handler;
224 	unsigned int	oldmask;
225 	u32 regs;  /* 4 byte pointer to the pt_regs32 structure. */
226 };
227 
228 struct ucontext32 {
229 	unsigned int	  uc_flags;
230 	unsigned int 	  uc_link;
231 	stack_32_t	  uc_stack;
232 	struct sigcontext32 uc_mcontext;
233 	sigset_t	  uc_sigmask;	/* mask last for extensibility */
234 };
235 
236 struct ipc_kludge_32 {
237 	unsigned int msgp;
238 	int msgtyp;
239 };
240 
241 struct ipc_perm32 {
242         __kernel_key_t32  key;
243         __kernel_uid_t32  uid;
244         __kernel_gid_t32  gid;
245         __kernel_uid_t32  cuid;
246         __kernel_gid_t32  cgid;
247         __kernel_mode_t32 mode;
248         unsigned short  seq;
249 };
250 
251 struct ipc64_perm32 {
252 	__kernel_key_t32 key;
253 	__kernel_uid_t32 uid;
254 	__kernel_gid_t32 gid;
255 	__kernel_uid_t32 cuid;
256 	__kernel_gid_t32 cgid;
257 	__kernel_mode_t32 mode;
258 	unsigned int	seq;
259 	unsigned int	__pad1;
260 	unsigned long	__unused1;
261 	unsigned long	__unused2;
262 };
263 
264 #endif  /* _PPC64_PPC32_H */
265