printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / hw_breakpoint.h
blobdb199d653dd1ae1a43137993c01012de6df624e8
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_HW_BREAKPOINT_H
3 #define _LINUX_HW_BREAKPOINT_H
5 #include <linux/perf_event.h>
6 #include <uapi/linux/hw_breakpoint.h>
8 #ifdef CONFIG_HAVE_HW_BREAKPOINT
10 enum bp_type_idx {
11 TYPE_INST = 0,
12 #if defined(CONFIG_HAVE_MIXED_BREAKPOINTS_REGS)
13 TYPE_DATA = 0,
14 #else
15 TYPE_DATA = 1,
16 #endif
17 TYPE_MAX
20 extern int __init init_hw_breakpoint(void);
22 static inline void hw_breakpoint_init(struct perf_event_attr *attr)
24 memset(attr, 0, sizeof(*attr));
26 attr->type = PERF_TYPE_BREAKPOINT;
27 attr->size = sizeof(*attr);
29 * As it's for in-kernel or ptrace use, we want it to be pinned
30 * and to call its callback every hits.
32 attr->pinned = 1;
33 attr->sample_period = 1;
36 static inline void ptrace_breakpoint_init(struct perf_event_attr *attr)
38 hw_breakpoint_init(attr);
39 attr->exclude_kernel = 1;
42 static inline unsigned long hw_breakpoint_addr(struct perf_event *bp)
44 return bp->attr.bp_addr;
47 static inline int hw_breakpoint_type(struct perf_event *bp)
49 return bp->attr.bp_type;
52 static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
54 return bp->attr.bp_len;
57 extern struct perf_event *
58 register_user_hw_breakpoint(struct perf_event_attr *attr,
59 perf_overflow_handler_t triggered,
60 void *context,
61 struct task_struct *tsk);
63 /* FIXME: only change from the attr, and don't unregister */
64 extern int
65 modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr);
66 extern int
67 modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr,
68 bool check);
71 * Kernel breakpoints are not associated with any particular thread.
73 extern struct perf_event *
74 register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
75 perf_overflow_handler_t triggered,
76 void *context,
77 int cpu);
79 extern struct perf_event * __percpu *
80 register_wide_hw_breakpoint(struct perf_event_attr *attr,
81 perf_overflow_handler_t triggered,
82 void *context);
84 extern int register_perf_hw_breakpoint(struct perf_event *bp);
85 extern void unregister_hw_breakpoint(struct perf_event *bp);
86 extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events);
87 extern bool hw_breakpoint_is_used(void);
89 extern int dbg_reserve_bp_slot(struct perf_event *bp);
90 extern int dbg_release_bp_slot(struct perf_event *bp);
91 extern int reserve_bp_slot(struct perf_event *bp);
92 extern void release_bp_slot(struct perf_event *bp);
94 extern void flush_ptrace_hw_breakpoint(struct task_struct *tsk);
96 static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
98 return &bp->hw.info;
101 #else /* !CONFIG_HAVE_HW_BREAKPOINT */
103 static inline int __init init_hw_breakpoint(void) { return 0; }
105 static inline struct perf_event *
106 register_user_hw_breakpoint(struct perf_event_attr *attr,
107 perf_overflow_handler_t triggered,
108 void *context,
109 struct task_struct *tsk) { return NULL; }
110 static inline int
111 modify_user_hw_breakpoint(struct perf_event *bp,
112 struct perf_event_attr *attr) { return -ENOSYS; }
113 static inline int
114 modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr,
115 bool check) { return -ENOSYS; }
117 static inline struct perf_event *
118 register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
119 perf_overflow_handler_t triggered,
120 void *context,
121 int cpu) { return NULL; }
122 static inline struct perf_event * __percpu *
123 register_wide_hw_breakpoint(struct perf_event_attr *attr,
124 perf_overflow_handler_t triggered,
125 void *context) { return NULL; }
126 static inline int
127 register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
128 static inline void unregister_hw_breakpoint(struct perf_event *bp) { }
129 static inline void
130 unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { }
131 static inline bool hw_breakpoint_is_used(void) { return false; }
133 static inline int
134 reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; }
135 static inline void release_bp_slot(struct perf_event *bp) { }
137 static inline void flush_ptrace_hw_breakpoint(struct task_struct *tsk) { }
139 static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
141 return NULL;
144 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
145 #endif /* _LINUX_HW_BREAKPOINT_H */