18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __ASM_SH_USER_H
38c2ecf20Sopenharmony_ci#define __ASM_SH_USER_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
68c2ecf20Sopenharmony_ci#include <asm/page.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/*
98c2ecf20Sopenharmony_ci * Core file format: The core file is written in such a way that gdb
108c2ecf20Sopenharmony_ci * can understand it and provide useful information to the user (under
118c2ecf20Sopenharmony_ci * linux we use the `trad-core' bfd).  The file contents are as follows:
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci *  upage: 1 page consisting of a user struct that tells gdb
148c2ecf20Sopenharmony_ci *	what is present in the file.  Directly after this is a
158c2ecf20Sopenharmony_ci *	copy of the task_struct, which is currently not used by gdb,
168c2ecf20Sopenharmony_ci *	but it may come in handy at some point.  All of the registers
178c2ecf20Sopenharmony_ci *	are stored as part of the upage.  The upage should always be
188c2ecf20Sopenharmony_ci *	only one page long.
198c2ecf20Sopenharmony_ci *  data: The data segment follows next.  We use current->end_text to
208c2ecf20Sopenharmony_ci *	current->brk to pick up all of the user variables, plus any memory
218c2ecf20Sopenharmony_ci *	that may have been sbrk'ed.  No attempt is made to determine if a
228c2ecf20Sopenharmony_ci *	page is demand-zero or if a page is totally unused, we just cover
238c2ecf20Sopenharmony_ci *	the entire range.  All of the addresses are rounded in such a way
248c2ecf20Sopenharmony_ci *	that an integral number of pages is written.
258c2ecf20Sopenharmony_ci *  stack: We need the stack information in order to get a meaningful
268c2ecf20Sopenharmony_ci *	backtrace.  We need to write the data from usp to
278c2ecf20Sopenharmony_ci *	current->start_stack, so we round each of these in order to be able
288c2ecf20Sopenharmony_ci *	to write an integer number of pages.
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_cistruct user_fpu_struct {
328c2ecf20Sopenharmony_ci	unsigned long fp_regs[16];
338c2ecf20Sopenharmony_ci	unsigned long xfp_regs[16];
348c2ecf20Sopenharmony_ci	unsigned long fpscr;
358c2ecf20Sopenharmony_ci	unsigned long fpul;
368c2ecf20Sopenharmony_ci};
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistruct user {
398c2ecf20Sopenharmony_ci	struct pt_regs	regs;			/* entire machine state */
408c2ecf20Sopenharmony_ci	struct user_fpu_struct fpu;	/* Math Co-processor registers  */
418c2ecf20Sopenharmony_ci	int u_fpvalid;		/* True if math co-processor being used */
428c2ecf20Sopenharmony_ci	size_t		u_tsize;		/* text size (pages) */
438c2ecf20Sopenharmony_ci	size_t		u_dsize;		/* data size (pages) */
448c2ecf20Sopenharmony_ci	size_t		u_ssize;		/* stack size (pages) */
458c2ecf20Sopenharmony_ci	unsigned long	start_code;		/* text starting address */
468c2ecf20Sopenharmony_ci	unsigned long	start_data;		/* data starting address */
478c2ecf20Sopenharmony_ci	unsigned long	start_stack;		/* stack starting address */
488c2ecf20Sopenharmony_ci	long int	signal;			/* signal causing core dump */
498c2ecf20Sopenharmony_ci	unsigned long	u_ar0;			/* help gdb find registers */
508c2ecf20Sopenharmony_ci	struct user_fpu_struct* u_fpstate;	/* Math Co-processor pointer */
518c2ecf20Sopenharmony_ci	unsigned long	magic;			/* identifies a core file */
528c2ecf20Sopenharmony_ci	char		u_comm[32];		/* user command name */
538c2ecf20Sopenharmony_ci};
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#define NBPG			PAGE_SIZE
568c2ecf20Sopenharmony_ci#define UPAGES			1
578c2ecf20Sopenharmony_ci#define HOST_TEXT_START_ADDR	(u.start_code)
588c2ecf20Sopenharmony_ci#define HOST_DATA_START_ADDR	(u.start_data)
598c2ecf20Sopenharmony_ci#define HOST_STACK_END_ADDR	(u.start_stack + u.u_ssize * NBPG)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#endif /* __ASM_SH_USER_H */
62