1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Author: Deepak Saxena <dsaxena@mvista.com>
7 * Copyright (C) 2002 MontaVista Software Inc.
11 #ifndef __ARM_KGDB_H__
12 #define __ARM_KGDB_H__
14 #include <linux/ptrace.h>
15 #include <asm/opcodes.h>
18 * GDB assumes that we're a user process being debugged, so
19 * it will send us an SWI command to write into memory as the
20 * debug trap. When an SWI occurs, the next instruction addr is
21 * placed into R14_svc before jumping to the vector trap.
22 * This doesn't work for kernel debugging as we are already in SVC
23 * we would loose the kernel's LR, which is a bad thing. This
26 * By doing this as an undefined instruction trap, we force a mode
27 * switch from SVC to UND mode, allowing us to save full kernel state.
29 * We also define a KGDB_COMPILED_BREAK which can be used to compile
30 * in breakpoints. This is important for things like sysrq-G and for
31 * the initial breakpoint from trap_init().
33 * Note to ARM HW designers: Add real trap support like SH && PPC to
34 * make our lives much much simpler. :)
36 #define BREAK_INSTR_SIZE 4
37 #define GDB_BREAKINST 0xef9f0001
38 #define KGDB_BREAKINST 0xe7ffdefe
39 #define KGDB_COMPILED_BREAK 0xe7ffdeff
40 #define CACHE_FLUSH_IS_SAFE 1
44 static inline void arch_kgdb_breakpoint(void)
46 asm(__inst_arm(0xe7ffdeff));
49 extern void kgdb_handle_bus_error(void);
50 extern int kgdb_fault_expected
;
52 #endif /* !__ASSEMBLY__ */
57 * gdb is expecting the following registers layout.
59 * r0-r15: 1 long word each
60 * f0-f7: unused, 3 long words each !!
61 * fps: unused, 1 long word
64 * Even though f0-f7 and fps are not used, they need to be
65 * present in the registers sent for correct processing in
68 * In particular, it is crucial that CPSR is in the right place,
69 * otherwise gdb will not be able to correctly interpret stepping over
70 * conditional branches.
75 #define GDB_MAX_REGS (_GP_REGS + (_FP_REGS * 3) + _EXTRA_REGS)
76 #define DBG_MAX_REG_NUM (_GP_REGS + _FP_REGS + _EXTRA_REGS)
78 #define KGDB_MAX_NO_CPUS 1
80 #define NUMREGBYTES (DBG_MAX_REG_NUM << 2)
81 #define NUMCRITREGBYTES (32 << 2)
99 #define _CPSR (GDB_MAX_REGS - 1)
102 * So that we can denote the end of a frame for tracing,
103 * in the simple case:
105 #define CFI_END_FRAME(func) __CFI_END_FRAME(_PC, _SPT, func)
107 #endif /* __ASM_KGDB_H__ */