18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_DEBUG_H
68c2ecf20Sopenharmony_ci#define _ASM_POWERPC_DEBUG_H
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <asm/hw_breakpoint.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cistruct pt_regs;
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC_CORE)
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciextern int (*__debugger)(struct pt_regs *regs);
158c2ecf20Sopenharmony_ciextern int (*__debugger_ipi)(struct pt_regs *regs);
168c2ecf20Sopenharmony_ciextern int (*__debugger_bpt)(struct pt_regs *regs);
178c2ecf20Sopenharmony_ciextern int (*__debugger_sstep)(struct pt_regs *regs);
188c2ecf20Sopenharmony_ciextern int (*__debugger_iabr_match)(struct pt_regs *regs);
198c2ecf20Sopenharmony_ciextern int (*__debugger_break_match)(struct pt_regs *regs);
208c2ecf20Sopenharmony_ciextern int (*__debugger_fault_handler)(struct pt_regs *regs);
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define DEBUGGER_BOILERPLATE(__NAME) \
238c2ecf20Sopenharmony_cistatic inline int __NAME(struct pt_regs *regs) \
248c2ecf20Sopenharmony_ci{ \
258c2ecf20Sopenharmony_ci	if (unlikely(__ ## __NAME)) \
268c2ecf20Sopenharmony_ci		return __ ## __NAME(regs); \
278c2ecf20Sopenharmony_ci	return 0; \
288c2ecf20Sopenharmony_ci}
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciDEBUGGER_BOILERPLATE(debugger)
318c2ecf20Sopenharmony_ciDEBUGGER_BOILERPLATE(debugger_ipi)
328c2ecf20Sopenharmony_ciDEBUGGER_BOILERPLATE(debugger_bpt)
338c2ecf20Sopenharmony_ciDEBUGGER_BOILERPLATE(debugger_sstep)
348c2ecf20Sopenharmony_ciDEBUGGER_BOILERPLATE(debugger_iabr_match)
358c2ecf20Sopenharmony_ciDEBUGGER_BOILERPLATE(debugger_break_match)
368c2ecf20Sopenharmony_ciDEBUGGER_BOILERPLATE(debugger_fault_handler)
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#else
398c2ecf20Sopenharmony_cistatic inline int debugger(struct pt_regs *regs) { return 0; }
408c2ecf20Sopenharmony_cistatic inline int debugger_ipi(struct pt_regs *regs) { return 0; }
418c2ecf20Sopenharmony_cistatic inline int debugger_bpt(struct pt_regs *regs) { return 0; }
428c2ecf20Sopenharmony_cistatic inline int debugger_sstep(struct pt_regs *regs) { return 0; }
438c2ecf20Sopenharmony_cistatic inline int debugger_iabr_match(struct pt_regs *regs) { return 0; }
448c2ecf20Sopenharmony_cistatic inline int debugger_break_match(struct pt_regs *regs) { return 0; }
458c2ecf20Sopenharmony_cistatic inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }
468c2ecf20Sopenharmony_ci#endif
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_civoid __set_breakpoint(int nr, struct arch_hw_breakpoint *brk);
498c2ecf20Sopenharmony_cibool ppc_breakpoint_available(void);
508c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC_ADV_DEBUG_REGS
518c2ecf20Sopenharmony_ciextern void do_send_trap(struct pt_regs *regs, unsigned long address,
528c2ecf20Sopenharmony_ci			 unsigned long error_code, int brkpt);
538c2ecf20Sopenharmony_ci#else
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciextern void do_break(struct pt_regs *regs, unsigned long address,
568c2ecf20Sopenharmony_ci		     unsigned long error_code);
578c2ecf20Sopenharmony_ci#endif
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_DEBUG_H */
60