1 /* FreeBSD/PowerPC specific low level interface, for the remote server for
3 Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #include <sys/cdefs.h>
24 __FBSDID("$FreeBSD$");
29 #include <sys/procfs.h>
30 #include <sys/ptrace.h>
32 #define ppc_num_regs 71
34 /* Currently, don't check/send MQ. */
35 static int ppc_regmap[] =
36 { 0, 4, 8, 12, 16, 20, 24, 28,
37 32, 36, 40, 44, 48, 52, 56, 60,
38 64, 68, 72, 76, 80, 84, 88, 92,
39 96, 100, 104, 108, 112, 116, 120, 124,
42 * XXX on FreeBSD the gdbserver for PowerPC was only tested with FPU-less
43 * cores i.e. e500. Let's leave the original FPR references around in case
44 * someone picks up and brings support for AIM-like FPU machines.
46 PT_FPR0*4, PT_FPR0*4 + 8, PT_FPR0*4+16, PT_FPR0*4+24,
47 PT_FPR0*4+32, PT_FPR0*4+40, PT_FPR0*4+48, PT_FPR0*4+56,
48 PT_FPR0*4+64, PT_FPR0*4+72, PT_FPR0*4+80, PT_FPR0*4+88,
49 PT_FPR0*4+96, PT_FPR0*4+104, PT_FPR0*4+112, PT_FPR0*4+120,
50 PT_FPR0*4+128, PT_FPR0*4+136, PT_FPR0*4+144, PT_FPR0*4+152,
51 PT_FPR0*4+160, PT_FPR0*4+168, PT_FPR0*4+176, PT_FPR0*4+184,
52 PT_FPR0*4+192, PT_FPR0*4+200, PT_FPR0*4+208, PT_FPR0*4+216,
53 PT_FPR0*4+224, PT_FPR0*4+232, PT_FPR0*4+240, PT_FPR0*4+248,
55 -1, -1, -1, -1, -1, -1, -1, -1,
56 -1, -1, -1, -1, -1, -1, -1, -1,
57 -1, -1, -1, -1, -1, -1, -1, -1,
58 -1, -1, -1, -1, -1, -1, -1, -1,
59 144, -1, 132, 128, 140, 136, -1
63 ppc_cannot_store_register (int regno)
65 /* Some kernels do not allow us to store fpscr. */
66 if (regno == find_regno ("fpscr"))
73 ppc_cannot_fetch_register (int regno)
83 collect_register_by_name ("pc", &pc);
84 return (CORE_ADDR) pc;
88 ppc_set_pc (CORE_ADDR pc)
90 unsigned long newpc = pc;
92 supply_register_by_name ("pc", &newpc);
95 /* Correct in either endianness. Note that this file is
96 for PowerPC only, not PowerPC64.
97 This instruction is "twge r2, r2", which GDB uses as a software
99 static const unsigned long ppc_breakpoint = 0x7d821008;
100 #define ppc_breakpoint_len 4
103 ppc_breakpoint_at (CORE_ADDR where)
107 (*the_target->read_memory) (where, (char *) &insn, 4);
108 if (insn == ppc_breakpoint)
110 /* If necessary, recognize more trap instructions here. GDB only uses the
116 ppc_fill_gregset (void *buf)
120 for (i = 0; i < ppc_num_regs; i++)
121 if (ppc_regmap[i] != -1)
122 collect_register (i, ((char *) buf) + ppc_regmap[i]);
127 ppc_store_gregset (const void *buf)
131 for (i = 0; i < ppc_num_regs; i++)
132 if (ppc_regmap[i] != -1)
133 supply_register (i, ((char *) buf) + ppc_regmap[i]);
137 struct regset_info target_regsets[] = {
138 { PT_GETREGS, PT_SETREGS, sizeof (struct reg),
140 ppc_fill_gregset, ppc_store_gregset },
141 { 0, 0, -1, -1, NULL, NULL }
144 struct fbsd_target_ops the_low_target = {
147 ppc_cannot_fetch_register,
148 ppc_cannot_store_register,
151 (const char *) &ppc_breakpoint,