1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *  * Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 *  * Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in
12 *    the documentation and/or other materials provided with the
13 *    distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _SYS_USER_H_
30#define _SYS_USER_H_
31
32#include <sys/cdefs.h>
33#include <stddef.h> /* For size_t. */
34
35__BEGIN_DECLS
36
37#define PAGE_SIZE 4096
38#define PAGE_MASK (~(PAGE_SIZE - 1))
39
40#if __i386__
41
42struct user_fpregs_struct {
43  long cwd;
44  long swd;
45  long twd;
46  long fip;
47  long fcs;
48  long foo;
49  long fos;
50  long st_space[20];
51};
52struct user_fpxregs_struct {
53  unsigned short cwd;
54  unsigned short swd;
55  unsigned short twd;
56  unsigned short fop;
57  long fip;
58  long fcs;
59  long foo;
60  long fos;
61  long mxcsr;
62  long reserved;
63  long st_space[32];
64  long xmm_space[32];
65  long padding[56];
66};
67struct user_regs_struct {
68  long ebx;
69  long ecx;
70  long edx;
71  long esi;
72  long edi;
73  long ebp;
74  long eax;
75  long xds;
76  long xes;
77  long xfs;
78  long xgs;
79  long orig_eax;
80  long eip;
81  long xcs;
82  long eflags;
83  long esp;
84  long xss;
85};
86struct user {
87  struct user_regs_struct regs;
88  int u_fpvalid;
89  struct user_fpregs_struct i387;
90  unsigned long int u_tsize;
91  unsigned long int u_dsize;
92  unsigned long int u_ssize;
93  unsigned long start_code;
94  unsigned long start_stack;
95  long int signal;
96  int reserved;
97  struct user_regs_struct* u_ar0;
98  struct user_fpregs_struct* u_fpstate;
99  unsigned long magic;
100  char u_comm[32];
101  int u_debugreg[8];
102};
103
104#elif defined(__x86_64__)
105
106struct user_fpregs_struct {
107  unsigned short cwd;
108  unsigned short swd;
109  unsigned short ftw;
110  unsigned short fop;
111  __u64 rip;
112  __u64 rdp;
113  __u32 mxcsr;
114  __u32 mxcr_mask;
115  __u32 st_space[32];
116  __u32 xmm_space[64];
117  __u32 padding[24];
118};
119struct user_regs_struct {
120  unsigned long r15;
121  unsigned long r14;
122  unsigned long r13;
123  unsigned long r12;
124  unsigned long rbp;
125  unsigned long rbx;
126  unsigned long r11;
127  unsigned long r10;
128  unsigned long r9;
129  unsigned long r8;
130  unsigned long rax;
131  unsigned long rcx;
132  unsigned long rdx;
133  unsigned long rsi;
134  unsigned long rdi;
135  unsigned long orig_rax;
136  unsigned long rip;
137  unsigned long cs;
138  unsigned long eflags;
139  unsigned long rsp;
140  unsigned long ss;
141  unsigned long fs_base;
142  unsigned long gs_base;
143  unsigned long ds;
144  unsigned long es;
145  unsigned long fs;
146  unsigned long gs;
147};
148struct user {
149  struct user_regs_struct regs;
150  int u_fpvalid;
151  int pad0;
152  struct user_fpregs_struct i387;
153  unsigned long int u_tsize;
154  unsigned long int u_dsize;
155  unsigned long int u_ssize;
156  unsigned long start_code;
157  unsigned long start_stack;
158  long int signal;
159  int reserved;
160  int pad1;
161  struct user_regs_struct* u_ar0;
162  struct user_fpregs_struct* u_fpstate;
163  unsigned long magic;
164  char u_comm[32];
165  unsigned long u_debugreg[8];
166  unsigned long error_code;
167  unsigned long fault_address;
168};
169
170#elif defined(__mips__)
171
172struct user {
173  unsigned long regs[180 / sizeof(unsigned long) + 64];
174  size_t u_tsize;
175  size_t u_dsize;
176  size_t u_ssize;
177  unsigned long start_code;
178  unsigned long start_data;
179  unsigned long start_stack;
180  long int signal;
181  void* u_ar0;
182  unsigned long magic;
183  char u_comm[32];
184};
185
186#elif defined(__arm__)
187
188struct user_fpregs {
189  struct fp_reg {
190    unsigned int sign1:1;
191    unsigned int unused:15;
192    unsigned int sign2:1;
193    unsigned int exponent:14;
194    unsigned int j:1;
195    unsigned int mantissa1:31;
196    unsigned int mantissa0:32;
197  } fpregs[8];
198  unsigned int fpsr:32;
199  unsigned int fpcr:32;
200  unsigned char ftype[8];
201  unsigned int init_flag;
202};
203struct user_regs {
204  unsigned long uregs[18];
205};
206struct user_vfp {
207  unsigned long long fpregs[32];
208  unsigned long fpscr;
209};
210struct user_vfp_exc {
211  unsigned long fpexc;
212  unsigned long fpinst;
213  unsigned long fpinst2;
214};
215struct user {
216  struct user_regs regs;
217  int u_fpvalid;
218  unsigned long int u_tsize;
219  unsigned long int u_dsize;
220  unsigned long int u_ssize;
221  unsigned long start_code;
222  unsigned long start_stack;
223  long int signal;
224  int reserved;
225  struct user_regs* u_ar0;
226  unsigned long magic;
227  char u_comm[32];
228  int u_debugreg[8];
229  struct user_fpregs u_fp;
230  struct user_fpregs* u_fp0;
231};
232
233#elif defined(__aarch64__)
234
235struct user_regs_struct {
236  uint64_t regs[31];
237  uint64_t sp;
238  uint64_t pc;
239  uint64_t pstate;
240};
241struct user_fpsimd_struct {
242  __uint128_t vregs[32];
243  uint32_t fpsr;
244  uint32_t fpcr;
245};
246
247#else
248
249#error "Unsupported architecture."
250
251#endif
252
253__END_DECLS
254
255#endif  /* _SYS_USER_H_ */
256