1 #ifndef __ASM_SH_HW_BREAKPOINT_H
2 #define __ASM_SH_HW_BREAKPOINT_H
3 
4 #include <linux/kdebug.h>
5 #include <linux/types.h>
6 
7 #ifdef __KERNEL__
8 #define __ARCH_HW_BREAKPOINT_H
9 
10 struct arch_hw_breakpoint {
11 	char		*name; /* Contains name of the symbol to set bkpt */
12 	unsigned long	address;
13 	u16		len;
14 	u16		type;
15 };
16 
17 enum {
18 	SH_BREAKPOINT_READ	= (1 << 1),
19 	SH_BREAKPOINT_WRITE	= (1 << 2),
20 	SH_BREAKPOINT_RW	= SH_BREAKPOINT_READ | SH_BREAKPOINT_WRITE,
21 
22 	SH_BREAKPOINT_LEN_1	= (1 << 12),
23 	SH_BREAKPOINT_LEN_2	= (1 << 13),
24 	SH_BREAKPOINT_LEN_4	= SH_BREAKPOINT_LEN_1 | SH_BREAKPOINT_LEN_2,
25 	SH_BREAKPOINT_LEN_8	= (1 << 14),
26 };
27 
28 struct sh_ubc {
29 	const char	*name;
30 	unsigned int	num_events;
31 	unsigned int	trap_nr;
32 	void		(*enable)(struct arch_hw_breakpoint *, int);
33 	void		(*disable)(struct arch_hw_breakpoint *, int);
34 	void		(*enable_all)(unsigned long);
35 	void		(*disable_all)(void);
36 	unsigned long	(*active_mask)(void);
37 	unsigned long	(*triggered_mask)(void);
38 	void		(*clear_triggered_mask)(unsigned long);
39 	struct clk	*clk;	/* optional interface clock / MSTP bit */
40 };
41 
42 struct perf_event;
43 struct task_struct;
44 struct pmu;
45 
46 /* Maximum number of UBC channels */
47 #define HBP_NUM		2
48 
49 /* arch/sh/kernel/hw_breakpoint.c */
50 extern int arch_check_va_in_userspace(unsigned long va, u16 hbp_len);
51 extern int arch_validate_hwbkpt_settings(struct perf_event *bp,
52 					 struct task_struct *tsk);
53 extern int hw_breakpoint_exceptions_notify(struct notifier_block *unused,
54 					   unsigned long val, void *data);
55 
56 int arch_install_hw_breakpoint(struct perf_event *bp);
57 void arch_uninstall_hw_breakpoint(struct perf_event *bp);
58 void hw_breakpoint_pmu_read(struct perf_event *bp);
59 void hw_breakpoint_pmu_unthrottle(struct perf_event *bp);
60 
61 extern void arch_fill_perf_breakpoint(struct perf_event *bp);
62 extern int register_sh_ubc(struct sh_ubc *);
63 
64 extern struct pmu perf_ops_bp;
65 
66 #endif /* __KERNEL__ */
67 #endif /* __ASM_SH_HW_BREAKPOINT_H */
68