3 * Copyright IBM Corp. 1999, 2000
4 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
9 #include <uapi/asm/ptrace.h>
11 #define PIF_SYSCALL 0 /* inside a system call */
12 #define PIF_PER_TRAP 1 /* deliver sigtrap on return to user */
14 #define _PIF_SYSCALL (1<<PIF_SYSCALL)
15 #define _PIF_PER_TRAP (1<<PIF_PER_TRAP)
19 #define PSW_KERNEL_BITS (PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_ASC_HOME | \
20 PSW_MASK_EA | PSW_MASK_BA)
21 #define PSW_USER_BITS (PSW_MASK_DAT | PSW_MASK_IO | PSW_MASK_EXT | \
22 PSW_DEFAULT_KEY | PSW_MASK_BASE | PSW_MASK_MCHECK | \
23 PSW_MASK_PSTATE | PSW_ASC_PRIMARY)
26 * The pt_regs struct defines the way the registers are stored on
27 * the stack during a system call.
31 unsigned long args[1];
33 unsigned long gprs[NUM_GPRS];
34 unsigned long orig_gpr2;
35 unsigned int int_code;
36 unsigned int int_parm;
37 unsigned long int_parm_long;
42 * Program event recording (PER) register set.
45 unsigned long control; /* PER control bits */
46 unsigned long start; /* PER starting address */
47 unsigned long end; /* PER ending address */
51 * PER event contains information about the cause of the last PER exception.
54 unsigned short cause; /* PER code, ATMID and AI */
55 unsigned long address; /* PER address */
56 unsigned char paid; /* PER access identification */
60 * Simplified per_info structure used to decode the ptrace user space ABI.
62 struct per_struct_kernel {
63 unsigned long cr9; /* PER control bits */
64 unsigned long cr10; /* PER starting address */
65 unsigned long cr11; /* PER ending address */
66 unsigned long bits; /* Obsolete software bits */
67 unsigned long starting_addr; /* User specified start address */
68 unsigned long ending_addr; /* User specified end address */
69 unsigned short perc_atmid; /* PER trap ATMID */
70 unsigned long address; /* PER trap instruction address */
71 unsigned char access_id; /* PER trap access identification */
74 #define PER_EVENT_MASK 0xEB000000UL
76 #define PER_EVENT_BRANCH 0x80000000UL
77 #define PER_EVENT_IFETCH 0x40000000UL
78 #define PER_EVENT_STORE 0x20000000UL
79 #define PER_EVENT_STORE_REAL 0x08000000UL
80 #define PER_EVENT_TRANSACTION_END 0x02000000UL
81 #define PER_EVENT_NULLIFICATION 0x01000000UL
83 #define PER_CONTROL_MASK 0x00e00000UL
85 #define PER_CONTROL_BRANCH_ADDRESS 0x00800000UL
86 #define PER_CONTROL_SUSPENSION 0x00400000UL
87 #define PER_CONTROL_ALTERATION 0x00200000UL
89 static inline void set_pt_regs_flag(struct pt_regs *regs, int flag)
91 regs->flags |= (1U << flag);
94 static inline void clear_pt_regs_flag(struct pt_regs *regs, int flag)
96 regs->flags &= ~(1U << flag);
99 static inline int test_pt_regs_flag(struct pt_regs *regs, int flag)
101 return !!(regs->flags & (1U << flag));
105 * These are defined as per linux/ptrace.h, which see.
107 #define arch_has_single_step() (1)
108 #define arch_has_block_step() (1)
110 #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
111 #define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
112 #define user_stack_pointer(regs)((regs)->gprs[15])
113 #define profile_pc(regs) instruction_pointer(regs)
115 static inline long regs_return_value(struct pt_regs *regs)
117 return regs->gprs[2];
120 int regs_query_register_offset(const char *name);
121 const char *regs_query_register_name(unsigned int offset);
122 unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset);
123 unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n);
125 static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
127 return regs->gprs[15] & PSW_ADDR_INSN;
130 #endif /* __ASSEMBLY__ */
131 #endif /* _S390_PTRACE_H */