1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 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 * $FreeBSD$ 29 */ 30 31 #ifndef _MACHINE_GDB_MACHDEP_H_ 32 #define _MACHINE_GDB_MACHDEP_H_ 33 34 #ifdef BOOKE 35 #define PPC_GDB_NREGS0 1 36 #define PPC_GDB_NREGS4 (70 + 1) 37 #define PPC_GDB_NREGS8 (1 + 32) 38 #define PPC_GDB_NREGS16 0 39 40 #else 41 /* 42 * 0 - 32*GPR(4/8) 43 * 32 - 32*FPR(8) 44 * 64 - PC, PS (4/8) 45 * 66 - CR (4) 46 * 67 - LR, CTR (4/8) 47 * 69 - XER, FPSCR (4) 48 * 71 - 32*VR(16) 49 * 103 - VSCR, VRSAVE (4) 50 */ 51 52 #define PPC_REGNUM_R0 0 53 #define PPC_REGNUM_R31 (PPC_REGNUM_R0 + 31) 54 #define PPC_REGNUM_FR0 32 55 #define PPC_REGNUM_FR31 (PPC_REGNUM_FR0 + 31) 56 #define PPC_REGNUM_PC 64 57 #define PPC_REGNUM_PS 65 58 #define PPC_REGNUM_CR 66 59 #define PPC_REGNUM_LR 67 60 #define PPC_REGNUM_CTR 68 61 #define PPC_REGNUM_XER 69 62 #define PPC_REGNUM_FPSCR 70 63 #define PPC_REGNUM_VR0 71 64 #define PPC_REGNUM_VR31 (PPC_REGNUM_VR0 + 31) 65 66 #define PPC_GDB_NREGS0 0 67 68 #ifdef __powerpc64__ 69 #define PPC_GDB_NREGS4 5 70 #define PPC_GDB_NREGS8 (64 + 4) 71 #else 72 #define PPC_GDB_NREGS4 (32 + 7 + 2) 73 #define PPC_GDB_NREGS8 32 74 #endif 75 76 #define PPC_GDB_NREGS16 32 77 #endif 78 79 #define GDB_NREGS (PPC_GDB_NREGS0 + PPC_GDB_NREGS4 + \ 80 PPC_GDB_NREGS8 + PPC_GDB_NREGS16) 81 #define GDB_REG_PC 64 82 83 #define GDB_BUFSZ (PPC_GDB_NREGS4 * 8 + \ 84 PPC_GDB_NREGS8 * 16 + \ 85 PPC_GDB_NREGS16 * 32) 86 87 static __inline size_t 88 gdb_cpu_regsz(int regnum) 89 { 90 91 #ifdef BOOKE 92 if (regnum == 70) 93 return (0); 94 if (regnum == 71 || regnum >= 73) 95 return (8); 96 #else 97 #ifdef __powerpc64__ 98 if ((regnum >= PPC_REGNUM_R0 && regnum <= PPC_REGNUM_PS) || 99 regnum == PPC_REGNUM_LR || regnum == PPC_REGNUM_CTR) 100 return (8); 101 #else 102 if (regnum >= PPC_REGNUM_FR0 && regnum <= PPC_REGNUM_FR31) 103 return (8); 104 #endif 105 if (regnum >= PPC_REGNUM_VR0 && regnum <= PPC_REGNUM_VR31) 106 return (16); 107 #endif 108 return (4); 109 } 110 111 static __inline int 112 gdb_cpu_query(void) 113 { 114 115 return (0); 116 } 117 118 static __inline void * 119 gdb_begin_write(void) 120 { 121 122 return (NULL); 123 } 124 125 static __inline void 126 gdb_end_write(void *arg __unused) 127 { 128 129 } 130 131 void *gdb_cpu_getreg(int, size_t *); 132 void gdb_cpu_setreg(int, void *); 133 int gdb_cpu_signal(int, int); 134 void gdb_cpu_do_offsets(void); 135 136 #endif /* !_MACHINE_GDB_MACHDEP_H_ */ 137