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 <stddef.h> /* For size_t. */ 34 #include <stdint.h> 35 36 __BEGIN_DECLS 37 38 #define PAGE_SIZE 4096 39 #define PAGE_MASK (~(PAGE_SIZE - 1)) 40 41 #if defined(__i386__) 42 43 struct user_fpregs_struct { 44 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 }; 53 struct user_fpxregs_struct { 54 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 }; 68 struct user_regs_struct { 69 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; 86 }; 87 struct user { 88 struct user_regs_struct regs; 89 int u_fpvalid; 90 struct user_fpregs_struct i387; 91 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; 98 struct user_regs_struct* u_ar0; 99 struct user_fpregs_struct* u_fpstate; 100 unsigned long magic; 101 char u_comm[32]; 102 int u_debugreg[8]; 103 }; 104 105 #elif defined(__x86_64__) 106 107 struct user_fpregs_struct { 108 unsigned short cwd; 109 unsigned short swd; 110 unsigned short ftw; 111 unsigned short fop; 112 unsigned long rip; 113 unsigned long rdp; 114 unsigned int mxcsr; 115 unsigned int mxcr_mask; 116 unsigned int st_space[32]; 117 unsigned int xmm_space[64]; 118 unsigned int padding[24]; 119 }; 120 struct user_regs_struct { 121 unsigned long r15; 122 unsigned long r14; 123 unsigned long r13; 124 unsigned long r12; 125 unsigned long rbp; 126 unsigned long rbx; 127 unsigned long r11; 128 unsigned long r10; 129 unsigned long r9; 130 unsigned long r8; 131 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; 138 unsigned long cs; 139 unsigned long eflags; 140 unsigned long rsp; 141 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 }; 149 struct user { 150 struct user_regs_struct regs; 151 int u_fpvalid; 152 int pad0; 153 struct user_fpregs_struct i387; 154 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; 162 struct user_regs_struct* u_ar0; 163 struct user_fpregs_struct* u_fpstate; 164 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 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 void* 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 struct user_regs_struct { 237 uint64_t regs[31]; 238 uint64_t sp; 239 uint64_t pc; 240 uint64_t pstate; 241 }; 242 struct user_fpsimd_struct { 243 __uint128_t vregs[32]; 244 uint32_t fpsr; 245 uint32_t fpcr; 246 }; 247 248 #else 249 250 #error "Unsupported architecture." 251 252 #endif 253 254 __END_DECLS 255 256 #endif /* _SYS_USER_H_ */ 257