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>
18typedef __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. */
46typedef unsigned int           __kernel_size_t32;
47typedef int                    __kernel_ssize_t32;
48typedef int                    __kernel_ptrdiff_t32;
49typedef int                    __kernel_time_t32;
50typedef int                    __kernel_clock_t32;
51typedef int                    __kernel_pid_t32;
52typedef unsigned short         __kernel_ipc_pid_t32;
53typedef unsigned int           __kernel_uid_t32;
54typedef unsigned int           __kernel_gid_t32;
55typedef unsigned int           __kernel_dev_t32;
56typedef unsigned int           __kernel_ino_t32;
57typedef unsigned int           __kernel_mode_t32;
58typedef unsigned int           __kernel_umode_t32;
59typedef short                  __kernel_nlink_t32;
60typedef int                    __kernel_daddr_t32;
61typedef int                    __kernel_off_t32;
62typedef unsigned int           __kernel_caddr_t32;
63typedef int 		       __kernel_loff_t32;
64/* typedef __kernel_fsid_t        __kernel_fsid_t32; */
65
66struct 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
79typedef union sigval32 {
80	int sival_int;
81	unsigned int sival_ptr;
82} sigval_t32;
83
84typedef struct siginfo32 {
85	int si_signo;
86	int si_errno;
87	int si_code;
88
89	union {
90		int _pad[SI_PAD_SIZE];
91
92		/* kill() */
93		struct {
94			__kernel_pid_t32 _pid;		/* sender's pid */
95			unsigned int _uid;		/* sender's uid */
96		} _kill;
97
98		/* POSIX.1b timers */
99		struct {
100			unsigned int _timer1;
101			unsigned int _timer2;
102		} _timer;
103
104		/* POSIX.1b signals */
105		struct {
106			__kernel_pid_t32 _pid;		/* sender's pid */
107			unsigned int _uid;		/* sender's uid */
108			sigval_t32 _sigval;
109		} _rt;
110
111		/* SIGCHLD */
112		struct {
113			__kernel_pid_t32 _pid;		/* which child */
114			unsigned int _uid;		/* sender's uid */
115			int _status;			/* exit code */
116			__kernel_clock_t32 _utime;
117			__kernel_clock_t32 _stime;
118		} _sigchld;
119
120		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
121		struct {
122			u32 _addr; /* faulting insn/memory ref. */
123			int _trapno;
124		} _sigfault;
125
126		/* SIGPOLL */
127		struct {
128			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
129			int _fd;
130		} _sigpoll;
131	} _sifields;
132} siginfo_t32;
133
134#define __old_sigset_t32	old_sigset_t32
135#define __old_sigaction32	old_sigaction32
136
137typedef unsigned int __old_sigset_t32;
138struct __old_sigaction32 {
139	unsigned		sa_handler;
140	__old_sigset_t32  	sa_mask;
141	unsigned int    	sa_flags;
142	unsigned		sa_restorer;     /* not used by Linux/SPARC yet */
143};
144
145
146
147#define _PPC32_NSIG	       64
148#define _PPC32_NSIG_BPW	       32
149#define _PPC32_NSIG_WORDS	       (_PPC32_NSIG / _PPC32_NSIG_BPW)
150
151typedef struct {
152       unsigned int sig[_PPC32_NSIG_WORDS];
153} sigset32_t;
154
155struct sigaction32 {
156       unsigned int  sa_handler;	/* Really a pointer, but need to deal
157					     with 32 bits */
158       unsigned int sa_flags;
159       unsigned int sa_restorer;	/* Another 32 bit pointer */
160       sigset32_t sa_mask;		/* A 32 bit mask */
161};
162
163typedef struct sigaltstack_32 {
164	unsigned int ss_sp;
165	int ss_flags;
166	__kernel_size_t32 ss_size;
167} stack_32_t;
168
169struct flock32 {
170	short l_type;
171	short l_whence;
172	__kernel_off_t32 l_start;
173	__kernel_off_t32 l_len;
174	__kernel_pid_t32 l_pid;
175	short __unused;
176};
177
178struct stat32 {
179	__kernel_dev_t32   st_dev; /* 2 */
180	/* __kernel_dev_t32 __pad1; */ /* 2 */
181	__kernel_ino_t32   st_ino; /* 4  */
182	__kernel_mode_t32  st_mode; /* 2  */
183	short   	   st_nlink; /* 2 */
184	__kernel_uid_t32   st_uid; /* 2 */
185	__kernel_gid_t32   st_gid; /* 2 */
186	__kernel_dev_t32   st_rdev; /* 2 */
187	/* __kernel_dev_t32 __pad2; */ /* 2 */
188	__kernel_off_t32   st_size; /* 4 */
189	__kernel_off_t32   st_blksize; /* 4 */
190	__kernel_off_t32   st_blocks; /* 4 */
191	__kernel_time_t32  st_atime; /* 4 */
192	unsigned int       __unused1; /* 4 */
193	__kernel_time_t32  st_mtime; /* 4 */
194	unsigned int       __unused2; /* 4 */
195	__kernel_time_t32  st_ctime; /* 4 */
196	unsigned int       __unused3; /* 4 */
197	unsigned int  __unused4[2]; /* 2*4 */
198};
199
200struct __old_kernel_stat32
201{
202	unsigned short st_dev;
203	unsigned short st_ino;
204	unsigned short st_mode;
205	unsigned short st_nlink;
206	unsigned short st_uid;
207	unsigned short st_gid;
208	unsigned short st_rdev;
209	unsigned int   st_size;
210	unsigned int   st_atime;
211	unsigned int   st_mtime;
212	unsigned int   st_ctime;
213};
214
215struct sigcontext32_struct {
216	unsigned int	_unused[4];
217	int		signal;
218	unsigned int	handler;
219	unsigned int	oldmask;
220	u32 regs;  /* 4 byte pointer to the pt_regs32 structure. */
221};
222
223struct ucontext32 {
224	unsigned int	  uc_flags;
225	unsigned int 	  uc_link;
226	stack_32_t	  uc_stack;
227	struct sigcontext32_struct uc_mcontext;
228	sigset_t	  uc_sigmask;	/* mask last for extensibility */
229};
230
231
232#endif  /* _PPC64_PPC32_H */
233