18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ARM_USER_H 38c2ecf20Sopenharmony_ci#define _ARM_USER_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <asm/page.h> 68c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 78c2ecf20Sopenharmony_ci/* Core file format: The core file is written in such a way that gdb 88c2ecf20Sopenharmony_ci can understand it and provide useful information to the user (under 98c2ecf20Sopenharmony_ci linux we use the 'trad-core' bfd). There are quite a number of 108c2ecf20Sopenharmony_ci obstacles to being able to view the contents of the floating point 118c2ecf20Sopenharmony_ci registers, and until these are solved you will not be able to view the 128c2ecf20Sopenharmony_ci contents of them. Actually, you can read in the core file and look at 138c2ecf20Sopenharmony_ci the contents of the user struct to find out what the floating point 148c2ecf20Sopenharmony_ci registers contain. 158c2ecf20Sopenharmony_ci The actual file contents are as follows: 168c2ecf20Sopenharmony_ci UPAGE: 1 page consisting of a user struct that tells gdb what is present 178c2ecf20Sopenharmony_ci in the file. Directly after this is a copy of the task_struct, which 188c2ecf20Sopenharmony_ci is currently not used by gdb, but it may come in useful at some point. 198c2ecf20Sopenharmony_ci All of the registers are stored as part of the upage. The upage should 208c2ecf20Sopenharmony_ci always be only one page. 218c2ecf20Sopenharmony_ci DATA: The data area is stored. We use current->end_text to 228c2ecf20Sopenharmony_ci current->brk to pick up all of the user variables, plus any memory 238c2ecf20Sopenharmony_ci that may have been malloced. No attempt is made to determine if a page 248c2ecf20Sopenharmony_ci is demand-zero or if a page is totally unused, we just cover the entire 258c2ecf20Sopenharmony_ci range. All of the addresses are rounded in such a way that an integral 268c2ecf20Sopenharmony_ci number of pages is written. 278c2ecf20Sopenharmony_ci STACK: We need the stack information in order to get a meaningful 288c2ecf20Sopenharmony_ci backtrace. We need to write the data from (esp) to 298c2ecf20Sopenharmony_ci current->start_stack, so we round each of these off in order to be able 308c2ecf20Sopenharmony_ci to write an integer number of pages. 318c2ecf20Sopenharmony_ci The minimum core file size is 3 pages, or 12288 bytes. 328c2ecf20Sopenharmony_ci*/ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct user_fp { 358c2ecf20Sopenharmony_ci struct fp_reg { 368c2ecf20Sopenharmony_ci unsigned int sign1:1; 378c2ecf20Sopenharmony_ci unsigned int unused:15; 388c2ecf20Sopenharmony_ci unsigned int sign2:1; 398c2ecf20Sopenharmony_ci unsigned int exponent:14; 408c2ecf20Sopenharmony_ci unsigned int j:1; 418c2ecf20Sopenharmony_ci unsigned int mantissa1:31; 428c2ecf20Sopenharmony_ci unsigned int mantissa0:32; 438c2ecf20Sopenharmony_ci } fpregs[8]; 448c2ecf20Sopenharmony_ci unsigned int fpsr:32; 458c2ecf20Sopenharmony_ci unsigned int fpcr:32; 468c2ecf20Sopenharmony_ci unsigned char ftype[8]; 478c2ecf20Sopenharmony_ci unsigned int init_flag; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* When the kernel dumps core, it starts by dumping the user struct - 518c2ecf20Sopenharmony_ci this will be used by gdb to figure out where the data and stack segments 528c2ecf20Sopenharmony_ci are within the file, and what virtual addresses to use. */ 538c2ecf20Sopenharmony_cistruct user{ 548c2ecf20Sopenharmony_ci/* We start with the registers, to mimic the way that "memory" is returned 558c2ecf20Sopenharmony_ci from the ptrace(3,...) function. */ 568c2ecf20Sopenharmony_ci struct pt_regs regs; /* Where the registers are actually stored */ 578c2ecf20Sopenharmony_ci/* ptrace does not yet supply these. Someday.... */ 588c2ecf20Sopenharmony_ci int u_fpvalid; /* True if math co-processor being used. */ 598c2ecf20Sopenharmony_ci /* for this mess. Not yet used. */ 608c2ecf20Sopenharmony_ci/* The rest of this junk is to help gdb figure out what goes where */ 618c2ecf20Sopenharmony_ci unsigned long int u_tsize; /* Text segment size (pages). */ 628c2ecf20Sopenharmony_ci unsigned long int u_dsize; /* Data segment size (pages). */ 638c2ecf20Sopenharmony_ci unsigned long int u_ssize; /* Stack segment size (pages). */ 648c2ecf20Sopenharmony_ci unsigned long start_code; /* Starting virtual address of text. */ 658c2ecf20Sopenharmony_ci unsigned long start_stack; /* Starting virtual address of stack area. 668c2ecf20Sopenharmony_ci This is actually the bottom of the stack, 678c2ecf20Sopenharmony_ci the top of the stack is always found in the 688c2ecf20Sopenharmony_ci esp register. */ 698c2ecf20Sopenharmony_ci long int signal; /* Signal that caused the core dump. */ 708c2ecf20Sopenharmony_ci int reserved; /* No longer used */ 718c2ecf20Sopenharmony_ci unsigned long u_ar0; /* Used by gdb to help find the values for */ 728c2ecf20Sopenharmony_ci /* the registers. */ 738c2ecf20Sopenharmony_ci unsigned long magic; /* To uniquely identify a core file */ 748c2ecf20Sopenharmony_ci char u_comm[32]; /* User command that was responsible */ 758c2ecf20Sopenharmony_ci int u_debugreg[8]; /* No longer used */ 768c2ecf20Sopenharmony_ci struct user_fp u_fp; /* FP state */ 778c2ecf20Sopenharmony_ci struct user_fp_struct * u_fp0;/* Used by gdb to help find the values for */ 788c2ecf20Sopenharmony_ci /* the FP registers. */ 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci#define NBPG PAGE_SIZE 818c2ecf20Sopenharmony_ci#define UPAGES 1 828c2ecf20Sopenharmony_ci#define HOST_TEXT_START_ADDR (u.start_code) 838c2ecf20Sopenharmony_ci#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci/* 868c2ecf20Sopenharmony_ci * User specific VFP registers. If only VFPv2 is present, registers 16 to 31 878c2ecf20Sopenharmony_ci * are ignored by the ptrace system call and the signal handler. 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_cistruct user_vfp { 908c2ecf20Sopenharmony_ci unsigned long long fpregs[32]; 918c2ecf20Sopenharmony_ci unsigned long fpscr; 928c2ecf20Sopenharmony_ci}; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* 958c2ecf20Sopenharmony_ci * VFP exception registers exposed to user space during signal delivery. 968c2ecf20Sopenharmony_ci * Fields not relavant to the current VFP architecture are ignored. 978c2ecf20Sopenharmony_ci */ 988c2ecf20Sopenharmony_cistruct user_vfp_exc { 998c2ecf20Sopenharmony_ci unsigned long fpexc; 1008c2ecf20Sopenharmony_ci unsigned long fpinst; 1018c2ecf20Sopenharmony_ci unsigned long fpinst2; 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#endif /* _ARM_USER_H */ 105