^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef _ASM_POWERPC_DEBUG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define _ASM_POWERPC_DEBUG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/hw_breakpoint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct pt_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC_CORE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) extern int (*__debugger)(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) extern int (*__debugger_ipi)(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) extern int (*__debugger_bpt)(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) extern int (*__debugger_sstep)(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) extern int (*__debugger_iabr_match)(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) extern int (*__debugger_break_match)(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) extern int (*__debugger_fault_handler)(struct pt_regs *regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define DEBUGGER_BOILERPLATE(__NAME) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static inline int __NAME(struct pt_regs *regs) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if (unlikely(__ ## __NAME)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) return __ ## __NAME(regs); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) return 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) DEBUGGER_BOILERPLATE(debugger)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) DEBUGGER_BOILERPLATE(debugger_ipi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) DEBUGGER_BOILERPLATE(debugger_bpt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) DEBUGGER_BOILERPLATE(debugger_sstep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) DEBUGGER_BOILERPLATE(debugger_iabr_match)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) DEBUGGER_BOILERPLATE(debugger_break_match)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) DEBUGGER_BOILERPLATE(debugger_fault_handler)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static inline int debugger(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static inline int debugger_ipi(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static inline int debugger_bpt(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static inline int debugger_sstep(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static inline int debugger_iabr_match(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static inline int debugger_break_match(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) void __set_breakpoint(int nr, struct arch_hw_breakpoint *brk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) bool ppc_breakpoint_available(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #ifdef CONFIG_PPC_ADV_DEBUG_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern void do_send_trap(struct pt_regs *regs, unsigned long address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) unsigned long error_code, int brkpt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) extern void do_break(struct pt_regs *regs, unsigned long address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) unsigned long error_code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #endif /* _ASM_POWERPC_DEBUG_H */