1 /* gdb->simulator interface.
2 Copyright (C) 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
4 This file is part of Z8KSIM
6 Z8KSIM is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 Z8KSIM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Z8KZIM; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 #include "gdb/callback.h"
26 #include "gdb/remote-sim.h"
32 host_callback *z8k_callback;
34 static SIM_OPEN_KIND sim_kind;
45 sim_store_register (sd, regno, value, length)
51 /* FIXME: Review the computation of regval. */
52 int regval = (value[0] << 24) | (value[1] << 16) | (value[2] << 8) | value[3];
54 tm_store_register (regno, regval);
59 sim_fetch_register (sd, regno, buf, length)
65 tm_fetch_register (regno, buf);
70 sim_write (sd, where, what, howmuch)
78 for (i = 0; i < howmuch; i++)
79 tm_write_byte (where + i, what[i]);
84 sim_read (sd, where, what, howmuch)
92 for (i = 0; i < howmuch; i++)
93 what[i] = tm_read_byte (where + i);
98 control_c (sig, code, scp, addr)
104 tm_exception (SIM_INTERRUPT);
111 tm_exception (SIM_INTERRUPT);
116 sim_resume (sd, step, sig)
123 prev = signal (SIGINT, control_c);
125 signal (SIGINT, prev);
129 sim_stop_reason (sd, reason, sigrc)
131 enum sim_stop *reason;
134 switch (tm_signal ())
148 case SIM_SINGLE_STEP:
151 case SIM_BAD_SYSCALL:
161 *sigrc = x.regs[2].word & 255;
162 *reason = sim_exited;
168 *reason = sim_stopped;
172 sim_info (sd, verbose)
183 sim_open (kind, cb, abfd, argv)
189 /* FIXME: The code in sim_load that determines the exact z8k arch
190 should be moved to here */
196 /* fudge our descriptor for now */
201 sim_close (sd, quitting)
209 sim_load (sd, prog, abfd, from_tty)
215 extern bfd *sim_load_file (); /* ??? Don't know where this should live. */
218 /* FIXME: The code determining the type of z9k processor should be
219 moved from here to sim_open. */
221 prog_bfd = sim_load_file (sd, myname, z8k_callback, prog, abfd,
222 sim_kind == SIM_OPEN_DEBUG,
224 if (prog_bfd == NULL)
226 if (bfd_get_mach (prog_bfd) == bfd_mach_z8001)
228 extern int sim_z8001_mode;
231 /* Close the bfd if we opened it. */
233 bfd_close (prog_bfd);
238 sim_create_inferior (sd, abfd, argv, env)
245 tm_store_register (REG_PC, bfd_get_start_address (abfd));
247 tm_store_register (REG_PC, 0);
252 sim_do_command (sd, cmd)
259 sim_set_callbacks (ptr)