Frederic Weisbecker | 2da3e16 | 2009-11-05 23:06:50 +0100 | [diff] [blame] | 1 | #ifndef _LINUX_HW_BREAKPOINT_H |
| 2 | #define _LINUX_HW_BREAKPOINT_H |
K.Prasad | b332828c | 2009-06-01 23:43:10 +0530 | [diff] [blame] | 3 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 4 | #include <linux/perf_event.h> |
K.Prasad | b332828c | 2009-06-01 23:43:10 +0530 | [diff] [blame] | 5 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 6 | enum { |
| 7 | HW_BREAKPOINT_LEN_1 = 1, |
| 8 | HW_BREAKPOINT_LEN_2 = 2, |
| 9 | HW_BREAKPOINT_LEN_4 = 4, |
| 10 | HW_BREAKPOINT_LEN_8 = 8, |
K.Prasad | b332828c | 2009-06-01 23:43:10 +0530 | [diff] [blame] | 11 | }; |
| 12 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 13 | enum { |
| 14 | HW_BREAKPOINT_R = 1, |
| 15 | HW_BREAKPOINT_W = 2, |
| 16 | HW_BREAKPOINT_X = 4, |
| 17 | }; |
K.Prasad | b332828c | 2009-06-01 23:43:10 +0530 | [diff] [blame] | 18 | |
Frederic Weisbecker | 5093eba | 2009-11-22 05:21:35 +0100 | [diff] [blame^] | 19 | #ifdef __KERNEL__ |
Ingo Molnar | 688bcaf | 2009-11-14 01:12:47 +0100 | [diff] [blame] | 20 | #ifdef CONFIG_HAVE_HW_BREAKPOINT |
| 21 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 22 | static inline unsigned long hw_breakpoint_addr(struct perf_event *bp) |
| 23 | { |
| 24 | return bp->attr.bp_addr; |
| 25 | } |
| 26 | |
| 27 | static inline int hw_breakpoint_type(struct perf_event *bp) |
| 28 | { |
| 29 | return bp->attr.bp_type; |
| 30 | } |
| 31 | |
| 32 | static inline int hw_breakpoint_len(struct perf_event *bp) |
| 33 | { |
| 34 | return bp->attr.bp_len; |
| 35 | } |
| 36 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 37 | extern struct perf_event * |
| 38 | register_user_hw_breakpoint(unsigned long addr, |
| 39 | int len, |
| 40 | int type, |
| 41 | perf_callback_t triggered, |
| 42 | struct task_struct *tsk, |
| 43 | bool active); |
| 44 | |
| 45 | /* FIXME: only change from the attr, and don't unregister */ |
| 46 | extern struct perf_event * |
| 47 | modify_user_hw_breakpoint(struct perf_event *bp, |
| 48 | unsigned long addr, |
| 49 | int len, |
| 50 | int type, |
| 51 | perf_callback_t triggered, |
| 52 | struct task_struct *tsk, |
| 53 | bool active); |
| 54 | |
K.Prasad | b332828c | 2009-06-01 23:43:10 +0530 | [diff] [blame] | 55 | /* |
| 56 | * Kernel breakpoints are not associated with any particular thread. |
| 57 | */ |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 58 | extern struct perf_event * |
| 59 | register_wide_hw_breakpoint_cpu(unsigned long addr, |
| 60 | int len, |
| 61 | int type, |
| 62 | perf_callback_t triggered, |
| 63 | int cpu, |
| 64 | bool active); |
K.Prasad | b332828c | 2009-06-01 23:43:10 +0530 | [diff] [blame] | 65 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 66 | extern struct perf_event ** |
| 67 | register_wide_hw_breakpoint(unsigned long addr, |
| 68 | int len, |
| 69 | int type, |
| 70 | perf_callback_t triggered, |
| 71 | bool active); |
K.Prasad | b332828c | 2009-06-01 23:43:10 +0530 | [diff] [blame] | 72 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 73 | extern int register_perf_hw_breakpoint(struct perf_event *bp); |
| 74 | extern int __register_perf_hw_breakpoint(struct perf_event *bp); |
| 75 | extern void unregister_hw_breakpoint(struct perf_event *bp); |
| 76 | extern void unregister_wide_hw_breakpoint(struct perf_event **cpu_events); |
| 77 | |
| 78 | extern int reserve_bp_slot(struct perf_event *bp); |
| 79 | extern void release_bp_slot(struct perf_event *bp); |
| 80 | |
| 81 | extern void flush_ptrace_hw_breakpoint(struct task_struct *tsk); |
| 82 | |
Frederic Weisbecker | 687b16f | 2009-11-13 13:16:15 +0100 | [diff] [blame] | 83 | static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp) |
| 84 | { |
| 85 | return &bp->hw.info; |
| 86 | } |
| 87 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 88 | #else /* !CONFIG_HAVE_HW_BREAKPOINT */ |
| 89 | |
| 90 | static inline struct perf_event * |
| 91 | register_user_hw_breakpoint(unsigned long addr, |
| 92 | int len, |
| 93 | int type, |
| 94 | perf_callback_t triggered, |
| 95 | struct task_struct *tsk, |
| 96 | bool active) { return NULL; } |
| 97 | static inline struct perf_event * |
| 98 | modify_user_hw_breakpoint(struct perf_event *bp, |
| 99 | unsigned long addr, |
| 100 | int len, |
| 101 | int type, |
| 102 | perf_callback_t triggered, |
| 103 | struct task_struct *tsk, |
| 104 | bool active) { return NULL; } |
| 105 | static inline struct perf_event * |
| 106 | register_wide_hw_breakpoint_cpu(unsigned long addr, |
| 107 | int len, |
| 108 | int type, |
| 109 | perf_callback_t triggered, |
| 110 | int cpu, |
| 111 | bool active) { return NULL; } |
| 112 | static inline struct perf_event ** |
| 113 | register_wide_hw_breakpoint(unsigned long addr, |
| 114 | int len, |
| 115 | int type, |
| 116 | perf_callback_t triggered, |
| 117 | bool active) { return NULL; } |
| 118 | static inline int |
| 119 | register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } |
| 120 | static inline int |
| 121 | __register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } |
| 122 | static inline void unregister_hw_breakpoint(struct perf_event *bp) { } |
| 123 | static inline void |
| 124 | unregister_wide_hw_breakpoint(struct perf_event **cpu_events) { } |
| 125 | static inline int |
| 126 | reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; } |
| 127 | static inline void release_bp_slot(struct perf_event *bp) { } |
| 128 | |
| 129 | static inline void flush_ptrace_hw_breakpoint(struct task_struct *tsk) { } |
| 130 | |
Frederic Weisbecker | 687b16f | 2009-11-13 13:16:15 +0100 | [diff] [blame] | 131 | static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp) |
| 132 | { |
| 133 | return NULL; |
| 134 | } |
| 135 | |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 136 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ |
Frederic Weisbecker | 5093eba | 2009-11-22 05:21:35 +0100 | [diff] [blame^] | 137 | #endif /* __KERNEL__ */ |
Frederic Weisbecker | 24f1e32c | 2009-09-09 19:22:48 +0200 | [diff] [blame] | 138 | |
| 139 | #endif /* _LINUX_HW_BREAKPOINT_H */ |