blob: 18684f1838e7b9f618ac3452c539436a2965fbbe [file] [log] [blame]
Elliott Hughese888de82013-11-19 15:32:31 -08001/*
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>
Elliott Hughes0e44bc32014-02-24 15:55:31 -080033#include <limits.h> /* For PAGE_SIZE. */
Elliott Hughese888de82013-11-19 15:32:31 -080034
35__BEGIN_DECLS
36
37#if __i386__
38
Elliott Hughes93e19072014-04-09 16:35:36 -070039struct user_fpregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -080040 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 {
Elliott Hughesf8b2b3c2014-01-09 14:01:18 -080065 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;
Elliott Hughese888de82013-11-19 15:32:31 -080082};
Elliott Hughesab797cb2013-11-26 17:57:31 -080083struct user {
Elliott Hughese888de82013-11-19 15:32:31 -080084 struct user_regs_struct regs;
85 int u_fpvalid;
Elliott Hughes93e19072014-04-09 16:35:36 -070086 struct user_fpregs_struct i387;
Elliott Hughese888de82013-11-19 15:32:31 -080087 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;
Elliott Hughes93e19072014-04-09 16:35:36 -070095 struct user_fpregs_struct* u_fpstate;
Elliott Hughese888de82013-11-19 15:32:31 -080096 unsigned long magic;
97 char u_comm[32];
98 int u_debugreg[8];
99};
100
101#elif defined(__x86_64__)
102
Elliott Hughes93e19072014-04-09 16:35:36 -0700103struct user_fpregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -0800104 unsigned short cwd;
105 unsigned short swd;
Ross McIlroy0c8a5f82014-05-14 13:29:19 +0100106 unsigned short ftw;
Elliott Hughese888de82013-11-19 15:32:31 -0800107 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};
116struct user_regs_struct {
117 unsigned long r15;
118 unsigned long r14;
119 unsigned long r13;
120 unsigned long r12;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800121 unsigned long rbp;
122 unsigned long rbx;
Elliott Hughese888de82013-11-19 15:32:31 -0800123 unsigned long r11;
124 unsigned long r10;
125 unsigned long r9;
126 unsigned long r8;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800127 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;
Elliott Hughese888de82013-11-19 15:32:31 -0800134 unsigned long cs;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800135 unsigned long eflags;
136 unsigned long rsp;
Elliott Hughese888de82013-11-19 15:32:31 -0800137 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;
Elliott Hughes93e19072014-04-09 16:35:36 -0700149 struct user_fpregs_struct i387;
Elliott Hughese888de82013-11-19 15:32:31 -0800150 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;
Elliott Hughes93e19072014-04-09 16:35:36 -0700159 struct user_fpregs_struct* u_fpstate;
Elliott Hughese888de82013-11-19 15:32:31 -0800160 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 unsigned long u_ar0;
179 unsigned long magic;
180 char u_comm[32];
181};
182
Christopher Ferris363390e2013-11-22 18:00:09 -0800183#elif defined(__arm__)
184
Elliott Hughes36144242014-01-30 10:39:02 -0800185struct user_fpregs {
Christopher Ferris363390e2013-11-22 18:00:09 -0800186 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};
Elliott Hughes36144242014-01-30 10:39:02 -0800200struct user_regs {
201 unsigned long uregs[18];
202};
Elliott Hughesab797cb2013-11-26 17:57:31 -0800203struct 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 {
Elliott Hughes36144242014-01-30 10:39:02 -0800213 struct user_regs regs;
Christopher Ferris363390e2013-11-22 18:00:09 -0800214 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;
Elliott Hughes36144242014-01-30 10:39:02 -0800222 struct user_regs* u_ar0;
Christopher Ferris363390e2013-11-22 18:00:09 -0800223 unsigned long magic;
224 char u_comm[32];
225 int u_debugreg[8];
Elliott Hughes36144242014-01-30 10:39:02 -0800226 struct user_fpregs u_fp;
227 struct user_fpregs* u_fp0;
Christopher Ferris363390e2013-11-22 18:00:09 -0800228};
229
230#elif defined(__aarch64__)
231
232// There are no user structures for 64 bit arm.
233
Elliott Hughese888de82013-11-19 15:32:31 -0800234#else
235
Christopher Ferris363390e2013-11-22 18:00:09 -0800236#error "Unsupported architecture."
Elliott Hughese888de82013-11-19 15:32:31 -0800237
238#endif
239
240__END_DECLS
241
242#endif /* _SYS_USER_H_ */