]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/s390/include/asm/ptrace.h
Merge tag 'jfs-3.16' of git://github.com/kleikamp/linux-shaggy into next
[karo-tx-linux.git] / arch / s390 / include / asm / ptrace.h
1 /*
2  *  S390 version
3  *    Copyright IBM Corp. 1999, 2000
4  *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
5  */
6 #ifndef _S390_PTRACE_H
7 #define _S390_PTRACE_H
8
9 #include <uapi/asm/ptrace.h>
10
11 #define PIF_SYSCALL             0       /* inside a system call */
12 #define PIF_PER_TRAP            1       /* deliver sigtrap on return to user */
13
14 #define _PIF_SYSCALL            (1<<PIF_SYSCALL)
15 #define _PIF_PER_TRAP           (1<<PIF_PER_TRAP)
16
17 #ifndef __ASSEMBLY__
18
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)
24
25 /*
26  * The pt_regs struct defines the way the registers are stored on
27  * the stack during a system call.
28  */
29 struct pt_regs 
30 {
31         unsigned long args[1];
32         psw_t psw;
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;
38         unsigned long flags;
39 };
40
41 /*
42  * Program event recording (PER) register set.
43  */
44 struct per_regs {
45         unsigned long control;          /* PER control bits */
46         unsigned long start;            /* PER starting address */
47         unsigned long end;              /* PER ending address */
48 };
49
50 /*
51  * PER event contains information about the cause of the last PER exception.
52  */
53 struct per_event {
54         unsigned short cause;           /* PER code, ATMID and AI */
55         unsigned long address;          /* PER address */
56         unsigned char paid;             /* PER access identification */
57 };
58
59 /*
60  * Simplified per_info structure used to decode the ptrace user space ABI.
61  */
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 */
72 };
73
74 #define PER_EVENT_MASK                  0xEB000000UL
75
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
82
83 #define PER_CONTROL_MASK                0x00e00000UL
84
85 #define PER_CONTROL_BRANCH_ADDRESS      0x00800000UL
86 #define PER_CONTROL_SUSPENSION          0x00400000UL
87 #define PER_CONTROL_ALTERATION          0x00200000UL
88
89 static inline void set_pt_regs_flag(struct pt_regs *regs, int flag)
90 {
91         regs->flags |= (1U << flag);
92 }
93
94 static inline void clear_pt_regs_flag(struct pt_regs *regs, int flag)
95 {
96         regs->flags &= ~(1U << flag);
97 }
98
99 static inline int test_pt_regs_flag(struct pt_regs *regs, int flag)
100 {
101         return !!(regs->flags & (1U << flag));
102 }
103
104 /*
105  * These are defined as per linux/ptrace.h, which see.
106  */
107 #define arch_has_single_step()  (1)
108 #define arch_has_block_step()   (1)
109
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)
114
115 static inline long regs_return_value(struct pt_regs *regs)
116 {
117         return regs->gprs[2];
118 }
119
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);
124
125 static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
126 {
127         return regs->gprs[15] & PSW_ADDR_INSN;
128 }
129
130 #endif /* __ASSEMBLY__ */
131 #endif /* _S390_PTRACE_H */