• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
39 struct 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 };
49 struct 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 };
64 struct 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 };
83 struct 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   unsigned long 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 
103 struct 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 mxcsr_mask;
112   __u32 st_space[32];
113   __u32 xmm_space[64];
114   __u32 padding[24];
115 };
116 struct 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 };
145 struct 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   unsigned long 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 struct user_regs_struct
169 {
170   unsigned long regs[180 / sizeof(unsigned long) + 64];
171 };
172 
173 struct user {
174   unsigned long regs[180 / sizeof(unsigned long) + 64];
175   size_t u_tsize;
176   size_t u_dsize;
177   size_t u_ssize;
178   unsigned long start_code;
179   unsigned long start_data;
180   unsigned long start_stack;
181   long int signal;
182   unsigned long u_ar0;
183   unsigned long magic;
184   char u_comm[32];
185 };
186 
187 #elif defined(__arm__)
188 
189 struct user_fpregs {
190   struct fp_reg {
191     unsigned int sign1:1;
192     unsigned int unused:15;
193     unsigned int sign2:1;
194     unsigned int exponent:14;
195     unsigned int j:1;
196     unsigned int mantissa1:31;
197     unsigned int mantissa0:32;
198   } fpregs[8];
199   unsigned int fpsr:32;
200   unsigned int fpcr:32;
201   unsigned char ftype[8];
202   unsigned int init_flag;
203 };
204 struct user_regs {
205   unsigned long uregs[18];
206 };
207 struct user_vfp {
208   unsigned long long fpregs[32];
209   unsigned long fpscr;
210 };
211 struct user_vfp_exc {
212   unsigned long fpexc;
213   unsigned long fpinst;
214   unsigned long fpinst2;
215 };
216 struct user {
217   struct user_regs regs;
218   int u_fpvalid;
219   unsigned long int u_tsize;
220   unsigned long int u_dsize;
221   unsigned long int u_ssize;
222   unsigned long start_code;
223   unsigned long start_stack;
224   long int signal;
225   int reserved;
226   struct user_regs* u_ar0;
227   unsigned long magic;
228   char u_comm[32];
229   int u_debugreg[8];
230   struct user_fpregs u_fp;
231   struct user_fpregs* u_fp0;
232 };
233 
234 #elif defined(__aarch64__)
235 
236 // There are no user structures for 64 bit arm.
237 
238 #else
239 
240 #error "Unsupported architecture."
241 
242 #endif
243 
244 __END_DECLS
245 
246 #endif  /* _SYS_USER_H_ */
247