Merge remote-tracking branches 'regmap/topic/bulk', 'regmap/topic/i2c', 'regmap/topic...
[deliverable/linux.git] / arch / arm64 / include / asm / kgdb.h
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 remote procotol (well most versions of it) expects the following
42 * register layout.
43 *
44 * General purpose regs:
45 * r0-r30: 64 bit
46 * sp,pc : 64 bit
47 * pstate : 32 bit
48 * Total: 33 + 1
49 * FPU regs:
50 * f0-f31: 128 bit
51 * fpsr & fpcr: 32 bit
52 * Total: 32 + 2
53 *
54 * To expand a little on the "most versions of it"... when the gdb remote
55 * protocol for AArch64 was developed it depended on a statement in the
56 * Architecture Reference Manual that claimed "SPSR_ELx is a 32-bit register".
57 * and, as a result, allocated only 32-bits for the PSTATE in the remote
58 * protocol. In fact this statement is still present in ARM DDI 0487A.i.
59 *
60 * Unfortunately "is a 32-bit register" has a very special meaning for
61 * system registers. It means that "the upper bits, bits[63:32], are
62 * RES0.". RES0 is heavily used in the ARM architecture documents as a
63 * way to leave space for future architecture changes. So to translate a
64 * little for people who don't spend their spare time reading ARM architecture
65 * manuals, what "is a 32-bit register" actually means in this context is
66 * "is a 64-bit register but one with no meaning allocated to any of the
67 * upper 32-bits... *yet*".
68 *
69 * Perhaps then we should not be surprised that this has led to some
70 * confusion. Specifically a patch, influenced by the above translation,
71 * that extended PSTATE to 64-bit was accepted into gdb-7.7 but the patch
72 * was reverted in gdb-7.8.1 and all later releases, when this was
73 * discovered to be an undocumented protocol change.
74 *
75 * So... it is *not* wrong for us to only allocate 32-bits to PSTATE
76 * here even though the kernel itself allocates 64-bits for the same
77 * state. That is because this bit of code tells the kernel how the gdb
78 * remote protocol (well most versions of it) describes the register state.
79 *
80 * Note that if you are using one of the versions of gdb that supports
81 * the gdb-7.7 version of the protocol you cannot use kgdb directly
82 * without providing a custom register description (gdb can load new
83 * protocol descriptions at runtime).
84 */
85
86 #define _GP_REGS 33
87 #define _FP_REGS 32
88 #define _EXTRA_REGS 3
89 /*
90 * general purpose registers size in bytes.
91 * pstate is only 4 bytes. subtract 4 bytes
92 */
93 #define GP_REG_BYTES (_GP_REGS * 8)
94 #define DBG_MAX_REG_NUM (_GP_REGS + _FP_REGS + _EXTRA_REGS)
95
96 /*
97 * Size of I/O buffer for gdb packet.
98 * considering to hold all register contents, size is set
99 */
100
101 #define BUFMAX 2048
102
103 /*
104 * Number of bytes required for gdb_regs buffer.
105 * _GP_REGS: 8 bytes, _FP_REGS: 16 bytes and _EXTRA_REGS: 4 bytes each
106 * GDB fails to connect for size beyond this with error
107 * "'g' packet reply is too long"
108 */
109
110 #define NUMREGBYTES ((_GP_REGS * 8) + (_FP_REGS * 16) + \
111 (_EXTRA_REGS * 4))
112
113 #endif /* __ASM_KGDB_H */
This page took 0.052206 seconds and 5 git commands to generate.