blob: 3312981d30bf0c39d4d72623a6ed37d8f3958ea9 [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>
David 'Digit' Turneraad1a392014-11-18 12:21:55 +010033#include <stddef.h> /* For size_t. */
Elliott Hughese888de82013-11-19 15:32:31 -080034
35__BEGIN_DECLS
36
Elliott Hughesafab3ff2015-07-28 14:58:37 -070037#define PAGE_SIZE 4096
38#define PAGE_MASK (~(PAGE_SIZE - 1))
39
Elliott Hughese888de82013-11-19 15:32:31 -080040#if __i386__
41
Elliott Hughes93e19072014-04-09 16:35:36 -070042struct user_fpregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -080043 long cwd;
44 long swd;
45 long twd;
46 long fip;
47 long fcs;
48 long foo;
49 long fos;
50 long st_space[20];
51};
Elliott Hughesfef58352015-06-24 17:31:24 -070052struct user_fpxregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -080053 unsigned short cwd;
54 unsigned short swd;
55 unsigned short twd;
56 unsigned short fop;
57 long fip;
58 long fcs;
59 long foo;
60 long fos;
61 long mxcsr;
62 long reserved;
63 long st_space[32];
64 long xmm_space[32];
65 long padding[56];
66};
67struct user_regs_struct {
Elliott Hughesf8b2b3c2014-01-09 14:01:18 -080068 long ebx;
69 long ecx;
70 long edx;
71 long esi;
72 long edi;
73 long ebp;
74 long eax;
75 long xds;
76 long xes;
77 long xfs;
78 long xgs;
79 long orig_eax;
80 long eip;
81 long xcs;
82 long eflags;
83 long esp;
84 long xss;
Elliott Hughese888de82013-11-19 15:32:31 -080085};
Elliott Hughesab797cb2013-11-26 17:57:31 -080086struct user {
Elliott Hughese888de82013-11-19 15:32:31 -080087 struct user_regs_struct regs;
88 int u_fpvalid;
Elliott Hughes93e19072014-04-09 16:35:36 -070089 struct user_fpregs_struct i387;
Elliott Hughese888de82013-11-19 15:32:31 -080090 unsigned long int u_tsize;
91 unsigned long int u_dsize;
92 unsigned long int u_ssize;
93 unsigned long start_code;
94 unsigned long start_stack;
95 long int signal;
96 int reserved;
Elliott Hughese03950f2014-10-24 20:57:09 -070097 struct user_regs_struct* u_ar0;
Elliott Hughes93e19072014-04-09 16:35:36 -070098 struct user_fpregs_struct* u_fpstate;
Elliott Hughese888de82013-11-19 15:32:31 -080099 unsigned long magic;
100 char u_comm[32];
101 int u_debugreg[8];
102};
103
104#elif defined(__x86_64__)
105
Elliott Hughes93e19072014-04-09 16:35:36 -0700106struct user_fpregs_struct {
Elliott Hughese888de82013-11-19 15:32:31 -0800107 unsigned short cwd;
108 unsigned short swd;
Ross McIlroy0c8a5f82014-05-14 13:29:19 +0100109 unsigned short ftw;
Elliott Hughese888de82013-11-19 15:32:31 -0800110 unsigned short fop;
111 __u64 rip;
112 __u64 rdp;
113 __u32 mxcsr;
Elliott Hughesf4855472014-10-23 20:29:42 -0700114 __u32 mxcr_mask;
Elliott Hughese888de82013-11-19 15:32:31 -0800115 __u32 st_space[32];
116 __u32 xmm_space[64];
117 __u32 padding[24];
118};
119struct user_regs_struct {
120 unsigned long r15;
121 unsigned long r14;
122 unsigned long r13;
123 unsigned long r12;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800124 unsigned long rbp;
125 unsigned long rbx;
Elliott Hughese888de82013-11-19 15:32:31 -0800126 unsigned long r11;
127 unsigned long r10;
128 unsigned long r9;
129 unsigned long r8;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800130 unsigned long rax;
131 unsigned long rcx;
132 unsigned long rdx;
133 unsigned long rsi;
134 unsigned long rdi;
135 unsigned long orig_rax;
136 unsigned long rip;
Elliott Hughese888de82013-11-19 15:32:31 -0800137 unsigned long cs;
Elliott Hugheseddc8ec2014-01-08 15:54:19 -0800138 unsigned long eflags;
139 unsigned long rsp;
Elliott Hughese888de82013-11-19 15:32:31 -0800140 unsigned long ss;
141 unsigned long fs_base;
142 unsigned long gs_base;
143 unsigned long ds;
144 unsigned long es;
145 unsigned long fs;
146 unsigned long gs;
147};
148struct user {
149 struct user_regs_struct regs;
150 int u_fpvalid;
151 int pad0;
Elliott Hughes93e19072014-04-09 16:35:36 -0700152 struct user_fpregs_struct i387;
Elliott Hughese888de82013-11-19 15:32:31 -0800153 unsigned long int u_tsize;
154 unsigned long int u_dsize;
155 unsigned long int u_ssize;
156 unsigned long start_code;
157 unsigned long start_stack;
158 long int signal;
159 int reserved;
160 int pad1;
Elliott Hughese03950f2014-10-24 20:57:09 -0700161 struct user_regs_struct* u_ar0;
Elliott Hughes93e19072014-04-09 16:35:36 -0700162 struct user_fpregs_struct* u_fpstate;
Elliott Hughese888de82013-11-19 15:32:31 -0800163 unsigned long magic;
164 char u_comm[32];
165 unsigned long u_debugreg[8];
166 unsigned long error_code;
167 unsigned long fault_address;
168};
169
170#elif defined(__mips__)
171
172struct user {
173 unsigned long regs[180 / sizeof(unsigned long) + 64];
174 size_t u_tsize;
175 size_t u_dsize;
176 size_t u_ssize;
177 unsigned long start_code;
178 unsigned long start_data;
179 unsigned long start_stack;
180 long int signal;
Elliott Hughese03950f2014-10-24 20:57:09 -0700181 void* u_ar0;
Elliott Hughese888de82013-11-19 15:32:31 -0800182 unsigned long magic;
183 char u_comm[32];
184};
185
Christopher Ferris363390e2013-11-22 18:00:09 -0800186#elif defined(__arm__)
187
Elliott Hughes36144242014-01-30 10:39:02 -0800188struct user_fpregs {
Christopher Ferris363390e2013-11-22 18:00:09 -0800189 struct fp_reg {
190 unsigned int sign1:1;
191 unsigned int unused:15;
192 unsigned int sign2:1;
193 unsigned int exponent:14;
194 unsigned int j:1;
195 unsigned int mantissa1:31;
196 unsigned int mantissa0:32;
197 } fpregs[8];
198 unsigned int fpsr:32;
199 unsigned int fpcr:32;
200 unsigned char ftype[8];
201 unsigned int init_flag;
202};
Elliott Hughes36144242014-01-30 10:39:02 -0800203struct user_regs {
204 unsigned long uregs[18];
205};
Elliott Hughesab797cb2013-11-26 17:57:31 -0800206struct user_vfp {
207 unsigned long long fpregs[32];
208 unsigned long fpscr;
209};
210struct user_vfp_exc {
211 unsigned long fpexc;
212 unsigned long fpinst;
213 unsigned long fpinst2;
214};
215struct user {
Elliott Hughes36144242014-01-30 10:39:02 -0800216 struct user_regs regs;
Christopher Ferris363390e2013-11-22 18:00:09 -0800217 int u_fpvalid;
218 unsigned long int u_tsize;
219 unsigned long int u_dsize;
220 unsigned long int u_ssize;
221 unsigned long start_code;
222 unsigned long start_stack;
223 long int signal;
224 int reserved;
Elliott Hughes36144242014-01-30 10:39:02 -0800225 struct user_regs* u_ar0;
Christopher Ferris363390e2013-11-22 18:00:09 -0800226 unsigned long magic;
227 char u_comm[32];
228 int u_debugreg[8];
Elliott Hughes36144242014-01-30 10:39:02 -0800229 struct user_fpregs u_fp;
230 struct user_fpregs* u_fp0;
Christopher Ferris363390e2013-11-22 18:00:09 -0800231};
232
233#elif defined(__aarch64__)
234
Elliott Hughes03f22462015-08-25 14:18:26 -0700235struct user_regs_struct {
236 uint64_t regs[31];
237 uint64_t sp;
238 uint64_t pc;
239 uint64_t pstate;
240};
241struct user_fpsimd_struct {
242 __uint128_t vregs[32];
243 uint32_t fpsr;
244 uint32_t fpcr;
245};
Christopher Ferris363390e2013-11-22 18:00:09 -0800246
Elliott Hughese888de82013-11-19 15:32:31 -0800247#else
248
Christopher Ferris363390e2013-11-22 18:00:09 -0800249#error "Unsupported architecture."
Elliott Hughese888de82013-11-19 15:32:31 -0800250
251#endif
252
253__END_DECLS
254
255#endif /* _SYS_USER_H_ */