Merge remote-tracking branches 'asoc/topic/sta529', 'asoc/topic/sti', 'asoc/topic...
[sfrench/cifs-2.6.git] / arch / arc / include / asm / ptrace.h
1 /*
2  * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
9  */
10 #ifndef __ASM_ARC_PTRACE_H
11 #define __ASM_ARC_PTRACE_H
12
13 #include <uapi/asm/ptrace.h>
14
15 #ifndef __ASSEMBLY__
16
17 /* THE pt_regs: Defines how regs are saved during entry into kernel */
18
19 #ifdef CONFIG_ISA_ARCOMPACT
20 struct pt_regs {
21
22         /* Real registers */
23         unsigned long bta;      /* bta_l1, bta_l2, erbta */
24
25         unsigned long lp_start, lp_end, lp_count;
26
27         unsigned long status32; /* status32_l1, status32_l2, erstatus */
28         unsigned long ret;      /* ilink1, ilink2 or eret */
29         unsigned long blink;
30         unsigned long fp;
31         unsigned long r26;      /* gp */
32
33         unsigned long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0;
34
35         unsigned long sp;       /* User/Kernel depending on where we came from */
36         unsigned long orig_r0;
37
38         /*
39          * To distinguish bet excp, syscall, irq
40          * For traps and exceptions, Exception Cause Register.
41          *      ECR: <00> <VV> <CC> <PP>
42          *      Last word used by Linux for extra state mgmt (syscall-restart)
43          * For interrupts, use artificial ECR values to note current prio-level
44          */
45         union {
46                 struct {
47 #ifdef CONFIG_CPU_BIG_ENDIAN
48                         unsigned long state:8, ecr_vec:8,
49                                       ecr_cause:8, ecr_param:8;
50 #else
51                         unsigned long ecr_param:8, ecr_cause:8,
52                                       ecr_vec:8, state:8;
53 #endif
54                 };
55                 unsigned long event;
56         };
57
58         unsigned long user_r25;
59 };
60 #else
61
62 struct pt_regs {
63
64         unsigned long orig_r0;
65
66         union {
67                 struct {
68 #ifdef CONFIG_CPU_BIG_ENDIAN
69                         unsigned long state:8, ecr_vec:8,
70                                       ecr_cause:8, ecr_param:8;
71 #else
72                         unsigned long ecr_param:8, ecr_cause:8,
73                                       ecr_vec:8, state:8;
74 #endif
75                 };
76                 unsigned long event;
77         };
78
79         unsigned long bta;      /* bta_l1, bta_l2, erbta */
80
81         unsigned long user_r25;
82
83         unsigned long r26;      /* gp */
84         unsigned long fp;
85         unsigned long sp;       /* user/kernel sp depending on where we came from  */
86
87         unsigned long r12, r30;
88
89         /*------- Below list auto saved by h/w -----------*/
90         unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11;
91
92         unsigned long blink;
93         unsigned long lp_end, lp_start, lp_count;
94
95         unsigned long ei, ldi, jli;
96
97         unsigned long ret;
98         unsigned long status32;
99 };
100
101 #endif
102
103 /* Callee saved registers - need to be saved only when you are scheduled out */
104
105 struct callee_regs {
106         unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
107 };
108
109 #define instruction_pointer(regs)       ((regs)->ret)
110 #define profile_pc(regs)                instruction_pointer(regs)
111
112 /* return 1 if user mode or 0 if kernel mode */
113 #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
114
115 #define user_stack_pointer(regs)\
116 ({  unsigned int sp;            \
117         if (user_mode(regs))    \
118                 sp = (regs)->sp;\
119         else                    \
120                 sp = -1;        \
121         sp;                     \
122 })
123
124 /* return 1 if PC in delay slot */
125 #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
126
127 #define in_syscall(regs)    ((regs->ecr_vec == ECR_V_TRAP) && !regs->ecr_param)
128 #define in_brkpt_trap(regs) ((regs->ecr_vec == ECR_V_TRAP) && regs->ecr_param)
129
130 #define STATE_SCALL_RESTARTED   0x01
131
132 #define syscall_wont_restart(reg) (reg->state |= STATE_SCALL_RESTARTED)
133 #define syscall_restartable(reg) !(reg->state &  STATE_SCALL_RESTARTED)
134
135 #define current_pt_regs()                                       \
136 ({                                                              \
137         /* open-coded current_thread_info() */                  \
138         register unsigned long sp asm ("sp");                   \
139         unsigned long pg_start = (sp & ~(THREAD_SIZE - 1));     \
140         (struct pt_regs *)(pg_start + THREAD_SIZE) - 1; \
141 })
142
143 static inline long regs_return_value(struct pt_regs *regs)
144 {
145         return (long)regs->r0;
146 }
147
148 #endif /* !__ASSEMBLY__ */
149
150 #endif /* __ASM_PTRACE_H */