162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * include/asm-xtensa/ptrace.h 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 562306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 662306a36Sopenharmony_ci * for more details. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Copyright (C) 2001 - 2005 Tensilica Inc. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci#ifndef _XTENSA_PTRACE_H 1162306a36Sopenharmony_ci#define _XTENSA_PTRACE_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <asm/kmem_layout.h> 1462306a36Sopenharmony_ci#include <uapi/asm/ptrace.h> 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* 1762306a36Sopenharmony_ci * Kernel stack 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * +-----------------------+ -------- STACK_SIZE 2062306a36Sopenharmony_ci * | register file | | 2162306a36Sopenharmony_ci * +-----------------------+ | 2262306a36Sopenharmony_ci * | struct pt_regs | | 2362306a36Sopenharmony_ci * +-----------------------+ | ------ PT_REGS_OFFSET 2462306a36Sopenharmony_ci * double : 16 bytes spill area : | ^ 2562306a36Sopenharmony_ci * excetion :- - - - - - - - - - - -: | | 2662306a36Sopenharmony_ci * frame : struct pt_regs : | | 2762306a36Sopenharmony_ci * :- - - - - - - - - - - -: | | 2862306a36Sopenharmony_ci * | | | | 2962306a36Sopenharmony_ci * | memory stack | | | 3062306a36Sopenharmony_ci * | | | | 3162306a36Sopenharmony_ci * ~ ~ ~ ~ 3262306a36Sopenharmony_ci * ~ ~ ~ ~ 3362306a36Sopenharmony_ci * | | | | 3462306a36Sopenharmony_ci * | | | | 3562306a36Sopenharmony_ci * +-----------------------+ | | --- STACK_BIAS 3662306a36Sopenharmony_ci * | struct task_struct | | | ^ 3762306a36Sopenharmony_ci * current --> +-----------------------+ | | | 3862306a36Sopenharmony_ci * | struct thread_info | | | | 3962306a36Sopenharmony_ci * +-----------------------+ -------- 4062306a36Sopenharmony_ci */ 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define NO_SYSCALL (-1) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#include <asm/coprocessor.h> 4762306a36Sopenharmony_ci#include <asm/core.h> 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* 5062306a36Sopenharmony_ci * This struct defines the way the registers are stored on the 5162306a36Sopenharmony_ci * kernel stack during a system call or other kernel entry. 5262306a36Sopenharmony_ci */ 5362306a36Sopenharmony_cistruct pt_regs { 5462306a36Sopenharmony_ci unsigned long pc; /* 4 */ 5562306a36Sopenharmony_ci unsigned long ps; /* 8 */ 5662306a36Sopenharmony_ci unsigned long depc; /* 12 */ 5762306a36Sopenharmony_ci unsigned long exccause; /* 16 */ 5862306a36Sopenharmony_ci unsigned long excvaddr; /* 20 */ 5962306a36Sopenharmony_ci unsigned long debugcause; /* 24 */ 6062306a36Sopenharmony_ci unsigned long wmask; /* 28 */ 6162306a36Sopenharmony_ci unsigned long lbeg; /* 32 */ 6262306a36Sopenharmony_ci unsigned long lend; /* 36 */ 6362306a36Sopenharmony_ci unsigned long lcount; /* 40 */ 6462306a36Sopenharmony_ci unsigned long sar; /* 44 */ 6562306a36Sopenharmony_ci unsigned long windowbase; /* 48 */ 6662306a36Sopenharmony_ci unsigned long windowstart; /* 52 */ 6762306a36Sopenharmony_ci unsigned long syscall; /* 56 */ 6862306a36Sopenharmony_ci unsigned long icountlevel; /* 60 */ 6962306a36Sopenharmony_ci unsigned long scompare1; /* 64 */ 7062306a36Sopenharmony_ci unsigned long threadptr; /* 68 */ 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci /* Additional configurable registers that are used by the compiler. */ 7362306a36Sopenharmony_ci xtregs_opt_t xtregs_opt; 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci /* Make sure the areg field is 16 bytes aligned. */ 7662306a36Sopenharmony_ci int align[0] __attribute__ ((aligned(16))); 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci /* current register frame. 7962306a36Sopenharmony_ci * Note: The ESF for kernel exceptions ends after 16 registers! 8062306a36Sopenharmony_ci */ 8162306a36Sopenharmony_ci unsigned long areg[XCHAL_NUM_AREGS]; 8262306a36Sopenharmony_ci}; 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci# define arch_has_single_step() (1) 8562306a36Sopenharmony_ci# define task_pt_regs(tsk) ((struct pt_regs*) \ 8662306a36Sopenharmony_ci (task_stack_page(tsk) + KERNEL_STACK_SIZE) - 1) 8762306a36Sopenharmony_ci# define user_mode(regs) (((regs)->ps & 0x00000020)!=0) 8862306a36Sopenharmony_ci# define instruction_pointer(regs) ((regs)->pc) 8962306a36Sopenharmony_ci# define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \ 9062306a36Sopenharmony_ci (regs)->areg[1])) 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci# ifndef CONFIG_SMP 9362306a36Sopenharmony_ci# define profile_pc(regs) instruction_pointer(regs) 9462306a36Sopenharmony_ci# else 9562306a36Sopenharmony_ci# define profile_pc(regs) \ 9662306a36Sopenharmony_ci ({ \ 9762306a36Sopenharmony_ci in_lock_functions(instruction_pointer(regs)) ? \ 9862306a36Sopenharmony_ci return_pointer(regs) : instruction_pointer(regs); \ 9962306a36Sopenharmony_ci }) 10062306a36Sopenharmony_ci# endif 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci#define user_stack_pointer(regs) ((regs)->areg[1]) 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_cistatic inline unsigned long regs_return_value(struct pt_regs *regs) 10562306a36Sopenharmony_ci{ 10662306a36Sopenharmony_ci return regs->areg[2]; 10762306a36Sopenharmony_ci} 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ciint do_syscall_trace_enter(struct pt_regs *regs); 11062306a36Sopenharmony_civoid do_syscall_trace_leave(struct pt_regs *regs); 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci#else /* __ASSEMBLY__ */ 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci# include <asm/asm-offsets.h> 11562306a36Sopenharmony_ci#define PT_REGS_OFFSET (KERNEL_STACK_SIZE - PT_USER_SIZE) 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci#endif /* _XTENSA_PTRACE_H */ 120