| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 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> | 
| Elliott Hughes | 0e44bc3 | 2014-02-24 15:55:31 -0800 | [diff] [blame] | 33 | #include <limits.h> /* For PAGE_SIZE. */ | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 34 |  | 
|  | 35 | __BEGIN_DECLS | 
|  | 36 |  | 
|  | 37 | #if __i386__ | 
|  | 38 |  | 
|  | 39 | struct user_i387_struct { | 
|  | 40 | long cwd; | 
|  | 41 | long swd; | 
|  | 42 | long twd; | 
|  | 43 | long fip; | 
|  | 44 | long fcs; | 
|  | 45 | long foo; | 
|  | 46 | long fos; | 
|  | 47 | long st_space[20]; | 
|  | 48 | }; | 
|  | 49 | struct user_fxsr_struct { | 
|  | 50 | unsigned short cwd; | 
|  | 51 | unsigned short swd; | 
|  | 52 | unsigned short twd; | 
|  | 53 | unsigned short fop; | 
|  | 54 | long fip; | 
|  | 55 | long fcs; | 
|  | 56 | long foo; | 
|  | 57 | long fos; | 
|  | 58 | long mxcsr; | 
|  | 59 | long reserved; | 
|  | 60 | long st_space[32]; | 
|  | 61 | long xmm_space[32]; | 
|  | 62 | long padding[56]; | 
|  | 63 | }; | 
|  | 64 | struct user_regs_struct { | 
| Elliott Hughes | f8b2b3c | 2014-01-09 14:01:18 -0800 | [diff] [blame] | 65 | long ebx; | 
|  | 66 | long ecx; | 
|  | 67 | long edx; | 
|  | 68 | long esi; | 
|  | 69 | long edi; | 
|  | 70 | long ebp; | 
|  | 71 | long eax; | 
|  | 72 | long xds; | 
|  | 73 | long xes; | 
|  | 74 | long xfs; | 
|  | 75 | long xgs; | 
|  | 76 | long orig_eax; | 
|  | 77 | long eip; | 
|  | 78 | long xcs; | 
|  | 79 | long eflags; | 
|  | 80 | long esp; | 
|  | 81 | long xss; | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 82 | }; | 
| Elliott Hughes | ab797cb | 2013-11-26 17:57:31 -0800 | [diff] [blame] | 83 | struct user { | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 84 | struct user_regs_struct regs; | 
|  | 85 | int u_fpvalid; | 
|  | 86 | struct user_i387_struct i387; | 
|  | 87 | unsigned long int u_tsize; | 
|  | 88 | unsigned long int u_dsize; | 
|  | 89 | unsigned long int u_ssize; | 
|  | 90 | unsigned long start_code; | 
|  | 91 | unsigned long start_stack; | 
|  | 92 | long int signal; | 
|  | 93 | int reserved; | 
|  | 94 | unsigned long u_ar0; | 
| Elliott Hughes | ab797cb | 2013-11-26 17:57:31 -0800 | [diff] [blame] | 95 | struct user_i387_struct* u_fpstate; | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 96 | unsigned long magic; | 
|  | 97 | char u_comm[32]; | 
|  | 98 | int u_debugreg[8]; | 
|  | 99 | }; | 
|  | 100 |  | 
|  | 101 | #elif defined(__x86_64__) | 
|  | 102 |  | 
|  | 103 | struct user_i387_struct { | 
|  | 104 | unsigned short cwd; | 
|  | 105 | unsigned short swd; | 
|  | 106 | unsigned short twd; | 
|  | 107 | unsigned short fop; | 
|  | 108 | __u64 rip; | 
|  | 109 | __u64 rdp; | 
|  | 110 | __u32 mxcsr; | 
|  | 111 | __u32 mxcsr_mask; | 
|  | 112 | __u32 st_space[32]; | 
|  | 113 | __u32 xmm_space[64]; | 
|  | 114 | __u32 padding[24]; | 
|  | 115 | }; | 
|  | 116 | struct user_regs_struct { | 
|  | 117 | unsigned long r15; | 
|  | 118 | unsigned long r14; | 
|  | 119 | unsigned long r13; | 
|  | 120 | unsigned long r12; | 
| Elliott Hughes | eddc8ec | 2014-01-08 15:54:19 -0800 | [diff] [blame] | 121 | unsigned long rbp; | 
|  | 122 | unsigned long rbx; | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 123 | unsigned long r11; | 
|  | 124 | unsigned long r10; | 
|  | 125 | unsigned long r9; | 
|  | 126 | unsigned long r8; | 
| Elliott Hughes | eddc8ec | 2014-01-08 15:54:19 -0800 | [diff] [blame] | 127 | unsigned long rax; | 
|  | 128 | unsigned long rcx; | 
|  | 129 | unsigned long rdx; | 
|  | 130 | unsigned long rsi; | 
|  | 131 | unsigned long rdi; | 
|  | 132 | unsigned long orig_rax; | 
|  | 133 | unsigned long rip; | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 134 | unsigned long cs; | 
| Elliott Hughes | eddc8ec | 2014-01-08 15:54:19 -0800 | [diff] [blame] | 135 | unsigned long eflags; | 
|  | 136 | unsigned long rsp; | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 137 | unsigned long ss; | 
|  | 138 | unsigned long fs_base; | 
|  | 139 | unsigned long gs_base; | 
|  | 140 | unsigned long ds; | 
|  | 141 | unsigned long es; | 
|  | 142 | unsigned long fs; | 
|  | 143 | unsigned long gs; | 
|  | 144 | }; | 
|  | 145 | struct user { | 
|  | 146 | struct user_regs_struct regs; | 
|  | 147 | int u_fpvalid; | 
|  | 148 | int pad0; | 
|  | 149 | struct user_i387_struct i387; | 
|  | 150 | unsigned long int u_tsize; | 
|  | 151 | unsigned long int u_dsize; | 
|  | 152 | unsigned long int u_ssize; | 
|  | 153 | unsigned long start_code; | 
|  | 154 | unsigned long start_stack; | 
|  | 155 | long int signal; | 
|  | 156 | int reserved; | 
|  | 157 | int pad1; | 
|  | 158 | unsigned long u_ar0; | 
| Elliott Hughes | ab797cb | 2013-11-26 17:57:31 -0800 | [diff] [blame] | 159 | struct user_i387_struct* u_fpstate; | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 160 | unsigned long magic; | 
|  | 161 | char u_comm[32]; | 
|  | 162 | unsigned long u_debugreg[8]; | 
|  | 163 | unsigned long error_code; | 
|  | 164 | unsigned long fault_address; | 
|  | 165 | }; | 
|  | 166 |  | 
|  | 167 | #elif defined(__mips__) | 
|  | 168 |  | 
|  | 169 | struct user { | 
|  | 170 | unsigned long regs[180 / sizeof(unsigned long) + 64]; | 
|  | 171 | size_t u_tsize; | 
|  | 172 | size_t u_dsize; | 
|  | 173 | size_t u_ssize; | 
|  | 174 | unsigned long start_code; | 
|  | 175 | unsigned long start_data; | 
|  | 176 | unsigned long start_stack; | 
|  | 177 | long int signal; | 
|  | 178 | unsigned long u_ar0; | 
|  | 179 | unsigned long magic; | 
|  | 180 | char u_comm[32]; | 
|  | 181 | }; | 
|  | 182 |  | 
| Christopher Ferris | 363390e | 2013-11-22 18:00:09 -0800 | [diff] [blame] | 183 | #elif defined(__arm__) | 
|  | 184 |  | 
| Elliott Hughes | 3614424 | 2014-01-30 10:39:02 -0800 | [diff] [blame] | 185 | struct user_fpregs { | 
| Christopher Ferris | 363390e | 2013-11-22 18:00:09 -0800 | [diff] [blame] | 186 | struct fp_reg { | 
|  | 187 | unsigned int sign1:1; | 
|  | 188 | unsigned int unused:15; | 
|  | 189 | unsigned int sign2:1; | 
|  | 190 | unsigned int exponent:14; | 
|  | 191 | unsigned int j:1; | 
|  | 192 | unsigned int mantissa1:31; | 
|  | 193 | unsigned int mantissa0:32; | 
|  | 194 | } fpregs[8]; | 
|  | 195 | unsigned int fpsr:32; | 
|  | 196 | unsigned int fpcr:32; | 
|  | 197 | unsigned char ftype[8]; | 
|  | 198 | unsigned int init_flag; | 
|  | 199 | }; | 
| Elliott Hughes | 3614424 | 2014-01-30 10:39:02 -0800 | [diff] [blame] | 200 | struct user_regs { | 
|  | 201 | unsigned long uregs[18]; | 
|  | 202 | }; | 
| Elliott Hughes | ab797cb | 2013-11-26 17:57:31 -0800 | [diff] [blame] | 203 | struct user_vfp { | 
|  | 204 | unsigned long long fpregs[32]; | 
|  | 205 | unsigned long fpscr; | 
|  | 206 | }; | 
|  | 207 | struct user_vfp_exc { | 
|  | 208 | unsigned long fpexc; | 
|  | 209 | unsigned long fpinst; | 
|  | 210 | unsigned long fpinst2; | 
|  | 211 | }; | 
|  | 212 | struct user { | 
| Elliott Hughes | 3614424 | 2014-01-30 10:39:02 -0800 | [diff] [blame] | 213 | struct user_regs regs; | 
| Christopher Ferris | 363390e | 2013-11-22 18:00:09 -0800 | [diff] [blame] | 214 | int u_fpvalid; | 
|  | 215 | unsigned long int u_tsize; | 
|  | 216 | unsigned long int u_dsize; | 
|  | 217 | unsigned long int u_ssize; | 
|  | 218 | unsigned long start_code; | 
|  | 219 | unsigned long start_stack; | 
|  | 220 | long int signal; | 
|  | 221 | int reserved; | 
| Elliott Hughes | 3614424 | 2014-01-30 10:39:02 -0800 | [diff] [blame] | 222 | struct user_regs* u_ar0; | 
| Christopher Ferris | 363390e | 2013-11-22 18:00:09 -0800 | [diff] [blame] | 223 | unsigned long magic; | 
|  | 224 | char u_comm[32]; | 
|  | 225 | int u_debugreg[8]; | 
| Elliott Hughes | 3614424 | 2014-01-30 10:39:02 -0800 | [diff] [blame] | 226 | struct user_fpregs u_fp; | 
|  | 227 | struct user_fpregs* u_fp0; | 
| Christopher Ferris | 363390e | 2013-11-22 18:00:09 -0800 | [diff] [blame] | 228 | }; | 
|  | 229 |  | 
|  | 230 | #elif defined(__aarch64__) | 
|  | 231 |  | 
|  | 232 | // There are no user structures for 64 bit arm. | 
|  | 233 |  | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 234 | #else | 
|  | 235 |  | 
| Christopher Ferris | 363390e | 2013-11-22 18:00:09 -0800 | [diff] [blame] | 236 | #error "Unsupported architecture." | 
| Elliott Hughes | e888de8 | 2013-11-19 15:32:31 -0800 | [diff] [blame] | 237 |  | 
|  | 238 | #endif | 
|  | 239 |  | 
|  | 240 | __END_DECLS | 
|  | 241 |  | 
|  | 242 | #endif  /* _SYS_USER_H_ */ |