1 /* run front end support for arm
2 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
4 This file is part of ARM SIM.
6 GNU CC 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 GNU CC 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 this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 /* This file provides the interface between the simulator and run.c and gdb
21 (when the simulator is linked with gdb).
22 All simulator interaction should go through this file. */
29 #include "remote-sim.h"
34 host_callback *sim_callback;
36 static struct ARMul_State *state;
38 /* Memory size in bytes. */
39 static int mem_size = (1 << 21);
41 /* Non-zero to display start up banner, and maybe other things. */
52 state = ARMul_NewState ();
53 ARMul_MemoryInit(state, mem_size);
55 ARMul_CoProInit(state);
56 state->verbose = verbosity;
61 /* Set verbosity level of simulator.
62 This is not intended to produce detailed tracing or debugging information.
64 /* FIXME: common/run.c doesn't do this yet. */
73 /* Set the memory size to SIZE bytes.
74 Must be called before initializing simulator. */
75 /* FIXME: Rename to sim_set_mem_size. */
85 ARMul_ConsolePrint (ARMul_State * state, const char *format,...)
91 va_start (ap, format);
98 ARMul_Debug (ARMul_State * state, ARMword pc, ARMword instr)
104 sim_write (sd, addr, buffer, size)
107 unsigned char *buffer;
112 for (i = 0; i < size; i++)
114 ARMul_WriteByte (state, addr+i, buffer[i]);
120 sim_read (sd, addr, buffer, size)
123 unsigned char *buffer;
128 for (i = 0; i < size; i++)
130 buffer[i] = ARMul_ReadByte (state, addr + i);
139 (*sim_callback->printf_filtered) (sim_callback, "This simulator does not support tracing\n");
144 sim_resume (sd, step, siggnal)
148 state->EndCondition = 0;
152 state->Reg[15] = ARMul_DoInstr (state);
153 if (state->EndCondition == 0)
154 state->EndCondition = RDIError_BreakpointReached;
158 state->Reg[15] = ARMul_DoProg (state);
165 sim_create_inferior (sd, start_address, argv, env)
167 SIM_ADDR start_address;
171 ARMul_SetPC(state, start_address);
175 sim_info (sd, verbose)
183 frommem (state, memory)
184 struct ARMul_State *state;
185 unsigned char *memory;
187 if (state->bigendSig == HIGH)
189 return (memory[0] << 24)
196 return (memory[3] << 24)
205 tomem (state, memory, val)
206 struct ARMul_State *state;
207 unsigned char *memory;
210 if (state->bigendSig == HIGH)
212 memory[0] = val >> 24;
213 memory[1] = val >> 16;
214 memory[2] = val >> 8;
215 memory[3] = val >> 0;
219 memory[3] = val >> 24;
220 memory[2] = val >> 16;
221 memory[1] = val >> 8;
222 memory[0] = val >> 0;
227 sim_store_register (sd, rn, memory)
230 unsigned char *memory;
233 ARMul_SetReg(state, state->Mode, rn, frommem (state, memory));
237 sim_fetch_register (sd, rn, memory)
240 unsigned char *memory;
243 tomem (state, memory, ARMul_GetReg(state, state->Mode, rn));
250 sim_open (kind, argv)
254 /* (*sim_callback->error) (sim_callback, "testing 1 2 3\n");*/
255 /* nothing to do, fudge our descriptor */
260 sim_close (sd, quitting)
268 sim_load (sd, prog, from_tty)
273 /* Return nonzero so GDB will handle it. */
278 sim_stop_reason (sd, reason, sigrc)
280 enum sim_stop *reason;
283 if (state->EndCondition == 0)
285 *reason = sim_exited;
286 *sigrc = state->Reg[0] & 255;
290 *reason = sim_stopped;
291 if (state->EndCondition == RDIError_BreakpointReached)
306 sim_do_command (sd, cmd)
310 (*sim_callback->printf_filtered) (sim_callback, "This simulator does not accept any commands.\n");
315 sim_set_callbacks (sd, ptr)