blob: d63fe6aa567a969e6d89b13ea7018eb21d5273bb [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
38#if __i386__
39
Elliott Hughes93e19072014-04-09 16:35:36 -070040struct user_fpregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -080041 long cwd;
42 long swd;
43 long twd;
44 long fip;
45 long fcs;
46 long foo;
47 long fos;
48 long st_space[20];
49};
Elliott Hughesfef58352015-06-24 17:31:24 -070050struct user_fpxregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -080051 unsigned short cwd;
52 unsigned short swd;
53 unsigned short twd;
54 unsigned short fop;
55 long fip;
56 long fcs;
57 long foo;
58 long fos;
59 long mxcsr;
60 long reserved;
61 long st_space[32];
62 long xmm_space[32];
63 long padding[56];
64};
65struct user_regs_struct {
Elliott Hughesf8b2b3c2014-01-09 14:01:18 -080066 long ebx;
67 long ecx;
68 long edx;
69 long esi;
70 long edi;
71 long ebp;
72 long eax;
73 long xds;
74 long xes;
75 long xfs;
76 long xgs;
77 long orig_eax;
78 long eip;
79 long xcs;
80 long eflags;
81 long esp;
82 long xss;
Elliott Hughese888de82013-11-19 15:32:31 -080083};
Elliott Hughesab797cb2013-11-26 17:57:31 -080084struct user {
Elliott Hughese888de82013-11-19 15:32:31 -080085 struct user_regs_struct regs;
86 int u_fpvalid;
Elliott Hughes93e19072014-04-09 16:35:36 -070087 struct user_fpregs_struct i387;
Elliott Hughese888de82013-11-19 15:32:31 -080088 unsigned long int u_tsize;
89 unsigned long int u_dsize;
90 unsigned long int u_ssize;
91 unsigned long start_code;
92 unsigned long start_stack;
93 long int signal;
94 int reserved;
Elliott Hughese03950f2014-10-24 20:57:09 -070095 struct user_regs_struct* u_ar0;
Elliott Hughes93e19072014-04-09 16:35:36 -070096 struct user_fpregs_struct* u_fpstate;
Elliott Hughese888de82013-11-19 15:32:31 -080097 unsigned long magic;
98 char u_comm[32];
99 int u_debugreg[8];
100};
101
102#elif defined(__x86_64__)
103
Elliott Hughes93e19072014-04-09 16:35:36 -0700104struct user_fpregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -0800105 unsigned short cwd;
106 unsigned short swd;
Ross McIlroy0c8a5f82014-05-14 13:29:19 +0100107 unsigned short ftw;
Elliott Hughese888de82013-11-19 15:32:31 -0800108 unsigned short fop;
109 __u64 rip;
110 __u64 rdp;
111 __u32 mxcsr;
Elliott Hughesf4855472014-10-23 20:29:42 -0700112 __u32 mxcr_mask;
Elliott Hughese888de82013-11-19 15:32:31 -0800113 __u32 st_space[32];
114 __u32 xmm_space[64];
115 __u32 padding[24];
116};
117struct user_regs_struct {
118 unsigned long r15;
119 unsigned long r14;
120 unsigned long r13;
121 unsigned long r12;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800122 unsigned long rbp;
123 unsigned long rbx;
Elliott Hughese888de82013-11-19 15:32:31 -0800124 unsigned long r11;
125 unsigned long r10;
126 unsigned long r9;
127 unsigned long r8;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800128 unsigned long rax;
129 unsigned long rcx;
130 unsigned long rdx;
131 unsigned long rsi;
132 unsigned long rdi;
133 unsigned long orig_rax;
134 unsigned long rip;
Elliott Hughese888de82013-11-19 15:32:31 -0800135 unsigned long cs;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800136 unsigned long eflags;
137 unsigned long rsp;
Elliott Hughese888de82013-11-19 15:32:31 -0800138 unsigned long ss;
139 unsigned long fs_base;
140 unsigned long gs_base;
141 unsigned long ds;
142 unsigned long es;
143 unsigned long fs;
144 unsigned long gs;
145};
146struct user {
147 struct user_regs_struct regs;
148 int u_fpvalid;
149 int pad0;
Elliott Hughes93e19072014-04-09 16:35:36 -0700150 struct user_fpregs_struct i387;
Elliott Hughese888de82013-11-19 15:32:31 -0800151 unsigned long int u_tsize;
152 unsigned long int u_dsize;
153 unsigned long int u_ssize;
154 unsigned long start_code;
155 unsigned long start_stack;
156 long int signal;
157 int reserved;
158 int pad1;
Elliott Hughese03950f2014-10-24 20:57:09 -0700159 struct user_regs_struct* u_ar0;
Elliott Hughes93e19072014-04-09 16:35:36 -0700160 struct user_fpregs_struct* u_fpstate;
Elliott Hughese888de82013-11-19 15:32:31 -0800161 unsigned long magic;
162 char u_comm[32];
163 unsigned long u_debugreg[8];
164 unsigned long error_code;
165 unsigned long fault_address;
166};
167
168#elif defined(__mips__)
169
170struct user {
171 unsigned long regs[180 / sizeof(unsigned long) + 64];
172 size_t u_tsize;
173 size_t u_dsize;
174 size_t u_ssize;
175 unsigned long start_code;
176 unsigned long start_data;
177 unsigned long start_stack;
178 long int signal;
Elliott Hughese03950f2014-10-24 20:57:09 -0700179 void* u_ar0;
Elliott Hughese888de82013-11-19 15:32:31 -0800180 unsigned long magic;
181 char u_comm[32];
182};
183
Christopher Ferris363390e2013-11-22 18:00:09 -0800184#elif defined(__arm__)
185
Elliott Hughes36144242014-01-30 10:39:02 -0800186struct user_fpregs {
Christopher Ferris363390e2013-11-22 18:00:09 -0800187 struct fp_reg {
188 unsigned int sign1:1;
189 unsigned int unused:15;
190 unsigned int sign2:1;
191 unsigned int exponent:14;
192 unsigned int j:1;
193 unsigned int mantissa1:31;
194 unsigned int mantissa0:32;
195 } fpregs[8];
196 unsigned int fpsr:32;
197 unsigned int fpcr:32;
198 unsigned char ftype[8];
199 unsigned int init_flag;
200};
Elliott Hughes36144242014-01-30 10:39:02 -0800201struct user_regs {
202 unsigned long uregs[18];
203};
Elliott Hughesab797cb2013-11-26 17:57:31 -0800204struct user_vfp {
205 unsigned long long fpregs[32];
206 unsigned long fpscr;
207};
208struct user_vfp_exc {
209 unsigned long fpexc;
210 unsigned long fpinst;
211 unsigned long fpinst2;
212};
213struct user {
Elliott Hughes36144242014-01-30 10:39:02 -0800214 struct user_regs regs;
Christopher Ferris363390e2013-11-22 18:00:09 -0800215 int u_fpvalid;
216 unsigned long int u_tsize;
217 unsigned long int u_dsize;
218 unsigned long int u_ssize;
219 unsigned long start_code;
220 unsigned long start_stack;
221 long int signal;
222 int reserved;
Elliott Hughes36144242014-01-30 10:39:02 -0800223 struct user_regs* u_ar0;
Christopher Ferris363390e2013-11-22 18:00:09 -0800224 unsigned long magic;
225 char u_comm[32];
226 int u_debugreg[8];
Elliott Hughes36144242014-01-30 10:39:02 -0800227 struct user_fpregs u_fp;
228 struct user_fpregs* u_fp0;
Christopher Ferris363390e2013-11-22 18:00:09 -0800229};
230
231#elif defined(__aarch64__)
232
233// There are no user structures for 64 bit arm.
234
Elliott Hughese888de82013-11-19 15:32:31 -0800235#else
236
Christopher Ferris363390e2013-11-22 18:00:09 -0800237#error "Unsupported architecture."
Elliott Hughese888de82013-11-19 15:32:31 -0800238
239#endif
240
241__END_DECLS
242
243#endif /* _SYS_USER_H_ */