xref: /openbmc/linux/arch/x86/include/asm/kgdb.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21965aae3SH. Peter Anvin #ifndef _ASM_X86_KGDB_H
31965aae3SH. Peter Anvin #define _ASM_X86_KGDB_H
4bb898558SAl Viro 
5bb898558SAl Viro /*
6bb898558SAl Viro  * Copyright (C) 2001-2004 Amit S. Kale
7bb898558SAl Viro  * Copyright (C) 2008 Wind River Systems, Inc.
8bb898558SAl Viro  */
9bb898558SAl Viro 
1035de5b06SAndy Lutomirski #include <asm/ptrace.h>
1135de5b06SAndy Lutomirski 
12bb898558SAl Viro /*
13bb898558SAl Viro  * BUFMAX defines the maximum number of characters in inbound/outbound
14bb898558SAl Viro  * buffers at least NUMREGBYTES*2 are needed for register packets
15bb898558SAl Viro  * Longer buffer is needed to list all threads
16bb898558SAl Viro  */
17bb898558SAl Viro #define BUFMAX			1024
18bb898558SAl Viro 
19bb898558SAl Viro /*
20bb898558SAl Viro  *  Note that this register image is in a different order than
21bb898558SAl Viro  *  the register image that Linux produces at interrupt time.
22bb898558SAl Viro  *
23bb898558SAl Viro  *  Linux's register image is defined by struct pt_regs in ptrace.h.
24bb898558SAl Viro  *  Just why GDB uses a different order is a historical mystery.
25bb898558SAl Viro  */
26bb898558SAl Viro #ifdef CONFIG_X86_32
27bb898558SAl Viro enum regnames {
28bb898558SAl Viro 	GDB_AX,			/* 0 */
29bb898558SAl Viro 	GDB_CX,			/* 1 */
30bb898558SAl Viro 	GDB_DX,			/* 2 */
31bb898558SAl Viro 	GDB_BX,			/* 3 */
32bb898558SAl Viro 	GDB_SP,			/* 4 */
33bb898558SAl Viro 	GDB_BP,			/* 5 */
34bb898558SAl Viro 	GDB_SI,			/* 6 */
35bb898558SAl Viro 	GDB_DI,			/* 7 */
36bb898558SAl Viro 	GDB_PC,			/* 8 also known as eip */
37bb898558SAl Viro 	GDB_PS,			/* 9 also known as eflags */
38bb898558SAl Viro 	GDB_CS,			/* 10 */
39bb898558SAl Viro 	GDB_SS,			/* 11 */
40bb898558SAl Viro 	GDB_DS,			/* 12 */
41bb898558SAl Viro 	GDB_ES,			/* 13 */
42bb898558SAl Viro 	GDB_FS,			/* 14 */
43bb898558SAl Viro 	GDB_GS,			/* 15 */
44bb898558SAl Viro };
4512bfa3deSJason Wessel #define GDB_ORIG_AX		41
4612bfa3deSJason Wessel #define DBG_MAX_REG_NUM		16
47bb898558SAl Viro #define NUMREGBYTES		((GDB_GS+1)*4)
48bb898558SAl Viro #else /* ! CONFIG_X86_32 */
4912bfa3deSJason Wessel enum regnames {
50bb898558SAl Viro 	GDB_AX,			/* 0 */
51bb898558SAl Viro 	GDB_BX,			/* 1 */
52bb898558SAl Viro 	GDB_CX,			/* 2 */
53bb898558SAl Viro 	GDB_DX,			/* 3 */
54bb898558SAl Viro 	GDB_SI,			/* 4 */
55bb898558SAl Viro 	GDB_DI,			/* 5 */
56bb898558SAl Viro 	GDB_BP,			/* 6 */
57bb898558SAl Viro 	GDB_SP,			/* 7 */
58bb898558SAl Viro 	GDB_R8,			/* 8 */
59bb898558SAl Viro 	GDB_R9,			/* 9 */
60bb898558SAl Viro 	GDB_R10,		/* 10 */
61bb898558SAl Viro 	GDB_R11,		/* 11 */
62bb898558SAl Viro 	GDB_R12,		/* 12 */
63bb898558SAl Viro 	GDB_R13,		/* 13 */
64bb898558SAl Viro 	GDB_R14,		/* 14 */
65bb898558SAl Viro 	GDB_R15,		/* 15 */
66bb898558SAl Viro 	GDB_PC,			/* 16 */
6712bfa3deSJason Wessel 	GDB_PS,			/* 17 */
6812bfa3deSJason Wessel 	GDB_CS,			/* 18 */
6912bfa3deSJason Wessel 	GDB_SS,			/* 19 */
70639077fbSJan Kiszka 	GDB_DS,			/* 20 */
71639077fbSJan Kiszka 	GDB_ES,			/* 21 */
72639077fbSJan Kiszka 	GDB_FS,			/* 22 */
73639077fbSJan Kiszka 	GDB_GS,			/* 23 */
74bb898558SAl Viro };
7512bfa3deSJason Wessel #define GDB_ORIG_AX		57
76639077fbSJan Kiszka #define DBG_MAX_REG_NUM		24
77639077fbSJan Kiszka /* 17 64 bit regs and 5 32 bit regs */
78639077fbSJan Kiszka #define NUMREGBYTES		((17 * 8) + (5 * 4))
7912bfa3deSJason Wessel #endif /* ! CONFIG_X86_32 */
80bb898558SAl Viro 
arch_kgdb_breakpoint(void)81bb898558SAl Viro static inline void arch_kgdb_breakpoint(void)
82bb898558SAl Viro {
83bb898558SAl Viro 	asm("   int $3");
84bb898558SAl Viro }
85bb898558SAl Viro #define BREAK_INSTR_SIZE	1
86bb898558SAl Viro #define CACHE_FLUSH_IS_SAFE	1
8763ab25ebSMike Frysinger #define GDB_ADJUSTS_BREAK_OFFSET
88bb898558SAl Viro 
89f503b5aeSJason Wessel extern int kgdb_ll_trap(int cmd, const char *str,
90f503b5aeSJason Wessel 			struct pt_regs *regs, long err, int trap, int sig);
91f503b5aeSJason Wessel 
921965aae3SH. Peter Anvin #endif /* _ASM_X86_KGDB_H */
93