0001
0002
0003 #ifndef __ASM_CSKY_PTRACE_H
0004 #define __ASM_CSKY_PTRACE_H
0005
0006 #include <uapi/asm/ptrace.h>
0007 #include <asm/traps.h>
0008 #include <linux/types.h>
0009 #include <linux/compiler.h>
0010
0011 #ifndef __ASSEMBLY__
0012
0013 #define PS_S 0x80000000
0014
0015 #define USR_BKPT 0x1464
0016
0017 #define arch_has_single_step() (1)
0018 #define current_pt_regs() \
0019 ({ (struct pt_regs *)((char *)current_thread_info() + THREAD_SIZE) - 1; })
0020
0021 #define user_stack_pointer(regs) ((regs)->usp)
0022
0023 #define user_mode(regs) (!((regs)->sr & PS_S))
0024 #define instruction_pointer(regs) ((regs)->pc)
0025 #define profile_pc(regs) instruction_pointer(regs)
0026 #define trap_no(regs) ((regs->sr >> 16) & 0xff)
0027
0028 static inline void instruction_pointer_set(struct pt_regs *regs,
0029 unsigned long val)
0030 {
0031 regs->pc = val;
0032 }
0033
0034 #if defined(__CSKYABIV2__)
0035 #define MAX_REG_OFFSET offsetof(struct pt_regs, dcsr)
0036 #else
0037 #define MAX_REG_OFFSET offsetof(struct pt_regs, regs[9])
0038 #endif
0039
0040 static inline bool in_syscall(struct pt_regs const *regs)
0041 {
0042 return ((regs->sr >> 16) & 0xff) == VEC_TRAP0;
0043 }
0044
0045 static inline void forget_syscall(struct pt_regs *regs)
0046 {
0047 regs->sr &= ~(0xff << 16);
0048 }
0049
0050 static inline unsigned long regs_return_value(struct pt_regs *regs)
0051 {
0052 return regs->a0;
0053 }
0054
0055 static inline void regs_set_return_value(struct pt_regs *regs,
0056 unsigned long val)
0057 {
0058 regs->a0 = val;
0059 }
0060
0061
0062 static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
0063 {
0064 return regs->usp;
0065 }
0066
0067 static inline unsigned long frame_pointer(struct pt_regs *regs)
0068 {
0069 return regs->regs[4];
0070 }
0071 static inline void frame_pointer_set(struct pt_regs *regs,
0072 unsigned long val)
0073 {
0074 regs->regs[4] = val;
0075 }
0076
0077 extern int regs_query_register_offset(const char *name);
0078 extern unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
0079 unsigned int n);
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 static inline unsigned long regs_get_register(struct pt_regs *regs,
0091 unsigned int offset)
0092 {
0093 if (unlikely(offset > MAX_REG_OFFSET))
0094 return 0;
0095
0096 return *(unsigned long *)((unsigned long)regs + offset);
0097 }
0098
0099 #endif
0100 #endif