xref: /linux/arch/xtensa/include/asm/ptrace.h (revision 40d1a07b333ef1f7fce11ee20b8f4281d1a75fb9)
1 /*
2  * include/asm-xtensa/ptrace.h
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (C) 2001 - 2005 Tensilica Inc.
9  */
10 #ifndef _XTENSA_PTRACE_H
11 #define _XTENSA_PTRACE_H
12 
13 #include <asm/kmem_layout.h>
14 #include <uapi/asm/ptrace.h>
15 
16 /*
17  * Kernel stack
18  *
19  *		+-----------------------+  -------- STACK_SIZE
20  *		|     register file     |  |
21  *		+-----------------------+  |
22  *		|    struct pt_regs     |  |
23  *		+-----------------------+  | ------ PT_REGS_OFFSET
24  * double	:  16 bytes spill area  :  |  ^
25  * excetion	:- - - - - - - - - - - -:  |  |
26  * frame	:    struct pt_regs     :  |  |
27  *		:- - - - - - - - - - - -:  |  |
28  *		|                       |  |  |
29  *		|     memory stack      |  |  |
30  *		|                       |  |  |
31  *		~                       ~  ~  ~
32  *		~                       ~  ~  ~
33  *		|                       |  |  |
34  *		|                       |  |  |
35  *		+-----------------------+  |  | --- STACK_BIAS
36  *		|  struct task_struct   |  |  |  ^
37  *  current --> +-----------------------+  |  |  |
38  *		|  struct thread_info   |  |  |  |
39  *		+-----------------------+ --------
40  */
41 
42 /*  Offsets for exception_handlers[] (3 x 64-entries x 4-byte tables). */
43 
44 #define EXC_TABLE_KSTK		0x004	/* Kernel Stack */
45 #define EXC_TABLE_DOUBLE_SAVE	0x008	/* Double exception save area for a0 */
46 #define EXC_TABLE_FIXUP		0x00c	/* Fixup handler */
47 #define EXC_TABLE_PARAM		0x010	/* For passing a parameter to fixup */
48 #define EXC_TABLE_SYSCALL_SAVE	0x014	/* For fast syscall handler */
49 #define EXC_TABLE_FAST_USER	0x100	/* Fast user exception handler */
50 #define EXC_TABLE_FAST_KERNEL	0x200	/* Fast kernel exception handler */
51 #define EXC_TABLE_DEFAULT	0x300	/* Default C-Handler */
52 #define EXC_TABLE_SIZE		0x400
53 
54 #ifndef __ASSEMBLY__
55 
56 #include <asm/coprocessor.h>
57 
58 /*
59  * This struct defines the way the registers are stored on the
60  * kernel stack during a system call or other kernel entry.
61  */
62 struct pt_regs {
63 	unsigned long pc;		/*   4 */
64 	unsigned long ps;		/*   8 */
65 	unsigned long depc;		/*  12 */
66 	unsigned long exccause;		/*  16 */
67 	unsigned long excvaddr;		/*  20 */
68 	unsigned long debugcause;	/*  24 */
69 	unsigned long wmask;		/*  28 */
70 	unsigned long lbeg;		/*  32 */
71 	unsigned long lend;		/*  36 */
72 	unsigned long lcount;		/*  40 */
73 	unsigned long sar;		/*  44 */
74 	unsigned long windowbase;	/*  48 */
75 	unsigned long windowstart;	/*  52 */
76 	unsigned long syscall;		/*  56 */
77 	unsigned long icountlevel;	/*  60 */
78 	unsigned long scompare1;	/*  64 */
79 	unsigned long threadptr;	/*  68 */
80 
81 	/* Additional configurable registers that are used by the compiler. */
82 	xtregs_opt_t xtregs_opt;
83 
84 	/* Make sure the areg field is 16 bytes aligned. */
85 	int align[0] __attribute__ ((aligned(16)));
86 
87 	/* current register frame.
88 	 * Note: The ESF for kernel exceptions ends after 16 registers!
89 	 */
90 	unsigned long areg[16];
91 };
92 
93 #include <variant/core.h>
94 
95 # define arch_has_single_step()	(1)
96 # define task_pt_regs(tsk) ((struct pt_regs*) \
97 	(task_stack_page(tsk) + KERNEL_STACK_SIZE - (XCHAL_NUM_AREGS-16)*4) - 1)
98 # define user_mode(regs) (((regs)->ps & 0x00000020)!=0)
99 # define instruction_pointer(regs) ((regs)->pc)
100 # define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \
101 					       (regs)->areg[1]))
102 
103 # ifndef CONFIG_SMP
104 #  define profile_pc(regs) instruction_pointer(regs)
105 # else
106 #  define profile_pc(regs)						\
107 	({								\
108 		in_lock_functions(instruction_pointer(regs)) ?		\
109 		return_pointer(regs) : instruction_pointer(regs);	\
110 	})
111 # endif
112 
113 #define user_stack_pointer(regs) ((regs)->areg[1])
114 
115 #else	/* __ASSEMBLY__ */
116 
117 # include <asm/asm-offsets.h>
118 #define PT_REGS_OFFSET	  (KERNEL_STACK_SIZE - PT_USER_SIZE)
119 
120 #endif	/* !__ASSEMBLY__ */
121 
122 #endif	/* _XTENSA_PTRACE_H */
123