xref: /freebsd/sys/riscv/include/gdb_machdep.h (revision d91f8db5f1822c43cd256f19aae1d059e4b25a26)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2021 Mitchell Horne <mhorne@FreeBSD.org>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef _MACHINE_GDB_MACHDEP_H_
30 #define	_MACHINE_GDB_MACHDEP_H_
31 
32 #define	GDB_BUFSZ		4096
33 #define	GDB_NREGS		33
34 #define	GDB_REG_ZERO		0
35 #define	GDB_REG_RA		1
36 #define	GDB_REG_SP		2
37 #define	GDB_REG_GP		3
38 #define	GDB_REG_TP		4
39 #define	GDB_REG_T0		5
40 #define	GDB_REG_FP		8
41 #define	GDB_REG_S1		9
42 #define	GDB_REG_A0		10
43 #define	GDB_REG_S2		18
44 #define	GDB_REG_T3		28
45 #define	GDB_REG_PC		32
46 #define	GDB_REG_CSR_BASE	65
47 #define	GDB_REG_SSTATUS		(GDB_REG_CSR_BASE + 0x100)
48 #define	GDB_REG_SCAUSE		(GDB_REG_CSR_BASE + 0x142)
49 #define	GDB_REG_STVAL		(GDB_REG_CSR_BASE + 0x143)
50 _Static_assert(GDB_BUFSZ >= (GDB_NREGS * 8), "buffer fits 'g' regs");
51 
52 static __inline size_t
53 gdb_cpu_regsz(int regnum __unused)
54 {
55 
56 	return (8);
57 }
58 
59 static __inline int
60 gdb_cpu_query(void)
61 {
62 	return (0);
63 }
64 
65 static __inline void *
66 gdb_begin_write(void)
67 {
68 
69 	return (NULL);
70 }
71 
72 static __inline void
73 gdb_end_write(void *arg __unused)
74 {
75 
76 }
77 
78 static __inline void
79 gdb_cpu_stop_reason(int type __unused, int code __unused)
80 {
81 
82 }
83 
84 void	*gdb_cpu_getreg(int, size_t *);
85 void	 gdb_cpu_setreg(int, void *);
86 int	 gdb_cpu_signal(int, int);
87 
88 #endif /* !_MACHINE_GDB_MACHDEP_H_ */
89