18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __ASM_SH_HW_BREAKPOINT_H 38c2ecf20Sopenharmony_ci#define __ASM_SH_HW_BREAKPOINT_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <uapi/asm/hw_breakpoint.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#define __ARCH_HW_BREAKPOINT_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/kdebug.h> 108c2ecf20Sopenharmony_ci#include <linux/types.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistruct arch_hw_breakpoint { 138c2ecf20Sopenharmony_ci unsigned long address; 148c2ecf20Sopenharmony_ci u16 len; 158c2ecf20Sopenharmony_ci u16 type; 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cienum { 198c2ecf20Sopenharmony_ci SH_BREAKPOINT_READ = (1 << 1), 208c2ecf20Sopenharmony_ci SH_BREAKPOINT_WRITE = (1 << 2), 218c2ecf20Sopenharmony_ci SH_BREAKPOINT_RW = SH_BREAKPOINT_READ | SH_BREAKPOINT_WRITE, 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci SH_BREAKPOINT_LEN_1 = (1 << 12), 248c2ecf20Sopenharmony_ci SH_BREAKPOINT_LEN_2 = (1 << 13), 258c2ecf20Sopenharmony_ci SH_BREAKPOINT_LEN_4 = SH_BREAKPOINT_LEN_1 | SH_BREAKPOINT_LEN_2, 268c2ecf20Sopenharmony_ci SH_BREAKPOINT_LEN_8 = (1 << 14), 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistruct sh_ubc { 308c2ecf20Sopenharmony_ci const char *name; 318c2ecf20Sopenharmony_ci unsigned int num_events; 328c2ecf20Sopenharmony_ci unsigned int trap_nr; 338c2ecf20Sopenharmony_ci void (*enable)(struct arch_hw_breakpoint *, int); 348c2ecf20Sopenharmony_ci void (*disable)(struct arch_hw_breakpoint *, int); 358c2ecf20Sopenharmony_ci void (*enable_all)(unsigned long); 368c2ecf20Sopenharmony_ci void (*disable_all)(void); 378c2ecf20Sopenharmony_ci unsigned long (*active_mask)(void); 388c2ecf20Sopenharmony_ci unsigned long (*triggered_mask)(void); 398c2ecf20Sopenharmony_ci void (*clear_triggered_mask)(unsigned long); 408c2ecf20Sopenharmony_ci struct clk *clk; /* optional interface clock / MSTP bit */ 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistruct perf_event_attr; 448c2ecf20Sopenharmony_cistruct perf_event; 458c2ecf20Sopenharmony_cistruct task_struct; 468c2ecf20Sopenharmony_cistruct pmu; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* Maximum number of UBC channels */ 498c2ecf20Sopenharmony_ci#define HBP_NUM 2 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistatic inline int hw_breakpoint_slots(int type) 528c2ecf20Sopenharmony_ci{ 538c2ecf20Sopenharmony_ci return HBP_NUM; 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* arch/sh/kernel/hw_breakpoint.c */ 578c2ecf20Sopenharmony_ciextern int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw); 588c2ecf20Sopenharmony_ciextern int hw_breakpoint_arch_parse(struct perf_event *bp, 598c2ecf20Sopenharmony_ci const struct perf_event_attr *attr, 608c2ecf20Sopenharmony_ci struct arch_hw_breakpoint *hw); 618c2ecf20Sopenharmony_ciextern int hw_breakpoint_exceptions_notify(struct notifier_block *unused, 628c2ecf20Sopenharmony_ci unsigned long val, void *data); 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ciint arch_install_hw_breakpoint(struct perf_event *bp); 658c2ecf20Sopenharmony_civoid arch_uninstall_hw_breakpoint(struct perf_event *bp); 668c2ecf20Sopenharmony_civoid hw_breakpoint_pmu_read(struct perf_event *bp); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciextern void arch_fill_perf_breakpoint(struct perf_event *bp); 698c2ecf20Sopenharmony_ciextern int register_sh_ubc(struct sh_ubc *); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciextern struct pmu perf_ops_bp; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#endif /* __ASM_SH_HW_BREAKPOINT_H */ 74