xref: /openbmc/linux/arch/xtensa/include/asm/ptrace.h (revision e0d77d0f38aa60ca61b3ce6e60d64fad2aa0853d)
1367b8112SChris Zankel /*
2367b8112SChris Zankel  * include/asm-xtensa/ptrace.h
3367b8112SChris Zankel  *
4367b8112SChris Zankel  * This file is subject to the terms and conditions of the GNU General Public
5367b8112SChris Zankel  * License.  See the file "COPYING" in the main directory of this archive
6367b8112SChris Zankel  * for more details.
7367b8112SChris Zankel  *
8367b8112SChris Zankel  * Copyright (C) 2001 - 2005 Tensilica Inc.
9367b8112SChris Zankel  */
10367b8112SChris Zankel #ifndef _XTENSA_PTRACE_H
11367b8112SChris Zankel #define _XTENSA_PTRACE_H
12367b8112SChris Zankel 
13f4431396SMax Filippov #include <asm/kmem_layout.h>
1483596729SDavid Howells #include <uapi/asm/ptrace.h>
15367b8112SChris Zankel 
160700ed07SMax Filippov /*
170700ed07SMax Filippov  * Kernel stack
180700ed07SMax Filippov  *
190700ed07SMax Filippov  *		+-----------------------+  -------- STACK_SIZE
200700ed07SMax Filippov  *		|     register file     |  |
210700ed07SMax Filippov  *		+-----------------------+  |
220700ed07SMax Filippov  *		|    struct pt_regs     |  |
230700ed07SMax Filippov  *		+-----------------------+  | ------ PT_REGS_OFFSET
240700ed07SMax Filippov  * double	:  16 bytes spill area  :  |  ^
250700ed07SMax Filippov  * excetion	:- - - - - - - - - - - -:  |  |
260700ed07SMax Filippov  * frame	:    struct pt_regs     :  |  |
270700ed07SMax Filippov  *		:- - - - - - - - - - - -:  |  |
280700ed07SMax Filippov  *		|                       |  |  |
290700ed07SMax Filippov  *		|     memory stack      |  |  |
300700ed07SMax Filippov  *		|                       |  |  |
310700ed07SMax Filippov  *		~                       ~  ~  ~
320700ed07SMax Filippov  *		~                       ~  ~  ~
330700ed07SMax Filippov  *		|                       |  |  |
340700ed07SMax Filippov  *		|                       |  |  |
350700ed07SMax Filippov  *		+-----------------------+  |  | --- STACK_BIAS
360700ed07SMax Filippov  *		|  struct task_struct   |  |  |  ^
370700ed07SMax Filippov  *  current --> +-----------------------+  |  |  |
380700ed07SMax Filippov  *		|  struct thread_info   |  |  |  |
390700ed07SMax Filippov  *		+-----------------------+ --------
400700ed07SMax Filippov  */
410700ed07SMax Filippov 
426a986984SMax Filippov #define NO_SYSCALL (-1)
436a986984SMax Filippov 
44367b8112SChris Zankel #ifndef __ASSEMBLY__
45367b8112SChris Zankel 
464573e398SChris Zankel #include <asm/coprocessor.h>
475b835d4cSMax Filippov #include <asm/core.h>
484573e398SChris Zankel 
49367b8112SChris Zankel /*
50367b8112SChris Zankel  * This struct defines the way the registers are stored on the
51367b8112SChris Zankel  * kernel stack during a system call or other kernel entry.
52367b8112SChris Zankel  */
53367b8112SChris Zankel struct pt_regs {
54367b8112SChris Zankel 	unsigned long pc;		/*   4 */
55367b8112SChris Zankel 	unsigned long ps;		/*   8 */
56367b8112SChris Zankel 	unsigned long depc;		/*  12 */
57367b8112SChris Zankel 	unsigned long exccause;		/*  16 */
58367b8112SChris Zankel 	unsigned long excvaddr;		/*  20 */
59367b8112SChris Zankel 	unsigned long debugcause;	/*  24 */
60367b8112SChris Zankel 	unsigned long wmask;		/*  28 */
61367b8112SChris Zankel 	unsigned long lbeg;		/*  32 */
62367b8112SChris Zankel 	unsigned long lend;		/*  36 */
63367b8112SChris Zankel 	unsigned long lcount;		/*  40 */
64367b8112SChris Zankel 	unsigned long sar;		/*  44 */
65367b8112SChris Zankel 	unsigned long windowbase;	/*  48 */
66367b8112SChris Zankel 	unsigned long windowstart;	/*  52 */
67367b8112SChris Zankel 	unsigned long syscall;		/*  56 */
68367b8112SChris Zankel 	unsigned long icountlevel;	/*  60 */
69733536b8SMax Filippov 	unsigned long scompare1;	/*  64 */
70c50842dfSChris Zankel 	unsigned long threadptr;	/*  68 */
71367b8112SChris Zankel 
72367b8112SChris Zankel 	/* Additional configurable registers that are used by the compiler. */
73367b8112SChris Zankel 	xtregs_opt_t xtregs_opt;
74367b8112SChris Zankel 
75367b8112SChris Zankel 	/* Make sure the areg field is 16 bytes aligned. */
76367b8112SChris Zankel 	int align[0] __attribute__ ((aligned(16)));
77367b8112SChris Zankel 
78367b8112SChris Zankel 	/* current register frame.
79367b8112SChris Zankel 	 * Note: The ESF for kernel exceptions ends after 16 registers!
80367b8112SChris Zankel 	 */
815b835d4cSMax Filippov 	unsigned long areg[XCHAL_NUM_AREGS];
82367b8112SChris Zankel };
83367b8112SChris Zankel 
846d75ca10SChristoph Hellwig # define arch_has_single_step()	(1)
85367b8112SChris Zankel # define task_pt_regs(tsk) ((struct pt_regs*) \
865b835d4cSMax Filippov 	(task_stack_page(tsk) + KERNEL_STACK_SIZE) - 1)
87367b8112SChris Zankel # define user_mode(regs) (((regs)->ps & 0x00000020)!=0)
88367b8112SChris Zankel # define instruction_pointer(regs) ((regs)->pc)
89f615136cSMax Filippov # define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \
90*ef31b464SMax Filippov 					       (regs)->pc))
91367b8112SChris Zankel 
92367b8112SChris Zankel # ifndef CONFIG_SMP
93367b8112SChris Zankel #  define profile_pc(regs) instruction_pointer(regs)
94f615136cSMax Filippov # else
95f615136cSMax Filippov #  define profile_pc(regs)						\
96f615136cSMax Filippov 	({								\
97f615136cSMax Filippov 		in_lock_functions(instruction_pointer(regs)) ?		\
98f615136cSMax Filippov 		return_pointer(regs) : instruction_pointer(regs);	\
99f615136cSMax Filippov 	})
100367b8112SChris Zankel # endif
101367b8112SChris Zankel 
1025208ba24SAl Viro #define user_stack_pointer(regs) ((regs)->areg[1])
1035208ba24SAl Viro 
regs_return_value(struct pt_regs * regs)104af5395c2SMax Filippov static inline unsigned long regs_return_value(struct pt_regs *regs)
105af5395c2SMax Filippov {
106af5395c2SMax Filippov 	return regs->areg[2];
107af5395c2SMax Filippov }
108af5395c2SMax Filippov 
1098cf543c0SRandy Dunlap int do_syscall_trace_enter(struct pt_regs *regs);
1108cf543c0SRandy Dunlap void do_syscall_trace_leave(struct pt_regs *regs);
1118cf543c0SRandy Dunlap 
112367b8112SChris Zankel #else	/* __ASSEMBLY__ */
113367b8112SChris Zankel 
114367b8112SChris Zankel # include <asm/asm-offsets.h>
115367b8112SChris Zankel #define PT_REGS_OFFSET	  (KERNEL_STACK_SIZE - PT_USER_SIZE)
116367b8112SChris Zankel 
117367b8112SChris Zankel #endif	/* !__ASSEMBLY__ */
118367b8112SChris Zankel 
119367b8112SChris Zankel #endif	/* _XTENSA_PTRACE_H */
120