master
  1/*-
  2 * SPDX-License-Identifier: BSD-2-Clause
  3 *
  4 * Copyright (c) 2006 Marcel Moolenaar
  5 * All rights reserved.
  6 *
  7 * Redistribution and use in source and binary forms, with or without
  8 * modification, are permitted provided that the following conditions
  9 * are met:
 10 *
 11 * 1. Redistributions of source code must retain the above copyright
 12 *    notice, this list of conditions and the following disclaimer.
 13 * 2. Redistributions in binary form must reproduce the above copyright
 14 *    notice, this list of conditions and the following disclaimer in the
 15 *    documentation and/or other materials provided with the distribution.
 16 *
 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27 */
 28
 29#ifndef _MACHINE_GDB_MACHDEP_H_
 30#define	_MACHINE_GDB_MACHDEP_H_
 31
 32#ifdef BOOKE
 33#define	PPC_GDB_NREGS0	1
 34#define	PPC_GDB_NREGS4	(70 + 1)
 35#define	PPC_GDB_NREGS8	(1 + 32)
 36#define	PPC_GDB_NREGS16	0
 37
 38#else
 39/*
 40 *   0 - 32*GPR(4/8)
 41 *  32 - 32*FPR(8)
 42 *  64 - PC, PS (4/8)
 43 *  66 - CR (4)
 44 *  67 - LR, CTR (4/8)
 45 *  69 - XER, FPSCR (4)
 46 *  71 - 32*VR(16)
 47 * 103 - VSCR, VRSAVE (4)
 48 */
 49
 50#define	PPC_REGNUM_R0	0
 51#define	PPC_REGNUM_R31	(PPC_REGNUM_R0 + 31)
 52#define	PPC_REGNUM_FR0	32
 53#define	PPC_REGNUM_FR31	(PPC_REGNUM_FR0 + 31)
 54#define	PPC_REGNUM_PC	64
 55#define	PPC_REGNUM_PS	65
 56#define	PPC_REGNUM_CR	66
 57#define	PPC_REGNUM_LR	67
 58#define	PPC_REGNUM_CTR	68
 59#define	PPC_REGNUM_XER	69
 60#define	PPC_REGNUM_FPSCR 70
 61#define	PPC_REGNUM_VR0	71
 62#define	PPC_REGNUM_VR31	(PPC_REGNUM_VR0 + 31)
 63
 64#define	PPC_GDB_NREGS0	0
 65
 66#ifdef __powerpc64__
 67#define	PPC_GDB_NREGS4	5
 68#define	PPC_GDB_NREGS8	(64 + 4)
 69#else
 70#define	PPC_GDB_NREGS4	(32 + 7 + 2)
 71#define	PPC_GDB_NREGS8	32
 72#endif
 73
 74#define	PPC_GDB_NREGS16	32
 75#endif
 76
 77#define GDB_NREGS	(PPC_GDB_NREGS0 + PPC_GDB_NREGS4 + \
 78			 PPC_GDB_NREGS8 + PPC_GDB_NREGS16)
 79#define	GDB_REG_PC	64
 80
 81#define	GDB_BUFSZ	(PPC_GDB_NREGS4 * 8 +	\
 82			 PPC_GDB_NREGS8 * 16 +	\
 83			 PPC_GDB_NREGS16 * 32)
 84
 85static __inline size_t
 86gdb_cpu_regsz(int regnum)
 87{
 88
 89#ifdef BOOKE
 90	if (regnum == 70)
 91		return (0);
 92	if (regnum == 71 || regnum >= 73)
 93		return (8);
 94#else
 95#ifdef __powerpc64__
 96	if ((regnum >= PPC_REGNUM_R0 && regnum <= PPC_REGNUM_PS) ||
 97	    regnum == PPC_REGNUM_LR || regnum == PPC_REGNUM_CTR)
 98		return (8);
 99#else
100	if (regnum >= PPC_REGNUM_FR0 && regnum <= PPC_REGNUM_FR31)
101		return (8);
102#endif
103	if (regnum >= PPC_REGNUM_VR0 && regnum <= PPC_REGNUM_VR31)
104		return (16);
105#endif
106	return (4);
107}
108
109static __inline int
110gdb_cpu_query(void)
111{
112
113	return (0);
114}
115
116static __inline void *
117gdb_begin_write(void)
118{
119
120	return (NULL);
121}
122
123static __inline void
124gdb_end_write(void *arg __unused)
125{
126
127}
128
129static __inline void
130gdb_cpu_stop_reason(int type __unused, int code __unused)
131{
132
133}
134
135void *gdb_cpu_getreg(int, size_t *);
136void gdb_cpu_setreg(int, void *);
137int gdb_cpu_signal(int, int);
138void gdb_cpu_do_offsets(void);
139
140#endif /* !_MACHINE_GDB_MACHDEP_H_ */