1512b2fb1SMarcel Moolenaar /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
371e3c308SPedro F. Giffuni *
4512b2fb1SMarcel Moolenaar * Copyright (c) 2006 Marcel Moolenaar
5512b2fb1SMarcel Moolenaar * All rights reserved.
6512b2fb1SMarcel Moolenaar *
7512b2fb1SMarcel Moolenaar * Redistribution and use in source and binary forms, with or without
8512b2fb1SMarcel Moolenaar * modification, are permitted provided that the following conditions
9512b2fb1SMarcel Moolenaar * are met:
10512b2fb1SMarcel Moolenaar *
11512b2fb1SMarcel Moolenaar * 1. Redistributions of source code must retain the above copyright
12512b2fb1SMarcel Moolenaar * notice, this list of conditions and the following disclaimer.
13512b2fb1SMarcel Moolenaar * 2. Redistributions in binary form must reproduce the above copyright
14512b2fb1SMarcel Moolenaar * notice, this list of conditions and the following disclaimer in the
15512b2fb1SMarcel Moolenaar * documentation and/or other materials provided with the distribution.
16512b2fb1SMarcel Moolenaar *
17512b2fb1SMarcel Moolenaar * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18512b2fb1SMarcel Moolenaar * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19512b2fb1SMarcel Moolenaar * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20512b2fb1SMarcel Moolenaar * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21512b2fb1SMarcel Moolenaar * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22512b2fb1SMarcel Moolenaar * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23512b2fb1SMarcel Moolenaar * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24512b2fb1SMarcel Moolenaar * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25512b2fb1SMarcel Moolenaar * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26512b2fb1SMarcel Moolenaar * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27512b2fb1SMarcel Moolenaar */
28512b2fb1SMarcel Moolenaar
29512b2fb1SMarcel Moolenaar #ifndef _MACHINE_GDB_MACHDEP_H_
30512b2fb1SMarcel Moolenaar #define _MACHINE_GDB_MACHDEP_H_
31512b2fb1SMarcel Moolenaar
32972aa496SMarcel Moolenaar #ifdef BOOKE
33972aa496SMarcel Moolenaar #define PPC_GDB_NREGS0 1
34972aa496SMarcel Moolenaar #define PPC_GDB_NREGS4 (70 + 1)
35972aa496SMarcel Moolenaar #define PPC_GDB_NREGS8 (1 + 32)
36972aa496SMarcel Moolenaar #define PPC_GDB_NREGS16 0
37a8a6278eSLeandro Lupori
38972aa496SMarcel Moolenaar #else
39a8a6278eSLeandro Lupori /*
40a8a6278eSLeandro Lupori * 0 - 32*GPR(4/8)
41a8a6278eSLeandro Lupori * 32 - 32*FPR(8)
42a8a6278eSLeandro Lupori * 64 - PC, PS (4/8)
43a8a6278eSLeandro Lupori * 66 - CR (4)
44a8a6278eSLeandro Lupori * 67 - LR, CTR (4/8)
45a8a6278eSLeandro Lupori * 69 - XER, FPSCR (4)
46a8a6278eSLeandro Lupori * 71 - 32*VR(16)
47a8a6278eSLeandro Lupori * 103 - VSCR, VRSAVE (4)
48a8a6278eSLeandro Lupori */
49a8a6278eSLeandro Lupori
50a8a6278eSLeandro Lupori #define PPC_REGNUM_R0 0
51a8a6278eSLeandro Lupori #define PPC_REGNUM_R31 (PPC_REGNUM_R0 + 31)
52a8a6278eSLeandro Lupori #define PPC_REGNUM_FR0 32
53a8a6278eSLeandro Lupori #define PPC_REGNUM_FR31 (PPC_REGNUM_FR0 + 31)
54a8a6278eSLeandro Lupori #define PPC_REGNUM_PC 64
55a8a6278eSLeandro Lupori #define PPC_REGNUM_PS 65
56a8a6278eSLeandro Lupori #define PPC_REGNUM_CR 66
57a8a6278eSLeandro Lupori #define PPC_REGNUM_LR 67
58a8a6278eSLeandro Lupori #define PPC_REGNUM_CTR 68
59a8a6278eSLeandro Lupori #define PPC_REGNUM_XER 69
60a8a6278eSLeandro Lupori #define PPC_REGNUM_FPSCR 70
61a8a6278eSLeandro Lupori #define PPC_REGNUM_VR0 71
62a8a6278eSLeandro Lupori #define PPC_REGNUM_VR31 (PPC_REGNUM_VR0 + 31)
63a8a6278eSLeandro Lupori
64972aa496SMarcel Moolenaar #define PPC_GDB_NREGS0 0
65a8a6278eSLeandro Lupori
66a8a6278eSLeandro Lupori #ifdef __powerpc64__
67a8a6278eSLeandro Lupori #define PPC_GDB_NREGS4 5
68a8a6278eSLeandro Lupori #define PPC_GDB_NREGS8 (64 + 4)
69a8a6278eSLeandro Lupori #else
70294800e5SMarcel Moolenaar #define PPC_GDB_NREGS4 (32 + 7 + 2)
71294800e5SMarcel Moolenaar #define PPC_GDB_NREGS8 32
72a8a6278eSLeandro Lupori #endif
73a8a6278eSLeandro Lupori
74294800e5SMarcel Moolenaar #define PPC_GDB_NREGS16 32
75972aa496SMarcel Moolenaar #endif
76294800e5SMarcel Moolenaar
77972aa496SMarcel Moolenaar #define GDB_NREGS (PPC_GDB_NREGS0 + PPC_GDB_NREGS4 + \
78972aa496SMarcel Moolenaar PPC_GDB_NREGS8 + PPC_GDB_NREGS16)
79512b2fb1SMarcel Moolenaar #define GDB_REG_PC 64
80512b2fb1SMarcel Moolenaar
81294800e5SMarcel Moolenaar #define GDB_BUFSZ (PPC_GDB_NREGS4 * 8 + \
82294800e5SMarcel Moolenaar PPC_GDB_NREGS8 * 16 + \
83294800e5SMarcel Moolenaar PPC_GDB_NREGS16 * 32)
84512b2fb1SMarcel Moolenaar
85512b2fb1SMarcel Moolenaar static __inline size_t
gdb_cpu_regsz(int regnum)86512b2fb1SMarcel Moolenaar gdb_cpu_regsz(int regnum)
87512b2fb1SMarcel Moolenaar {
88294800e5SMarcel Moolenaar
89972aa496SMarcel Moolenaar #ifdef BOOKE
90972aa496SMarcel Moolenaar if (regnum == 70)
91972aa496SMarcel Moolenaar return (0);
92972aa496SMarcel Moolenaar if (regnum == 71 || regnum >= 73)
93972aa496SMarcel Moolenaar return (8);
94972aa496SMarcel Moolenaar #else
95a8a6278eSLeandro Lupori #ifdef __powerpc64__
96a8a6278eSLeandro Lupori if ((regnum >= PPC_REGNUM_R0 && regnum <= PPC_REGNUM_PS) ||
97a8a6278eSLeandro Lupori regnum == PPC_REGNUM_LR || regnum == PPC_REGNUM_CTR)
98294800e5SMarcel Moolenaar return (8);
99a8a6278eSLeandro Lupori #else
100a8a6278eSLeandro Lupori if (regnum >= PPC_REGNUM_FR0 && regnum <= PPC_REGNUM_FR31)
101a8a6278eSLeandro Lupori return (8);
102a8a6278eSLeandro Lupori #endif
103a8a6278eSLeandro Lupori if (regnum >= PPC_REGNUM_VR0 && regnum <= PPC_REGNUM_VR31)
104294800e5SMarcel Moolenaar return (16);
105972aa496SMarcel Moolenaar #endif
106294800e5SMarcel Moolenaar return (4);
107512b2fb1SMarcel Moolenaar }
108512b2fb1SMarcel Moolenaar
109512b2fb1SMarcel Moolenaar static __inline int
gdb_cpu_query(void)110512b2fb1SMarcel Moolenaar gdb_cpu_query(void)
111512b2fb1SMarcel Moolenaar {
112294800e5SMarcel Moolenaar
113512b2fb1SMarcel Moolenaar return (0);
114512b2fb1SMarcel Moolenaar }
115512b2fb1SMarcel Moolenaar
116beb24065SJonathan T. Looney static __inline void *
gdb_begin_write(void)117beb24065SJonathan T. Looney gdb_begin_write(void)
118beb24065SJonathan T. Looney {
119beb24065SJonathan T. Looney
120beb24065SJonathan T. Looney return (NULL);
121beb24065SJonathan T. Looney }
122beb24065SJonathan T. Looney
123beb24065SJonathan T. Looney static __inline void
gdb_end_write(void * arg __unused)124beb24065SJonathan T. Looney gdb_end_write(void *arg __unused)
125beb24065SJonathan T. Looney {
126beb24065SJonathan T. Looney
127beb24065SJonathan T. Looney }
128beb24065SJonathan T. Looney
1297446b088SMitchell Horne static __inline void
gdb_cpu_stop_reason(int type __unused,int code __unused)1307446b088SMitchell Horne gdb_cpu_stop_reason(int type __unused, int code __unused)
1317446b088SMitchell Horne {
1327446b088SMitchell Horne
1337446b088SMitchell Horne }
1347446b088SMitchell Horne
135512b2fb1SMarcel Moolenaar void *gdb_cpu_getreg(int, size_t *);
136512b2fb1SMarcel Moolenaar void gdb_cpu_setreg(int, void *);
137512b2fb1SMarcel Moolenaar int gdb_cpu_signal(int, int);
138fa76c6f9SLeandro Lupori void gdb_cpu_do_offsets(void);
139512b2fb1SMarcel Moolenaar
140512b2fb1SMarcel Moolenaar #endif /* !_MACHINE_GDB_MACHDEP_H_ */
141