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 */
56 #ifdef CONFIG_CPU_BIG_ENDIAN
57 /* so that assembly code is same for LE/BE */
58 unsigned long orig_r8
:16, event
:16;
60 unsigned long event
:16, orig_r8
:16;
67 /* Callee saved registers - need to be saved only when you are scheduled out */
70 long res
; /* Again this is not needed */
86 #define instruction_pointer(regs) ((regs)->ret)
87 #define profile_pc(regs) instruction_pointer(regs)
89 /* return 1 if user mode or 0 if kernel mode */
90 #define user_mode(regs) (regs->status32 & STATUS_U_MASK)
92 #define user_stack_pointer(regs)\
94 if (user_mode(regs)) \
101 /* return 1 if PC in delay slot */
102 #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK)
104 #define in_syscall(regs) (regs->event & orig_r8_IS_SCALL)
105 #define in_brkpt_trap(regs) (regs->event & orig_r8_IS_BRKPT)
107 #define syscall_wont_restart(regs) (regs->event |= orig_r8_IS_SCALL_RESTARTED)
108 #define syscall_restartable(regs) !(regs->event & orig_r8_IS_SCALL_RESTARTED)
110 #define current_pt_regs() \
112 /* open-coded current_thread_info() */ \
113 register unsigned long sp asm ("sp"); \
114 unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \
115 (struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1; \
118 static inline long regs_return_value(struct pt_regs
*regs
)
123 #endif /* !__ASSEMBLY__ */
125 #define orig_r8_IS_SCALL 0x0001
126 #define orig_r8_IS_SCALL_RESTARTED 0x0002
127 #define orig_r8_IS_BRKPT 0x0004
128 #define orig_r8_IS_EXCPN 0x0008
129 #define orig_r8_IS_IRQ1 0x0010
130 #define orig_r8_IS_IRQ2 0x0020
132 #endif /* __ASM_PTRACE_H */