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