blob: 62314791570cbdda16b7e575c2aa7fc48ed5d45a [file] [log] [blame]
Will Deacon478fcb22012-03-05 11:49:33 +00001/*
2 * Copyright (C) 2012 ARM Ltd.
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 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef __ASM_DEBUG_MONITORS_H
17#define __ASM_DEBUG_MONITORS_H
18
19#ifdef __KERNEL__
20
21#define DBG_ESR_EVT(x) (((x) >> 27) & 0x7)
22
23/* AArch64 */
24#define DBG_ESR_EVT_HWBP 0x0
25#define DBG_ESR_EVT_HWSS 0x1
26#define DBG_ESR_EVT_HWWP 0x2
27#define DBG_ESR_EVT_BRK 0x6
28
29enum debug_el {
30 DBG_ACTIVE_EL0 = 0,
31 DBG_ACTIVE_EL1,
32};
33
34/* AArch32 */
35#define DBG_ESR_EVT_BKPT 0x4
36#define DBG_ESR_EVT_VECC 0x5
37
38#define AARCH32_BREAK_ARM 0x07f001f0
39#define AARCH32_BREAK_THUMB 0xde01
40#define AARCH32_BREAK_THUMB2_LO 0xf7f0
41#define AARCH32_BREAK_THUMB2_HI 0xa000
42
43#ifndef __ASSEMBLY__
44struct task_struct;
45
46#define local_dbg_save(flags) \
47 do { \
48 typecheck(unsigned long, flags); \
49 asm volatile( \
50 "mrs %0, daif // local_dbg_save\n" \
51 "msr daifset, #8" \
52 : "=r" (flags) : : "memory"); \
53 } while (0)
54
55#define local_dbg_restore(flags) \
56 do { \
57 typecheck(unsigned long, flags); \
58 asm volatile( \
59 "msr daif, %0 // local_dbg_restore\n" \
60 : : "r" (flags) : "memory"); \
61 } while (0)
62
63#define DBG_ARCH_ID_RESERVED 0 /* In case of ptrace ABI updates. */
64
Sandeepa Prabhuee6214c2013-12-04 05:50:20 +000065#define DBG_HOOK_HANDLED 0
66#define DBG_HOOK_ERROR 1
67
68struct step_hook {
69 struct list_head node;
70 int (*fn)(struct pt_regs *regs, unsigned int esr);
71};
72
73void register_step_hook(struct step_hook *hook);
74void unregister_step_hook(struct step_hook *hook);
75
76struct break_hook {
77 struct list_head node;
78 u32 esr_val;
79 u32 esr_mask;
80 int (*fn)(struct pt_regs *regs, unsigned int esr);
81};
82
83void register_break_hook(struct break_hook *hook);
84void unregister_break_hook(struct break_hook *hook);
85
Will Deacon478fcb22012-03-05 11:49:33 +000086u8 debug_monitors_arch(void);
87
88void enable_debug_monitors(enum debug_el el);
89void disable_debug_monitors(enum debug_el el);
90
91void user_rewind_single_step(struct task_struct *task);
92void user_fastforward_single_step(struct task_struct *task);
93
94void kernel_enable_single_step(struct pt_regs *regs);
95void kernel_disable_single_step(void);
96int kernel_active_single_step(void);
97
98#ifdef CONFIG_HAVE_HW_BREAKPOINT
99int reinstall_suspended_bps(struct pt_regs *regs);
100#else
101static inline int reinstall_suspended_bps(struct pt_regs *regs)
102{
103 return -ENODEV;
104}
105#endif
106
Will Deacon1442b6e2013-03-16 08:48:13 +0000107int aarch32_break_handler(struct pt_regs *regs);
Will Deacon1442b6e2013-03-16 08:48:13 +0000108
Will Deacon478fcb22012-03-05 11:49:33 +0000109#endif /* __ASSEMBLY */
110#endif /* __KERNEL__ */
111#endif /* __ASM_DEBUG_MONITORS_H */