1bbfa199cSmhorne /*-
24d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3bbfa199cSmhorne *
4bbfa199cSmhorne * Copyright (c) 2020 The FreeBSD Foundation
5bbfa199cSmhorne *
6bbfa199cSmhorne * This software was developed by Mitchell Horne under sponsorship from
7bbfa199cSmhorne * the FreeBSD Foundation.
8bbfa199cSmhorne *
9bbfa199cSmhorne * Redistribution and use in source and binary forms, with or without
10bbfa199cSmhorne * modification, are permitted provided that the following conditions
11bbfa199cSmhorne * are met:
12bbfa199cSmhorne * 1. Redistributions of source code must retain the above copyright
13bbfa199cSmhorne * notice, this list of conditions and the following disclaimer.
14bbfa199cSmhorne * 2. Redistributions in binary form must reproduce the above copyright
15bbfa199cSmhorne * notice, this list of conditions and the following disclaimer in the
16bbfa199cSmhorne * documentation and/or other materials provided with the distribution.
17bbfa199cSmhorne *
18bbfa199cSmhorne * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19bbfa199cSmhorne * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20bbfa199cSmhorne * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21bbfa199cSmhorne * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22bbfa199cSmhorne * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23bbfa199cSmhorne * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24bbfa199cSmhorne * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25bbfa199cSmhorne * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26bbfa199cSmhorne * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27bbfa199cSmhorne * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28bbfa199cSmhorne * SUCH DAMAGE.
29bbfa199cSmhorne */
30bbfa199cSmhorne
31bbfa199cSmhorne #ifndef _MACHINE_GDB_MACHDEP_H_
32bbfa199cSmhorne #define _MACHINE_GDB_MACHDEP_H_
33bbfa199cSmhorne
34bbfa199cSmhorne #define GDB_BUFSZ 4096
35bbfa199cSmhorne #define GDB_NREGS 68
36bbfa199cSmhorne #define GDB_REG_X0 0
371c1f31a5SAndrew Turner #define GDB_REG_X19 19
38bbfa199cSmhorne #define GDB_REG_X29 29
39bbfa199cSmhorne #define GDB_REG_LR 30
40bbfa199cSmhorne #define GDB_REG_SP 31
41bbfa199cSmhorne #define GDB_REG_PC 32
42bbfa199cSmhorne #define GDB_REG_CSPR 33
43bbfa199cSmhorne #define GDB_REG_V0 34
44bbfa199cSmhorne #define GDB_REG_V31 65
45bbfa199cSmhorne #define GDB_REG_FPSR 66
46bbfa199cSmhorne #define GDB_REG_FPCR 67
47bbfa199cSmhorne _Static_assert(GDB_BUFSZ >= (GDB_NREGS * 16), "buffer fits 'g' regs");
48bbfa199cSmhorne
49bbfa199cSmhorne static __inline size_t
gdb_cpu_regsz(int regnum)50bbfa199cSmhorne gdb_cpu_regsz(int regnum)
51bbfa199cSmhorne {
52bbfa199cSmhorne if (regnum == GDB_REG_CSPR || regnum == GDB_REG_FPSR ||
53bbfa199cSmhorne regnum == GDB_REG_FPCR)
54bbfa199cSmhorne return (4);
55bbfa199cSmhorne else if (regnum >= GDB_REG_V0 && regnum <= GDB_REG_V31)
56bbfa199cSmhorne return (16);
57bbfa199cSmhorne
58bbfa199cSmhorne return (8);
59bbfa199cSmhorne }
60bbfa199cSmhorne
61bbfa199cSmhorne static __inline int
gdb_cpu_query(void)62bbfa199cSmhorne gdb_cpu_query(void)
63bbfa199cSmhorne {
64bbfa199cSmhorne return (0);
65bbfa199cSmhorne }
66bbfa199cSmhorne
67bbfa199cSmhorne static __inline void *
gdb_begin_write(void)68bbfa199cSmhorne gdb_begin_write(void)
69bbfa199cSmhorne {
70bbfa199cSmhorne return (NULL);
71bbfa199cSmhorne }
72bbfa199cSmhorne
73bbfa199cSmhorne static __inline void
gdb_end_write(void * arg __unused)74bbfa199cSmhorne gdb_end_write(void *arg __unused)
75bbfa199cSmhorne {
76bbfa199cSmhorne }
77bbfa199cSmhorne
78bbfa199cSmhorne void *gdb_cpu_getreg(int, size_t *);
79bbfa199cSmhorne void gdb_cpu_setreg(int, void *);
80bbfa199cSmhorne int gdb_cpu_signal(int, int);
817446b088SMitchell Horne void gdb_cpu_stop_reason(int, int);
82bbfa199cSmhorne
83bbfa199cSmhorne #endif /* !_MACHINE_GDB_MACHDEP_H_ */
84