blob: 12af664d55f0989b4b128a8092c360b8e92a08af [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. */
David 'Digit' Turneraad1a392014-11-18 12:21:55 +010034#include <stddef.h> /* For size_t. */
Elliott Hughese888de82013-11-19 15:32:31 -080035
36__BEGIN_DECLS
37
Elliott Hughesafab3ff2015-07-28 14:58:37 -070038#define PAGE_SIZE 4096
39#define PAGE_MASK (~(PAGE_SIZE - 1))
40
Elliott Hughese888de82013-11-19 15:32:31 -080041#if __i386__
42
Elliott Hughes93e19072014-04-09 16:35:36 -070043struct user_fpregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -080044 long cwd;
45 long swd;
46 long twd;
47 long fip;
48 long fcs;
49 long foo;
50 long fos;
51 long st_space[20];
52};
Elliott Hughesfef58352015-06-24 17:31:24 -070053struct user_fpxregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -080054 unsigned short cwd;
55 unsigned short swd;
56 unsigned short twd;
57 unsigned short fop;
58 long fip;
59 long fcs;
60 long foo;
61 long fos;
62 long mxcsr;
63 long reserved;
64 long st_space[32];
65 long xmm_space[32];
66 long padding[56];
67};
68struct user_regs_struct {
Elliott Hughesf8b2b3c2014-01-09 14:01:18 -080069 long ebx;
70 long ecx;
71 long edx;
72 long esi;
73 long edi;
74 long ebp;
75 long eax;
76 long xds;
77 long xes;
78 long xfs;
79 long xgs;
80 long orig_eax;
81 long eip;
82 long xcs;
83 long eflags;
84 long esp;
85 long xss;
Elliott Hughese888de82013-11-19 15:32:31 -080086};
Elliott Hughesab797cb2013-11-26 17:57:31 -080087struct user {
Elliott Hughese888de82013-11-19 15:32:31 -080088 struct user_regs_struct regs;
89 int u_fpvalid;
Elliott Hughes93e19072014-04-09 16:35:36 -070090 struct user_fpregs_struct i387;
Elliott Hughese888de82013-11-19 15:32:31 -080091 unsigned long int u_tsize;
92 unsigned long int u_dsize;
93 unsigned long int u_ssize;
94 unsigned long start_code;
95 unsigned long start_stack;
96 long int signal;
97 int reserved;
Elliott Hughese03950f2014-10-24 20:57:09 -070098 struct user_regs_struct* u_ar0;
Elliott Hughes93e19072014-04-09 16:35:36 -070099 struct user_fpregs_struct* u_fpstate;
Elliott Hughese888de82013-11-19 15:32:31 -0800100 unsigned long magic;
101 char u_comm[32];
102 int u_debugreg[8];
103};
104
105#elif defined(__x86_64__)
106
Elliott Hughes93e19072014-04-09 16:35:36 -0700107struct user_fpregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -0800108 unsigned short cwd;
109 unsigned short swd;
Ross McIlroy0c8a5f82014-05-14 13:29:19 +0100110 unsigned short ftw;
Elliott Hughese888de82013-11-19 15:32:31 -0800111 unsigned short fop;
112 __u64 rip;
113 __u64 rdp;
114 __u32 mxcsr;
Elliott Hughesf4855472014-10-23 20:29:42 -0700115 __u32 mxcr_mask;
Elliott Hughese888de82013-11-19 15:32:31 -0800116 __u32 st_space[32];
117 __u32 xmm_space[64];
118 __u32 padding[24];
119};
120struct user_regs_struct {
121 unsigned long r15;
122 unsigned long r14;
123 unsigned long r13;
124 unsigned long r12;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800125 unsigned long rbp;
126 unsigned long rbx;
Elliott Hughese888de82013-11-19 15:32:31 -0800127 unsigned long r11;
128 unsigned long r10;
129 unsigned long r9;
130 unsigned long r8;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800131 unsigned long rax;
132 unsigned long rcx;
133 unsigned long rdx;
134 unsigned long rsi;
135 unsigned long rdi;
136 unsigned long orig_rax;
137 unsigned long rip;
Elliott Hughese888de82013-11-19 15:32:31 -0800138 unsigned long cs;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800139 unsigned long eflags;
140 unsigned long rsp;
Elliott Hughese888de82013-11-19 15:32:31 -0800141 unsigned long ss;
142 unsigned long fs_base;
143 unsigned long gs_base;
144 unsigned long ds;
145 unsigned long es;
146 unsigned long fs;
147 unsigned long gs;
148};
149struct user {
150 struct user_regs_struct regs;
151 int u_fpvalid;
152 int pad0;
Elliott Hughes93e19072014-04-09 16:35:36 -0700153 struct user_fpregs_struct i387;
Elliott Hughese888de82013-11-19 15:32:31 -0800154 unsigned long int u_tsize;
155 unsigned long int u_dsize;
156 unsigned long int u_ssize;
157 unsigned long start_code;
158 unsigned long start_stack;
159 long int signal;
160 int reserved;
161 int pad1;
Elliott Hughese03950f2014-10-24 20:57:09 -0700162 struct user_regs_struct* u_ar0;
Elliott Hughes93e19072014-04-09 16:35:36 -0700163 struct user_fpregs_struct* u_fpstate;
Elliott Hughese888de82013-11-19 15:32:31 -0800164 unsigned long magic;
165 char u_comm[32];
166 unsigned long u_debugreg[8];
167 unsigned long error_code;
168 unsigned long fault_address;
169};
170
171#elif defined(__mips__)
172
173struct 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;
Elliott Hughese03950f2014-10-24 20:57:09 -0700182 void* u_ar0;
Elliott Hughese888de82013-11-19 15:32:31 -0800183 unsigned long magic;
184 char u_comm[32];
185};
186
Christopher Ferris363390e2013-11-22 18:00:09 -0800187#elif defined(__arm__)
188
Elliott Hughes36144242014-01-30 10:39:02 -0800189struct user_fpregs {
Christopher Ferris363390e2013-11-22 18:00:09 -0800190 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};
Elliott Hughes36144242014-01-30 10:39:02 -0800204struct user_regs {
205 unsigned long uregs[18];
206};
Elliott Hughesab797cb2013-11-26 17:57:31 -0800207struct user_vfp {
208 unsigned long long fpregs[32];
209 unsigned long fpscr;
210};
211struct user_vfp_exc {
212 unsigned long fpexc;
213 unsigned long fpinst;
214 unsigned long fpinst2;
215};
216struct user {
Elliott Hughes36144242014-01-30 10:39:02 -0800217 struct user_regs regs;
Christopher Ferris363390e2013-11-22 18:00:09 -0800218 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;
Elliott Hughes36144242014-01-30 10:39:02 -0800226 struct user_regs* u_ar0;
Christopher Ferris363390e2013-11-22 18:00:09 -0800227 unsigned long magic;
228 char u_comm[32];
229 int u_debugreg[8];
Elliott Hughes36144242014-01-30 10:39:02 -0800230 struct user_fpregs u_fp;
231 struct user_fpregs* u_fp0;
Christopher Ferris363390e2013-11-22 18:00:09 -0800232};
233
234#elif defined(__aarch64__)
235
236// There are no user structures for 64 bit arm.
237
Elliott Hughese888de82013-11-19 15:32:31 -0800238#else
239
Christopher Ferris363390e2013-11-22 18:00:09 -0800240#error "Unsupported architecture."
Elliott Hughese888de82013-11-19 15:32:31 -0800241
242#endif
243
244__END_DECLS
245
246#endif /* _SYS_USER_H_ */