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