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 <limits.h> /* For PAGE_SIZE. */ 34#include <stddef.h> /* For size_t. */ 35 36__BEGIN_DECLS 37 38#if __i386__ 39 40struct user_fpregs_struct { 41 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}; 50struct user_fxsr_struct { 51 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 { 66 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; 83}; 84struct user { 85 struct user_regs_struct regs; 86 int u_fpvalid; 87 struct user_fpregs_struct i387; 88 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; 95 struct user_regs_struct* u_ar0; 96 struct user_fpregs_struct* u_fpstate; 97 unsigned long magic; 98 char u_comm[32]; 99 int u_debugreg[8]; 100}; 101 102#elif defined(__x86_64__) 103 104struct user_fpregs_struct { 105 unsigned short cwd; 106 unsigned short swd; 107 unsigned short ftw; 108 unsigned short fop; 109 __u64 rip; 110 __u64 rdp; 111 __u32 mxcsr; 112 __u32 mxcr_mask; 113 __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; 122 unsigned long rbp; 123 unsigned long rbx; 124 unsigned long r11; 125 unsigned long r10; 126 unsigned long r9; 127 unsigned long r8; 128 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; 135 unsigned long cs; 136 unsigned long eflags; 137 unsigned long rsp; 138 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; 150 struct user_fpregs_struct i387; 151 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; 159 struct user_regs_struct* u_ar0; 160 struct user_fpregs_struct* u_fpstate; 161 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; 179 void* u_ar0; 180 unsigned long magic; 181 char u_comm[32]; 182}; 183 184#elif defined(__arm__) 185 186struct user_fpregs { 187 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}; 201struct user_regs { 202 unsigned long uregs[18]; 203}; 204struct 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 { 214 struct user_regs regs; 215 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; 223 struct user_regs* u_ar0; 224 unsigned long magic; 225 char u_comm[32]; 226 int u_debugreg[8]; 227 struct user_fpregs u_fp; 228 struct user_fpregs* u_fp0; 229}; 230 231#elif defined(__aarch64__) 232 233// There are no user structures for 64 bit arm. 234 235#else 236 237#error "Unsupported architecture." 238 239#endif 240 241__END_DECLS 242 243#endif /* _SYS_USER_H_ */ 244