xref: /openbmc/linux/arch/arm64/include/asm/kgdb.h (revision c819e2cf)
1 /*
2  * AArch64 KGDB support
3  *
4  * Based on arch/arm/include/kgdb.h
5  *
6  * Copyright (C) 2013 Cavium Inc.
7  * Author: Vijaya Kumar K <vijaya.kumar@caviumnetworks.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef __ARM_KGDB_H
23 #define __ARM_KGDB_H
24 
25 #include <linux/ptrace.h>
26 #include <asm/debug-monitors.h>
27 
28 #ifndef	__ASSEMBLY__
29 
30 static inline void arch_kgdb_breakpoint(void)
31 {
32 	asm ("brk %0" : : "I" (KGDB_COMPILED_DBG_BRK_IMM));
33 }
34 
35 extern void kgdb_handle_bus_error(void);
36 extern int kgdb_fault_expected;
37 
38 #endif /* !__ASSEMBLY__ */
39 
40 /*
41  * gdb is expecting the following registers layout.
42  *
43  * General purpose regs:
44  *     r0-r30: 64 bit
45  *     sp,pc : 64 bit
46  *     pstate  : 64 bit
47  *     Total: 34
48  * FPU regs:
49  *     f0-f31: 128 bit
50  *     Total: 32
51  * Extra regs
52  *     fpsr & fpcr: 32 bit
53  *     Total: 2
54  *
55  */
56 
57 #define _GP_REGS		34
58 #define _FP_REGS		32
59 #define _EXTRA_REGS		2
60 /*
61  * general purpose registers size in bytes.
62  * pstate is only 4 bytes. subtract 4 bytes
63  */
64 #define GP_REG_BYTES		(_GP_REGS * 8)
65 #define DBG_MAX_REG_NUM		(_GP_REGS + _FP_REGS + _EXTRA_REGS)
66 
67 /*
68  * Size of I/O buffer for gdb packet.
69  * considering to hold all register contents, size is set
70  */
71 
72 #define BUFMAX			2048
73 
74 /*
75  * Number of bytes required for gdb_regs buffer.
76  * _GP_REGS: 8 bytes, _FP_REGS: 16 bytes and _EXTRA_REGS: 4 bytes each
77  * GDB fails to connect for size beyond this with error
78  * "'g' packet reply is too long"
79  */
80 
81 #define NUMREGBYTES	((_GP_REGS * 8) + (_FP_REGS * 16) + \
82 			(_EXTRA_REGS * 4))
83 
84 #endif /* __ASM_KGDB_H */
85