1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2023 Loongson Technology Corporation Limited
6 #ifndef _ASM_LOONGARCH_KGDB_H
7 #define _ASM_LOONGARCH_KGDB_H
9 #define GDB_SIZEOF_REG sizeof(u64)
11 /* gdb remote procotol expects the following register layout. */
14 * General purpose registers:
18 * csr_badvaddr: 64 bit
20 #define DBG_PT_REGS_BASE 0
21 #define DBG_PT_REGS_NUM 35
22 #define DBG_PT_REGS_END (DBG_PT_REGS_BASE + DBG_PT_REGS_NUM - 1)
25 * Floating point registers:
28 #define DBG_FPR_BASE (DBG_PT_REGS_END + 1)
29 #define DBG_FPR_NUM 32
30 #define DBG_FPR_END (DBG_FPR_BASE + DBG_FPR_NUM - 1)
33 * Condition Flag registers:
36 #define DBG_FCC_BASE (DBG_FPR_END + 1)
38 #define DBG_FCC_END (DBG_FCC_BASE + DBG_FCC_NUM - 1)
41 * Floating-point Control and Status registers:
44 #define DBG_FCSR_NUM 1
45 #define DBG_FCSR (DBG_FCC_END + 1)
47 #define DBG_MAX_REG_NUM (DBG_FCSR + 1)
50 * Size of I/O buffer for gdb packet.
51 * considering to hold all register contents, size is set
56 * Number of bytes required for gdb_regs buffer.
57 * PT_REGS and FPR: 8 bytes; FCSR: 4 bytes; FCC: 1 bytes.
58 * GDB fails to connect for size beyond this with error
59 * "'g' packet reply is too long"
61 #define NUMREGBYTES ((DBG_PT_REGS_NUM + DBG_FPR_NUM) * GDB_SIZEOF_REG + DBG_FCC_NUM * 1 + DBG_FCSR_NUM * 4)
63 #define BREAK_INSTR_SIZE 4
64 #define CACHE_FLUSH_IS_SAFE 0
66 /* Register numbers of various important registers. */
67 enum dbg_loongarch_regnum {
68 DBG_LOONGARCH_ZERO = 0,
73 DBG_LOONGARCH_FP = 22,
83 DBG_LOONGARCH_ORIG_A0,
88 void kgdb_breakinst(void);
89 void arch_kgdb_breakpoint(void);
92 bool kgdb_breakpoint_handler(struct pt_regs *regs);
93 #else /* !CONFIG_KGDB */
94 static inline bool kgdb_breakpoint_handler(struct pt_regs *regs) { return false; }
95 #endif /* CONFIG_KGDB */
97 #endif /* __ASM_KGDB_H_ */