18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _H8300_USER_H 38c2ecf20Sopenharmony_ci#define _H8300_USER_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <asm/page.h> 68c2ecf20Sopenharmony_ci 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_ci/* This is the old layout of "struct pt_regs" as of Linux 1.x, and 358c2ecf20Sopenharmony_ci is still the layout used by user (the new pt_regs doesn't have 368c2ecf20Sopenharmony_ci all registers). */ 378c2ecf20Sopenharmony_cistruct user_regs_struct { 388c2ecf20Sopenharmony_ci long er1, er2, er3, er4, er5, er6; 398c2ecf20Sopenharmony_ci long er0; 408c2ecf20Sopenharmony_ci long usp; 418c2ecf20Sopenharmony_ci long orig_er0; 428c2ecf20Sopenharmony_ci long ccr; 438c2ecf20Sopenharmony_ci long pc; 448c2ecf20Sopenharmony_ci}; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* When the kernel dumps core, it starts by dumping the user struct - 478c2ecf20Sopenharmony_ci this will be used by gdb to figure out where the data and stack segments 488c2ecf20Sopenharmony_ci are within the file, and what virtual addresses to use. */ 498c2ecf20Sopenharmony_cistruct user { 508c2ecf20Sopenharmony_ci/* We start with the registers, to mimic the way that "memory" is returned 518c2ecf20Sopenharmony_ci from the ptrace(3,...) function. */ 528c2ecf20Sopenharmony_ci struct user_regs_struct regs; /* Where the registers are actually stored */ 538c2ecf20Sopenharmony_ci/* ptrace does not yet supply these. Someday.... */ 548c2ecf20Sopenharmony_ci/* The rest of this junk is to help gdb figure out what goes where */ 558c2ecf20Sopenharmony_ci unsigned long int u_tsize; /* Text segment size (pages). */ 568c2ecf20Sopenharmony_ci unsigned long int u_dsize; /* Data segment size (pages). */ 578c2ecf20Sopenharmony_ci unsigned long int u_ssize; /* Stack segment size (pages). */ 588c2ecf20Sopenharmony_ci unsigned long start_code; /* Starting virtual address of text. */ 598c2ecf20Sopenharmony_ci unsigned long start_stack; /* Starting virtual address of stack area. 608c2ecf20Sopenharmony_ci This is actually the bottom of the stack, 618c2ecf20Sopenharmony_ci the top of the stack is always found in the 628c2ecf20Sopenharmony_ci esp register. */ 638c2ecf20Sopenharmony_ci long int signal; /* Signal that caused the core dump. */ 648c2ecf20Sopenharmony_ci int reserved; /* No longer used */ 658c2ecf20Sopenharmony_ci unsigned long u_ar0; /* Used by gdb to help find the values for */ 668c2ecf20Sopenharmony_ci /* the registers. */ 678c2ecf20Sopenharmony_ci unsigned long magic; /* To uniquely identify a core file */ 688c2ecf20Sopenharmony_ci char u_comm[32]; /* User command that was responsible */ 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci#define NBPG PAGE_SIZE 718c2ecf20Sopenharmony_ci#define UPAGES 1 728c2ecf20Sopenharmony_ci#define HOST_TEXT_START_ADDR (u.start_code) 738c2ecf20Sopenharmony_ci#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#endif 76