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