2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
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.
8 * Amit Bhor, Sameer Dhavale: Codito Technologies 2004
10 #ifndef __ASM_ARC_PTRACE_H
11 #define __ASM_ARC_PTRACE_H
13 #include <uapi/asm/ptrace.h>
17 /* THE pt_regs: Defines how regs are saved during entry into kernel */
21 * 1 word gutter after reg-file has been saved
22 * Technically not needed, Since SP always points to a "full" location
23 * (vs. "empty"). But pt_regs is shared with tools....
28 long bta; /* bta_l1, bta_l2, erbta */
32 long status32; /* status32_l1, status32_l2, erstatus */
33 long ret; /* ilink1, ilink2 or eret */
50 long sp; /* user/kernel sp depending on where we came from */
53 /*to distinguish bet excp, syscall, irq */
55 #ifdef CONFIG_CPU_BIG_ENDIAN
56 /* so that assembly code is same for LE/BE */
57 unsigned long orig_r8:16, event:16;
59 unsigned long event:16, orig_r8:16;
65 /* Callee saved registers - need to be saved only when you are scheduled out */
68 long res; /* Again this is not needed */
84 #define instruction_pointer(regs) ((regs)->ret)
85 #define profile_pc(regs) instruction_pointer(regs)
87 /* return 1 if user mode or 0 if kernel mode */
88 #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
90 #define user_stack_pointer(regs)\
92 if (user_mode(regs)) \
99 /* return 1 if PC in delay slot */
100 #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
102 #define in_syscall(regs) (regs->event & orig_r8_IS_SCALL)
103 #define in_brkpt_trap(regs) (regs->event & orig_r8_IS_BRKPT)
105 #define syscall_wont_restart(regs) (regs->event |= orig_r8_IS_SCALL_RESTARTED)
106 #define syscall_restartable(regs) !(regs->event & orig_r8_IS_SCALL_RESTARTED)
108 #define current_pt_regs() \
110 /* open-coded current_thread_info() */ \
111 register unsigned long sp asm ("sp"); \
112 unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \
113 (struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1; \
116 static inline long regs_return_value(struct pt_regs *regs)
121 #endif /* !__ASSEMBLY__ */
123 #define orig_r8_IS_SCALL 0x0001
124 #define orig_r8_IS_SCALL_RESTARTED 0x0002
125 #define orig_r8_IS_BRKPT 0x0004
126 #define orig_r8_IS_EXCPN 0x0008
127 #define orig_r8_IS_IRQ1 0x0010
128 #define orig_r8_IS_IRQ2 0x0020
130 #endif /* __ASM_PTRACE_H */