1c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef _ARM_USER_H
2c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define _ARM_USER_H
3c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
4c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#include <asm/page.h>
5c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#include <asm/ptrace.h>
6c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* Core file format: The core file is written in such a way that gdb
7c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   can understand it and provide useful information to the user (under
8c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   linux we use the 'trad-core' bfd).  There are quite a number of
9c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   obstacles to being able to view the contents of the floating point
10c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   registers, and until these are solved you will not be able to view the
11c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   contents of them.  Actually, you can read in the core file and look at
12c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   the contents of the user struct to find out what the floating point
13c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   registers contain.
14c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   The actual file contents are as follows:
15c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   UPAGE: 1 page consisting of a user struct that tells gdb what is present
16c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   in the file.  Directly after this is a copy of the task_struct, which
17c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   is currently not used by gdb, but it may come in useful at some point.
18c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   All of the registers are stored as part of the upage.  The upage should
19c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   always be only one page.
20c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   DATA: The data area is stored.  We use current->end_text to
21c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   current->brk to pick up all of the user variables, plus any memory
22c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   that may have been malloced.  No attempt is made to determine if a page
23c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   is demand-zero or if a page is totally unused, we just cover the entire
24c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   range.  All of the addresses are rounded in such a way that an integral
25c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   number of pages is written.
26c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   STACK: We need the stack information in order to get a meaningful
27c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   backtrace.  We need to write the data from (esp) to
28c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   current->start_stack, so we round each of these off in order to be able
29c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   to write an integer number of pages.
30c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   The minimum core file size is 3 pages, or 12288 bytes.
31c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru*/
32c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
33c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Querustruct user_fp {
34c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru	struct fp_reg {
35c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru		unsigned int sign1:1;
36c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru		unsigned int unused:15;
37c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru		unsigned int sign2:1;
38c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru		unsigned int exponent:14;
39c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru		unsigned int j:1;
40c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru		unsigned int mantissa1:31;
41c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru		unsigned int mantissa0:32;
42c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru	} fpregs[8];
43c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru	unsigned int fpsr:32;
44c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru	unsigned int fpcr:32;
45c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru	unsigned char ftype[8];
46c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru	unsigned int init_flag;
47c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru};
48c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
49c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* When the kernel dumps core, it starts by dumping the user struct -
50c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   this will be used by gdb to figure out where the data and stack segments
51c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   are within the file, and what virtual addresses to use. */
52c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Querustruct user{
53c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* We start with the registers, to mimic the way that "memory" is returned
54c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru   from the ptrace(3,...) function.  */
55c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  struct pt_regs regs;		/* Where the registers are actually stored */
56c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* ptrace does not yet supply these.  Someday.... */
57c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  int u_fpvalid;		/* True if math co-processor being used. */
58c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru                                /* for this mess. Not yet used. */
59c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* The rest of this junk is to help gdb figure out what goes where */
60c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  unsigned long int u_tsize;	/* Text segment size (pages). */
61c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  unsigned long int u_dsize;	/* Data segment size (pages). */
62c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  unsigned long int u_ssize;	/* Stack segment size (pages). */
63c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  unsigned long start_code;     /* Starting virtual address of text. */
64c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  unsigned long start_stack;	/* Starting virtual address of stack area.
65c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru				   This is actually the bottom of the stack,
66c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru				   the top of the stack is always found in the
67c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru				   esp register.  */
68c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  long int signal;     		/* Signal that caused the core dump. */
69c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  int reserved;			/* No longer used */
70c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  struct pt_regs * u_ar0;	/* Used by gdb to help find the values for */
71c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru				/* the registers. */
72c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  unsigned long magic;		/* To uniquely identify a core file */
73c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  char u_comm[32];		/* User command that was responsible */
74c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  int u_debugreg[8];
75c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  struct user_fp u_fp;		/* FP state */
76c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  struct user_fp_struct * u_fp0;/* Used by gdb to help find the values for */
77c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  				/* the FP registers. */
78c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru};
79c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define NBPG PAGE_SIZE
80c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define UPAGES 1
81c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define HOST_TEXT_START_ADDR (u.start_code)
82c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
83c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
84d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner/*
85d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner * User specific VFP registers. If only VFPv2 is present, registers 16 to 31
86d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner * are ignored by the ptrace system call and the signal handler.
87d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner */
88d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turnerstruct user_vfp {
89d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner	unsigned long long fpregs[32];
90d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner	unsigned long fpscr;
91d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner};
92d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner
93d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner/*
94d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner * VFP exception registers exposed to user space during signal delivery.
95d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner * Fields not relavant to the current VFP architecture are ignored.
96d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner */
97d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turnerstruct user_vfp_exc {
98d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner	unsigned long	fpexc;
99d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner	unsigned long	fpinst;
100d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner	unsigned long	fpinst2;
101d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner};
102d47bb549ea8cb91415e130713495d0039b5c4d1cDavid 'Digit' Turner
103c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif /* _ARM_USER_H */
104