2013-11-20 00:32:31 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 The Android Open Source Project
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_USER_H_
|
|
|
|
#define _SYS_USER_H_
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2014-11-18 12:21:55 +01:00
|
|
|
#include <stddef.h> /* For size_t. */
|
2016-04-26 02:04:56 +02:00
|
|
|
#include <stdint.h>
|
2013-11-20 00:32:31 +01:00
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2015-07-28 23:58:37 +02:00
|
|
|
#define PAGE_SIZE 4096
|
|
|
|
#define PAGE_MASK (~(PAGE_SIZE - 1))
|
|
|
|
|
2016-09-15 22:56:37 +02:00
|
|
|
#if defined(__i386__)
|
2013-11-20 00:32:31 +01:00
|
|
|
|
2014-04-10 01:35:36 +02:00
|
|
|
struct user_fpregs_struct {
|
2013-11-20 00:32:31 +01:00
|
|
|
long cwd;
|
|
|
|
long swd;
|
|
|
|
long twd;
|
|
|
|
long fip;
|
|
|
|
long fcs;
|
|
|
|
long foo;
|
|
|
|
long fos;
|
|
|
|
long st_space[20];
|
|
|
|
};
|
2015-06-25 02:31:24 +02:00
|
|
|
struct user_fpxregs_struct {
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned short cwd;
|
|
|
|
unsigned short swd;
|
|
|
|
unsigned short twd;
|
|
|
|
unsigned short fop;
|
|
|
|
long fip;
|
|
|
|
long fcs;
|
|
|
|
long foo;
|
|
|
|
long fos;
|
|
|
|
long mxcsr;
|
|
|
|
long reserved;
|
|
|
|
long st_space[32];
|
|
|
|
long xmm_space[32];
|
|
|
|
long padding[56];
|
|
|
|
};
|
|
|
|
struct user_regs_struct {
|
2014-01-09 23:01:18 +01:00
|
|
|
long ebx;
|
|
|
|
long ecx;
|
|
|
|
long edx;
|
|
|
|
long esi;
|
|
|
|
long edi;
|
|
|
|
long ebp;
|
|
|
|
long eax;
|
|
|
|
long xds;
|
|
|
|
long xes;
|
|
|
|
long xfs;
|
|
|
|
long xgs;
|
|
|
|
long orig_eax;
|
|
|
|
long eip;
|
|
|
|
long xcs;
|
|
|
|
long eflags;
|
|
|
|
long esp;
|
|
|
|
long xss;
|
2013-11-20 00:32:31 +01:00
|
|
|
};
|
2013-11-27 02:57:31 +01:00
|
|
|
struct user {
|
2013-11-20 00:32:31 +01:00
|
|
|
struct user_regs_struct regs;
|
|
|
|
int u_fpvalid;
|
2014-04-10 01:35:36 +02:00
|
|
|
struct user_fpregs_struct i387;
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned long int u_tsize;
|
|
|
|
unsigned long int u_dsize;
|
|
|
|
unsigned long int u_ssize;
|
|
|
|
unsigned long start_code;
|
|
|
|
unsigned long start_stack;
|
|
|
|
long int signal;
|
|
|
|
int reserved;
|
2014-10-25 05:57:09 +02:00
|
|
|
struct user_regs_struct* u_ar0;
|
2014-04-10 01:35:36 +02:00
|
|
|
struct user_fpregs_struct* u_fpstate;
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned long magic;
|
|
|
|
char u_comm[32];
|
|
|
|
int u_debugreg[8];
|
|
|
|
};
|
|
|
|
|
2017-07-06 20:04:15 +02:00
|
|
|
#define UPAGES 1
|
|
|
|
#define HOST_TEXT_START_ADDR (u.start_code)
|
|
|
|
#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * PAGE_SIZE)
|
|
|
|
|
2013-11-20 00:32:31 +01:00
|
|
|
#elif defined(__x86_64__)
|
|
|
|
|
2014-04-10 01:35:36 +02:00
|
|
|
struct user_fpregs_struct {
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned short cwd;
|
|
|
|
unsigned short swd;
|
2014-05-14 14:29:19 +02:00
|
|
|
unsigned short ftw;
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned short fop;
|
2016-05-26 00:18:14 +02:00
|
|
|
unsigned long rip;
|
|
|
|
unsigned long rdp;
|
|
|
|
unsigned int mxcsr;
|
|
|
|
unsigned int mxcr_mask;
|
|
|
|
unsigned int st_space[32];
|
|
|
|
unsigned int xmm_space[64];
|
|
|
|
unsigned int padding[24];
|
2013-11-20 00:32:31 +01:00
|
|
|
};
|
|
|
|
struct user_regs_struct {
|
|
|
|
unsigned long r15;
|
|
|
|
unsigned long r14;
|
|
|
|
unsigned long r13;
|
|
|
|
unsigned long r12;
|
2014-01-09 00:54:19 +01:00
|
|
|
unsigned long rbp;
|
|
|
|
unsigned long rbx;
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned long r11;
|
|
|
|
unsigned long r10;
|
|
|
|
unsigned long r9;
|
|
|
|
unsigned long r8;
|
2014-01-09 00:54:19 +01:00
|
|
|
unsigned long rax;
|
|
|
|
unsigned long rcx;
|
|
|
|
unsigned long rdx;
|
|
|
|
unsigned long rsi;
|
|
|
|
unsigned long rdi;
|
|
|
|
unsigned long orig_rax;
|
|
|
|
unsigned long rip;
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned long cs;
|
2014-01-09 00:54:19 +01:00
|
|
|
unsigned long eflags;
|
|
|
|
unsigned long rsp;
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned long ss;
|
|
|
|
unsigned long fs_base;
|
|
|
|
unsigned long gs_base;
|
|
|
|
unsigned long ds;
|
|
|
|
unsigned long es;
|
|
|
|
unsigned long fs;
|
|
|
|
unsigned long gs;
|
|
|
|
};
|
|
|
|
struct user {
|
|
|
|
struct user_regs_struct regs;
|
|
|
|
int u_fpvalid;
|
|
|
|
int pad0;
|
2014-04-10 01:35:36 +02:00
|
|
|
struct user_fpregs_struct i387;
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned long int u_tsize;
|
|
|
|
unsigned long int u_dsize;
|
|
|
|
unsigned long int u_ssize;
|
|
|
|
unsigned long start_code;
|
|
|
|
unsigned long start_stack;
|
|
|
|
long int signal;
|
|
|
|
int reserved;
|
|
|
|
int pad1;
|
2014-10-25 05:57:09 +02:00
|
|
|
struct user_regs_struct* u_ar0;
|
2014-04-10 01:35:36 +02:00
|
|
|
struct user_fpregs_struct* u_fpstate;
|
2013-11-20 00:32:31 +01:00
|
|
|
unsigned long magic;
|
|
|
|
char u_comm[32];
|
|
|
|
unsigned long u_debugreg[8];
|
|
|
|
unsigned long error_code;
|
|
|
|
unsigned long fault_address;
|
|
|
|
};
|
|
|
|
|
2013-11-23 03:00:09 +01:00
|
|
|
#elif defined(__arm__)
|
|
|
|
|
2014-01-30 19:39:02 +01:00
|
|
|
struct user_fpregs {
|
2013-11-23 03:00:09 +01:00
|
|
|
struct fp_reg {
|
|
|
|
unsigned int sign1:1;
|
|
|
|
unsigned int unused:15;
|
|
|
|
unsigned int sign2:1;
|
|
|
|
unsigned int exponent:14;
|
|
|
|
unsigned int j:1;
|
|
|
|
unsigned int mantissa1:31;
|
|
|
|
unsigned int mantissa0:32;
|
|
|
|
} fpregs[8];
|
|
|
|
unsigned int fpsr:32;
|
|
|
|
unsigned int fpcr:32;
|
|
|
|
unsigned char ftype[8];
|
|
|
|
unsigned int init_flag;
|
|
|
|
};
|
2014-01-30 19:39:02 +01:00
|
|
|
struct user_regs {
|
|
|
|
unsigned long uregs[18];
|
|
|
|
};
|
2013-11-27 02:57:31 +01:00
|
|
|
struct user_vfp {
|
|
|
|
unsigned long long fpregs[32];
|
|
|
|
unsigned long fpscr;
|
|
|
|
};
|
|
|
|
struct user_vfp_exc {
|
|
|
|
unsigned long fpexc;
|
|
|
|
unsigned long fpinst;
|
|
|
|
unsigned long fpinst2;
|
|
|
|
};
|
|
|
|
struct user {
|
2014-01-30 19:39:02 +01:00
|
|
|
struct user_regs regs;
|
2013-11-23 03:00:09 +01:00
|
|
|
int u_fpvalid;
|
|
|
|
unsigned long int u_tsize;
|
|
|
|
unsigned long int u_dsize;
|
|
|
|
unsigned long int u_ssize;
|
|
|
|
unsigned long start_code;
|
|
|
|
unsigned long start_stack;
|
|
|
|
long int signal;
|
|
|
|
int reserved;
|
2014-01-30 19:39:02 +01:00
|
|
|
struct user_regs* u_ar0;
|
2013-11-23 03:00:09 +01:00
|
|
|
unsigned long magic;
|
|
|
|
char u_comm[32];
|
|
|
|
int u_debugreg[8];
|
2014-01-30 19:39:02 +01:00
|
|
|
struct user_fpregs u_fp;
|
|
|
|
struct user_fpregs* u_fp0;
|
2013-11-23 03:00:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#elif defined(__aarch64__)
|
|
|
|
|
2015-08-25 23:18:26 +02:00
|
|
|
struct user_regs_struct {
|
|
|
|
uint64_t regs[31];
|
|
|
|
uint64_t sp;
|
|
|
|
uint64_t pc;
|
|
|
|
uint64_t pstate;
|
|
|
|
};
|
|
|
|
struct user_fpsimd_struct {
|
|
|
|
__uint128_t vregs[32];
|
|
|
|
uint32_t fpsr;
|
|
|
|
uint32_t fpcr;
|
|
|
|
};
|
2013-11-23 03:00:09 +01:00
|
|
|
|
2013-11-20 00:32:31 +01:00
|
|
|
#else
|
|
|
|
|
2013-11-23 03:00:09 +01:00
|
|
|
#error "Unsupported architecture."
|
2013-11-20 00:32:31 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif /* _SYS_USER_H_ */
|