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