xref: /linux/arch/riscv/include/asm/kgdb.h (revision e3966940559d52aa1800a008dcfeec218dd31f88)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __ASM_KGDB_H_
4 #define __ASM_KGDB_H_
5 
6 #include <linux/build_bug.h>
7 
8 #ifdef __KERNEL__
9 
10 #define GDB_SIZEOF_REG sizeof(unsigned long)
11 
12 #define DBG_MAX_REG_NUM 36
13 #define NUMREGBYTES (DBG_MAX_REG_NUM * GDB_SIZEOF_REG)
14 #define CACHE_FLUSH_IS_SAFE     1
15 #define BUFMAX                  2048
16 static_assert(BUFMAX > NUMREGBYTES,
17 	      "As per KGDB documentation, BUFMAX must be larger than NUMREGBYTES");
18 #ifdef CONFIG_RISCV_ISA_C
19 #define BREAK_INSTR_SIZE	2
20 #else
21 #define BREAK_INSTR_SIZE	4
22 #endif
23 
24 #ifndef	__ASSEMBLER__
25 
26 void arch_kgdb_breakpoint(void);
27 extern unsigned long kgdb_compiled_break;
28 
29 #endif /* !__ASSEMBLER__ */
30 
31 #define DBG_REG_ZERO "zero"
32 #define DBG_REG_RA "ra"
33 #define DBG_REG_SP "sp"
34 #define DBG_REG_GP "gp"
35 #define DBG_REG_TP "tp"
36 #define DBG_REG_T0 "t0"
37 #define DBG_REG_T1 "t1"
38 #define DBG_REG_T2 "t2"
39 #define DBG_REG_FP "fp"
40 #define DBG_REG_S1 "s1"
41 #define DBG_REG_A0 "a0"
42 #define DBG_REG_A1 "a1"
43 #define DBG_REG_A2 "a2"
44 #define DBG_REG_A3 "a3"
45 #define DBG_REG_A4 "a4"
46 #define DBG_REG_A5 "a5"
47 #define DBG_REG_A6 "a6"
48 #define DBG_REG_A7 "a7"
49 #define DBG_REG_S2 "s2"
50 #define DBG_REG_S3 "s3"
51 #define DBG_REG_S4 "s4"
52 #define DBG_REG_S5 "s5"
53 #define DBG_REG_S6 "s6"
54 #define DBG_REG_S7 "s7"
55 #define DBG_REG_S8 "s8"
56 #define DBG_REG_S9 "s9"
57 #define DBG_REG_S10 "s10"
58 #define DBG_REG_S11 "s11"
59 #define DBG_REG_T3 "t3"
60 #define DBG_REG_T4 "t4"
61 #define DBG_REG_T5 "t5"
62 #define DBG_REG_T6 "t6"
63 #define DBG_REG_EPC "pc"
64 #define DBG_REG_STATUS "sstatus"
65 #define DBG_REG_BADADDR "stval"
66 #define DBG_REG_CAUSE "scause"
67 
68 #define DBG_REG_ZERO_OFF 0
69 #define DBG_REG_RA_OFF 1
70 #define DBG_REG_SP_OFF 2
71 #define DBG_REG_GP_OFF 3
72 #define DBG_REG_TP_OFF 4
73 #define DBG_REG_T0_OFF 5
74 #define DBG_REG_T1_OFF 6
75 #define DBG_REG_T2_OFF 7
76 #define DBG_REG_FP_OFF 8
77 #define DBG_REG_S1_OFF 9
78 #define DBG_REG_A0_OFF 10
79 #define DBG_REG_A1_OFF 11
80 #define DBG_REG_A2_OFF 12
81 #define DBG_REG_A3_OFF 13
82 #define DBG_REG_A4_OFF 14
83 #define DBG_REG_A5_OFF 15
84 #define DBG_REG_A6_OFF 16
85 #define DBG_REG_A7_OFF 17
86 #define DBG_REG_S2_OFF 18
87 #define DBG_REG_S3_OFF 19
88 #define DBG_REG_S4_OFF 20
89 #define DBG_REG_S5_OFF 21
90 #define DBG_REG_S6_OFF 22
91 #define DBG_REG_S7_OFF 23
92 #define DBG_REG_S8_OFF 24
93 #define DBG_REG_S9_OFF 25
94 #define DBG_REG_S10_OFF 26
95 #define DBG_REG_S11_OFF 27
96 #define DBG_REG_T3_OFF 28
97 #define DBG_REG_T4_OFF 29
98 #define DBG_REG_T5_OFF 30
99 #define DBG_REG_T6_OFF 31
100 #define DBG_REG_EPC_OFF 32
101 #define DBG_REG_STATUS_OFF 33
102 #define DBG_REG_BADADDR_OFF 34
103 #define DBG_REG_CAUSE_OFF 35
104 /* NOTE: increase DBG_MAX_REG_NUM if you add more values here. */
105 
106 extern const char riscv_gdb_stub_feature[64];
107 
108 #define kgdb_arch_gdb_stub_feature riscv_gdb_stub_feature
109 
110 #endif
111 #endif
112