18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_USER_32_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_USER_32_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/page.h>
68c2ecf20Sopenharmony_ci/* Core file format: The core file is written in such a way that gdb
78c2ecf20Sopenharmony_ci   can understand it and provide useful information to the user (under
88c2ecf20Sopenharmony_ci   linux we use the 'trad-core' bfd).  There are quite a number of
98c2ecf20Sopenharmony_ci   obstacles to being able to view the contents of the floating point
108c2ecf20Sopenharmony_ci   registers, and until these are solved you will not be able to view the
118c2ecf20Sopenharmony_ci   contents of them.  Actually, you can read in the core file and look at
128c2ecf20Sopenharmony_ci   the contents of the user struct to find out what the floating point
138c2ecf20Sopenharmony_ci   registers contain.
148c2ecf20Sopenharmony_ci   The actual file contents are as follows:
158c2ecf20Sopenharmony_ci   UPAGE: 1 page consisting of a user struct that tells gdb what is present
168c2ecf20Sopenharmony_ci   in the file.  Directly after this is a copy of the task_struct, which
178c2ecf20Sopenharmony_ci   is currently not used by gdb, but it may come in useful at some point.
188c2ecf20Sopenharmony_ci   All of the registers are stored as part of the upage.  The upage should
198c2ecf20Sopenharmony_ci   always be only one page.
208c2ecf20Sopenharmony_ci   DATA: The data area is stored.  We use current->end_text to
218c2ecf20Sopenharmony_ci   current->brk to pick up all of the user variables, plus any memory
228c2ecf20Sopenharmony_ci   that may have been malloced.  No attempt is made to determine if a page
238c2ecf20Sopenharmony_ci   is demand-zero or if a page is totally unused, we just cover the entire
248c2ecf20Sopenharmony_ci   range.  All of the addresses are rounded in such a way that an integral
258c2ecf20Sopenharmony_ci   number of pages is written.
268c2ecf20Sopenharmony_ci   STACK: We need the stack information in order to get a meaningful
278c2ecf20Sopenharmony_ci   backtrace.  We need to write the data from (esp) to
288c2ecf20Sopenharmony_ci   current->start_stack, so we round each of these off in order to be able
298c2ecf20Sopenharmony_ci   to write an integer number of pages.
308c2ecf20Sopenharmony_ci   The minimum core file size is 3 pages, or 12288 bytes.
318c2ecf20Sopenharmony_ci*/
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci * Pentium III FXSR, SSE support
358c2ecf20Sopenharmony_ci *	Gareth Hughes <gareth@valinux.com>, May 2000
368c2ecf20Sopenharmony_ci *
378c2ecf20Sopenharmony_ci * Provide support for the GDB 5.0+ PTRACE_{GET|SET}FPXREGS requests for
388c2ecf20Sopenharmony_ci * interacting with the FXSR-format floating point environment.  Floating
398c2ecf20Sopenharmony_ci * point data can be accessed in the regular format in the usual manner,
408c2ecf20Sopenharmony_ci * and both the standard and SIMD floating point data can be accessed via
418c2ecf20Sopenharmony_ci * the new ptrace requests.  In either case, changes to the FPU environment
428c2ecf20Sopenharmony_ci * will be reflected in the task's state as expected.
438c2ecf20Sopenharmony_ci */
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistruct user_i387_struct {
468c2ecf20Sopenharmony_ci	long	cwd;
478c2ecf20Sopenharmony_ci	long	swd;
488c2ecf20Sopenharmony_ci	long	twd;
498c2ecf20Sopenharmony_ci	long	fip;
508c2ecf20Sopenharmony_ci	long	fcs;
518c2ecf20Sopenharmony_ci	long	foo;
528c2ecf20Sopenharmony_ci	long	fos;
538c2ecf20Sopenharmony_ci	long	st_space[20];	/* 8*10 bytes for each FP-reg = 80 bytes */
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistruct user_fxsr_struct {
578c2ecf20Sopenharmony_ci	unsigned short	cwd;
588c2ecf20Sopenharmony_ci	unsigned short	swd;
598c2ecf20Sopenharmony_ci	unsigned short	twd;
608c2ecf20Sopenharmony_ci	unsigned short	fop;
618c2ecf20Sopenharmony_ci	long	fip;
628c2ecf20Sopenharmony_ci	long	fcs;
638c2ecf20Sopenharmony_ci	long	foo;
648c2ecf20Sopenharmony_ci	long	fos;
658c2ecf20Sopenharmony_ci	long	mxcsr;
668c2ecf20Sopenharmony_ci	long	reserved;
678c2ecf20Sopenharmony_ci	long	st_space[32];	/* 8*16 bytes for each FP-reg = 128 bytes */
688c2ecf20Sopenharmony_ci	long	xmm_space[32];	/* 8*16 bytes for each XMM-reg = 128 bytes */
698c2ecf20Sopenharmony_ci	long	padding[56];
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/*
738c2ecf20Sopenharmony_ci * This is the old layout of "struct pt_regs", and
748c2ecf20Sopenharmony_ci * is still the layout used by user mode (the new
758c2ecf20Sopenharmony_ci * pt_regs doesn't have all registers as the kernel
768c2ecf20Sopenharmony_ci * doesn't use the extra segment registers)
778c2ecf20Sopenharmony_ci */
788c2ecf20Sopenharmony_cistruct user_regs_struct {
798c2ecf20Sopenharmony_ci	unsigned long	bx;
808c2ecf20Sopenharmony_ci	unsigned long	cx;
818c2ecf20Sopenharmony_ci	unsigned long	dx;
828c2ecf20Sopenharmony_ci	unsigned long	si;
838c2ecf20Sopenharmony_ci	unsigned long	di;
848c2ecf20Sopenharmony_ci	unsigned long	bp;
858c2ecf20Sopenharmony_ci	unsigned long	ax;
868c2ecf20Sopenharmony_ci	unsigned long	ds;
878c2ecf20Sopenharmony_ci	unsigned long	es;
888c2ecf20Sopenharmony_ci	unsigned long	fs;
898c2ecf20Sopenharmony_ci	unsigned long	gs;
908c2ecf20Sopenharmony_ci	unsigned long	orig_ax;
918c2ecf20Sopenharmony_ci	unsigned long	ip;
928c2ecf20Sopenharmony_ci	unsigned long	cs;
938c2ecf20Sopenharmony_ci	unsigned long	flags;
948c2ecf20Sopenharmony_ci	unsigned long	sp;
958c2ecf20Sopenharmony_ci	unsigned long	ss;
968c2ecf20Sopenharmony_ci};
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci/* When the kernel dumps core, it starts by dumping the user struct -
998c2ecf20Sopenharmony_ci   this will be used by gdb to figure out where the data and stack segments
1008c2ecf20Sopenharmony_ci   are within the file, and what virtual addresses to use. */
1018c2ecf20Sopenharmony_cistruct user{
1028c2ecf20Sopenharmony_ci/* We start with the registers, to mimic the way that "memory" is returned
1038c2ecf20Sopenharmony_ci   from the ptrace(3,...) function.  */
1048c2ecf20Sopenharmony_ci  struct user_regs_struct regs;	/* Where the registers are actually stored */
1058c2ecf20Sopenharmony_ci/* ptrace does not yet supply these.  Someday.... */
1068c2ecf20Sopenharmony_ci  int u_fpvalid;		/* True if math co-processor being used. */
1078c2ecf20Sopenharmony_ci				/* for this mess. Not yet used. */
1088c2ecf20Sopenharmony_ci  struct user_i387_struct i387;	/* Math Co-processor registers. */
1098c2ecf20Sopenharmony_ci/* The rest of this junk is to help gdb figure out what goes where */
1108c2ecf20Sopenharmony_ci  unsigned long int u_tsize;	/* Text segment size (pages). */
1118c2ecf20Sopenharmony_ci  unsigned long int u_dsize;	/* Data segment size (pages). */
1128c2ecf20Sopenharmony_ci  unsigned long int u_ssize;	/* Stack segment size (pages). */
1138c2ecf20Sopenharmony_ci  unsigned long start_code;     /* Starting virtual address of text. */
1148c2ecf20Sopenharmony_ci  unsigned long start_stack;	/* Starting virtual address of stack area.
1158c2ecf20Sopenharmony_ci				   This is actually the bottom of the stack,
1168c2ecf20Sopenharmony_ci				   the top of the stack is always found in the
1178c2ecf20Sopenharmony_ci				   esp register.  */
1188c2ecf20Sopenharmony_ci  long int signal;     		/* Signal that caused the core dump. */
1198c2ecf20Sopenharmony_ci  int reserved;			/* No longer used */
1208c2ecf20Sopenharmony_ci  unsigned long u_ar0;		/* Used by gdb to help find the values for */
1218c2ecf20Sopenharmony_ci				/* the registers. */
1228c2ecf20Sopenharmony_ci  struct user_i387_struct *u_fpstate;	/* Math Co-processor pointer. */
1238c2ecf20Sopenharmony_ci  unsigned long magic;		/* To uniquely identify a core file */
1248c2ecf20Sopenharmony_ci  char u_comm[32];		/* User command that was responsible */
1258c2ecf20Sopenharmony_ci  int u_debugreg[8];
1268c2ecf20Sopenharmony_ci};
1278c2ecf20Sopenharmony_ci#define NBPG PAGE_SIZE
1288c2ecf20Sopenharmony_ci#define UPAGES 1
1298c2ecf20Sopenharmony_ci#define HOST_TEXT_START_ADDR (u.start_code)
1308c2ecf20Sopenharmony_ci#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#endif /* _ASM_X86_USER_32_H */
133