user.h revision e03950fa0c5567edf70d011b856a027e03b1c0f7
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 <limits.h> /* For PAGE_SIZE. */
34
35__BEGIN_DECLS
36
37#if __i386__
38
39struct user_fpregs_struct {
40  long cwd;
41  long swd;
42  long twd;
43  long fip;
44  long fcs;
45  long foo;
46  long fos;
47  long st_space[20];
48};
49struct user_fxsr_struct {
50  unsigned short cwd;
51  unsigned short swd;
52  unsigned short twd;
53  unsigned short fop;
54  long fip;
55  long fcs;
56  long foo;
57  long fos;
58  long mxcsr;
59  long reserved;
60  long st_space[32];
61  long xmm_space[32];
62  long padding[56];
63};
64struct user_regs_struct {
65  long ebx;
66  long ecx;
67  long edx;
68  long esi;
69  long edi;
70  long ebp;
71  long eax;
72  long xds;
73  long xes;
74  long xfs;
75  long xgs;
76  long orig_eax;
77  long eip;
78  long xcs;
79  long eflags;
80  long esp;
81  long xss;
82};
83struct user {
84  struct user_regs_struct regs;
85  int u_fpvalid;
86  struct user_fpregs_struct i387;
87  unsigned long int u_tsize;
88  unsigned long int u_dsize;
89  unsigned long int u_ssize;
90  unsigned long start_code;
91  unsigned long start_stack;
92  long int signal;
93  int reserved;
94  struct user_regs_struct* u_ar0;
95  struct user_fpregs_struct* u_fpstate;
96  unsigned long magic;
97  char u_comm[32];
98  int u_debugreg[8];
99};
100
101#elif defined(__x86_64__)
102
103struct user_fpregs_struct {
104  unsigned short cwd;
105  unsigned short swd;
106  unsigned short ftw;
107  unsigned short fop;
108  __u64 rip;
109  __u64 rdp;
110  __u32 mxcsr;
111  __u32 mxcr_mask;
112  __u32 st_space[32];
113  __u32 xmm_space[64];
114  __u32 padding[24];
115};
116struct user_regs_struct {
117  unsigned long r15;
118  unsigned long r14;
119  unsigned long r13;
120  unsigned long r12;
121  unsigned long rbp;
122  unsigned long rbx;
123  unsigned long r11;
124  unsigned long r10;
125  unsigned long r9;
126  unsigned long r8;
127  unsigned long rax;
128  unsigned long rcx;
129  unsigned long rdx;
130  unsigned long rsi;
131  unsigned long rdi;
132  unsigned long orig_rax;
133  unsigned long rip;
134  unsigned long cs;
135  unsigned long eflags;
136  unsigned long rsp;
137  unsigned long ss;
138  unsigned long fs_base;
139  unsigned long gs_base;
140  unsigned long ds;
141  unsigned long es;
142  unsigned long fs;
143  unsigned long gs;
144};
145struct user {
146  struct user_regs_struct regs;
147  int u_fpvalid;
148  int pad0;
149  struct user_fpregs_struct i387;
150  unsigned long int u_tsize;
151  unsigned long int u_dsize;
152  unsigned long int u_ssize;
153  unsigned long start_code;
154  unsigned long start_stack;
155  long int signal;
156  int reserved;
157  int pad1;
158  struct user_regs_struct* u_ar0;
159  struct user_fpregs_struct* u_fpstate;
160  unsigned long magic;
161  char u_comm[32];
162  unsigned long u_debugreg[8];
163  unsigned long error_code;
164  unsigned long fault_address;
165};
166
167#elif defined(__mips__)
168
169struct user {
170  unsigned long regs[180 / sizeof(unsigned long) + 64];
171  size_t u_tsize;
172  size_t u_dsize;
173  size_t u_ssize;
174  unsigned long start_code;
175  unsigned long start_data;
176  unsigned long start_stack;
177  long int signal;
178  void* u_ar0;
179  unsigned long magic;
180  char u_comm[32];
181};
182
183#elif defined(__arm__)
184
185struct user_fpregs {
186  struct fp_reg {
187    unsigned int sign1:1;
188    unsigned int unused:15;
189    unsigned int sign2:1;
190    unsigned int exponent:14;
191    unsigned int j:1;
192    unsigned int mantissa1:31;
193    unsigned int mantissa0:32;
194  } fpregs[8];
195  unsigned int fpsr:32;
196  unsigned int fpcr:32;
197  unsigned char ftype[8];
198  unsigned int init_flag;
199};
200struct user_regs {
201  unsigned long uregs[18];
202};
203struct user_vfp {
204  unsigned long long fpregs[32];
205  unsigned long fpscr;
206};
207struct user_vfp_exc {
208  unsigned long fpexc;
209  unsigned long fpinst;
210  unsigned long fpinst2;
211};
212struct user {
213  struct user_regs regs;
214  int u_fpvalid;
215  unsigned long int u_tsize;
216  unsigned long int u_dsize;
217  unsigned long int u_ssize;
218  unsigned long start_code;
219  unsigned long start_stack;
220  long int signal;
221  int reserved;
222  struct user_regs* u_ar0;
223  unsigned long magic;
224  char u_comm[32];
225  int u_debugreg[8];
226  struct user_fpregs u_fp;
227  struct user_fpregs* u_fp0;
228};
229
230#elif defined(__aarch64__)
231
232// There are no user structures for 64 bit arm.
233
234#else
235
236#error "Unsupported architecture."
237
238#endif
239
240__END_DECLS
241
242#endif  /* _SYS_USER_H_ */
243