• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Author: Chong Qiao <qiaochong@loongson.cn>
4  *         Huacai Chen <chenhuacai@loongson.cn>
5  *
6  * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
7  */
8 #ifndef _ASM_WATCH_H
9 #define _ASM_WATCH_H
10 
11 #include <linux/bitops.h>
12 
13 #include <asm/loongarchregs.h>
14 
15 unsigned long watch_csrrd(unsigned int reg);
16 void watch_csrwr(unsigned long val, unsigned int reg);
17 
18 void loongarch_probe_watch_registers(struct cpuinfo_loongarch *c);
19 void loongarch_clear_watch_registers(void);
20 void loongarch_install_watch_registers(struct task_struct *t);
21 void loongarch_clear_prev_watch_registers(struct task_struct *prev);
22 void loongarch_install_next_watch_registers(struct task_struct *next);
23 void loongarch_read_watch_registers(struct pt_regs *regs);
24 void loongarch_update_watch_registers(struct task_struct *t);
25 
26 #ifdef CONFIG_HARDWARE_WATCHPOINTS
27 #define __process_watch(prev, next) do {				\
28 	if (test_bit(TIF_LOAD_WATCH, &task_thread_info(prev)->flags)	\
29 	    || test_bit(TIF_SINGLESTEP, &task_thread_info(prev)->flags)) \
30 		loongarch_clear_prev_watch_registers(prev);		\
31 	if (test_bit(TIF_LOAD_WATCH, &task_thread_info(prev)->flags)	\
32 	    || test_bit(TIF_SINGLESTEP, &task_thread_info(prev)->flags)) \
33 		loongarch_install_next_watch_registers(next);		\
34 } while (0)
35 #else
36 #define __process_watch(prev, next) do {} while (0)
37 #endif
38 
39 #endif /* _ASM_WATCH_H */
40