1 /* Remote target communications for the Macraigor Systems BDM Wiggler
2 talking to a Motorola PPC 505.
3 Copyright 1996, 1997 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #include "gdb_string.h"
33 #include "gdb-stabs.h"
34 #include <sys/types.h>
39 static void bdm_ppc_open
PARAMS ((char *name
, int from_tty
));
41 static int bdm_ppc_wait
PARAMS ((int pid
,
42 struct target_waitstatus
*target_status
));
44 static void bdm_ppc_fetch_registers
PARAMS ((int regno
));
46 static void bdm_ppc_store_registers
PARAMS ((int regno
));
48 extern struct target_ops bdm_ppc_ops
; /* Forward decl */
50 /* Open a connection to a remote debugger.
51 NAME is the filename used for communication. */
54 bdm_ppc_open (name
, from_tty
)
58 ocd_open (name
, from_tty
, OCD_TARGET_MOTO_PPC
, &bdm_ppc_ops
);
61 /* Wait until the remote machine stops, then return,
62 storing status in STATUS just as `wait' would.
63 Returns "pid" (though it's not clear what, if anything, that
64 means in the case of this target). */
67 bdm_ppc_wait (pid
, target_status
)
69 struct target_waitstatus
*target_status
;
73 target_status
->kind
= TARGET_WAITKIND_STOPPED
;
75 stop_reason
= ocd_wait ();
79 target_status
->value
.sig
= TARGET_SIGNAL_INT
;
83 target_status
->value
.sig
= TARGET_SIGNAL_TRAP
; /* XXX for now */
86 unsigned long ecr
, der
;
88 ecr
= ocd_read_bdm_register (148); /* Read the exception cause register */
89 der
= ocd_read_bdm_register (149); /* Read the debug enables register */
90 fprintf_unfiltered (gdb_stdout
, "ecr = 0x%x, der = 0x%x\n", ecr
, der
);
96 static int bdm_regmap
[] = {BDM_REGMAP
};
98 /* Read the remote registers into regs.
100 The Wiggler uses the following codes to access the registers:
102 0 -> 1023 SPR 0 -> 1023
106 9 - SPR 9 - CTR (known as cnt in GDB)
107 26 - SPR 26 - SRR0 - pc
108 1024 -> 2047 DCR 0 -> DCR 1023 (IBM PPC 4xx only)
109 2048 -> 2079 R0 -> R31
110 2080 -> 2143 FP0 -> FP31 (64 bit regs)
111 2144 CR (known as cnd in GDB)
113 2146 MSR (known as ps in GDB)
117 bdm_ppc_fetch_registers (regno
)
122 int first_regno
, last_regno
;
123 int first_bdm_regno
, last_bdm_regno
;
129 last_regno
= NUM_REGS
- 1;
132 last_bdm_regno
= BDM_NUM_REGS
- 1;
139 first_bdm_regno
= bdm_regmap
[regno
];
140 last_bdm_regno
= bdm_regmap
[regno
];
143 if (first_bdm_regno
== -1)
145 supply_register (first_regno
, NULL
);
146 return; /* Unsupported register */
149 regs
= ocd_read_bdm_registers (first_bdm_regno
, last_bdm_regno
, ®len
);
151 for (i
= first_regno
; i
<= last_regno
; i
++)
153 int bdm_regno
, regoffset
;
155 bdm_regno
= bdm_regmap
[i
];
158 regoffset
= bdm_regno
- first_bdm_regno
;
160 if (regoffset
>= reglen
/ 4)
163 supply_register (i
, regs
+ 4 * regoffset
);
166 supply_register (i
, NULL
); /* Unsupported register */
170 /* Store register REGNO, or all registers if REGNO == -1, from the contents
171 of REGISTERS. FIXME: ignores errors. */
174 bdm_ppc_store_registers (regno
)
178 int first_regno
, last_regno
;
179 int first_bdm_regno
, last_bdm_regno
;
184 last_regno
= NUM_REGS
- 1;
187 last_bdm_regno
= BDM_NUM_REGS
- 1;
194 first_bdm_regno
= bdm_regmap
[regno
];
195 last_bdm_regno
= bdm_regmap
[regno
];
198 if (first_bdm_regno
== -1)
199 return; /* Unsupported register */
201 for (i
= first_regno
; i
<= last_regno
; i
++)
205 bdm_regno
= bdm_regmap
[i
];
207 ocd_write_bdm_registers (bdm_regno
, registers
+ REGISTER_BYTE (i
), 4);
211 /* Define the target subroutine names */
213 struct target_ops bdm_ppc_ops
= {
214 "ocd", /* to_shortname */
215 "", /* to_longname */
217 bdm_ppc_open
, /* to_open */
218 ocd_close
, /* to_close */
219 NULL
, /* to_attach */
220 ocd_detach
, /* to_detach */
221 ocd_resume
, /* to_resume */
222 bdm_ppc_wait
, /* to_wait */
223 bdm_ppc_fetch_registers
, /* to_fetch_registers */
224 bdm_ppc_store_registers
, /* to_store_registers */
225 ocd_prepare_to_store
, /* to_prepare_to_store */
226 ocd_xfer_memory
, /* to_xfer_memory */
227 ocd_files_info
, /* to_files_info */
228 memory_insert_breakpoint
, /* to_insert_breakpoint */
229 memory_remove_breakpoint
, /* to_remove_breakpoint */
230 NULL
, /* to_terminal_init */
231 NULL
, /* to_terminal_inferior */
232 NULL
, /* to_terminal_ours_for_output */
233 NULL
, /* to_terminal_ours */
234 NULL
, /* to_terminal_info */
235 ocd_kill
, /* to_kill */
236 ocd_load
, /* to_load */
237 NULL
, /* to_lookup_symbol */
238 ocd_create_inferior
, /* to_create_inferior */
239 ocd_mourn
, /* to_mourn_inferior */
241 0, /* to_notice_signals */
242 ocd_thread_alive
, /* to_thread_alive */
243 ocd_stop
, /* to_stop */
244 process_stratum
, /* to_stratum */
246 1, /* to_has_all_memory */
247 1, /* to_has_memory */
248 1, /* to_has_stack */
249 1, /* to_has_registers */
250 1, /* to_has_execution */
252 NULL
, /* sections_end */
253 OPS_MAGIC
/* to_magic */
257 _initialize_bdm_ppc ()
259 add_target (&bdm_ppc_ops
);
This page took 0.034303 seconds and 4 git commands to generate.