+Wed Apr 2 17:09:12 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * remote-sim.h (sim_trace, sim_size): Make these global. They
+ will go away shortly.
+
+Wed Apr 2 15:23:49 1997 Doug Evans <dje@canuck.cygnus.com>
+
+ * remote-sim.h (SIM_OPEN_KIND, SIM_RC): New enums.
+ (sim_open): New argument `kind'.
+
Wed Apr 2 14:45:51 1997 Ian Lance Taylor <ian@cygnus.com>
* COPYING: Update FSF address.
void sim_set_callbacks PARAMS ((SIM_DESC sd, struct host_callback_struct *));
+
+/* NOTE: sim_size() and sim_trace() are going away */
+
+void sim_size PARAMS ((int i));
+
+int sim_trace PARAMS ((SIM_DESC sd));
+
+
#endif /* !defined (REMOTE_SIM_H) */
+Thu Apr 17 11:48:25 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * wrapper.c (sim_trace): Update so that it matches prototype.
+
+Mon Apr 7 15:45:02 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * configure: Regenerated to track ../common/aclocal.m4 changes.
+ * config.in: Ditto.
+
Mon Apr 7 12:01:17 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
* Makefile.in (armemu32.o): Replace $< with autoconf recommended
/* run front end support for arm
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
-This file is part of ARM SIM
+This file is part of ARM SIM.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* This file provides the interface between the simulator and run.c and gdb
+ (when the simulator is linked with gdb).
+ All simulator interaction should go through this file. */
#include <stdio.h>
#include <stdarg.h>
-#include <armdefs.h>
#include <bfd.h>
#include <signal.h>
#include "callback.h"
#include "remote-sim.h"
+#include "armdefs.h"
+#include "armemu.h"
+#include "dbg_rdi.h"
+
+host_callback *sim_callback;
+
static struct ARMul_State *state;
+/* Memory size in bytes. */
+static int mem_size = (1 << 21);
+
+/* Non-zero to display start up banner, and maybe other things. */
+static int verbosity;
+
static void
init ()
{
static int done;
+
if (!done)
{
ARMul_EmulateInit();
state = ARMul_NewState ();
- ARMul_MemoryInit(state, 1<<21);
+ ARMul_MemoryInit(state, mem_size);
ARMul_OSInit(state);
ARMul_CoProInit(state);
+ state->verbose = verbosity;
done = 1;
}
-
-}
-void
-ARMul_ConsolePrint (ARMul_State * state, const char *format,...)
-{
- va_list ap;
- va_start (ap, format);
- vprintf (format, ap);
- va_end (ap);
}
-ARMword
-ARMul_Debug (ARMul_State * state, ARMword pc, ARMword instr)
-{
+/* Set verbosity level of simulator.
+ This is not intended to produce detailed tracing or debugging information.
+ Just summaries. */
+/* FIXME: common/run.c doesn't do this yet. */
+void
+sim_set_verbose (v)
+ int v;
+{
+ verbosity = v;
}
+/* Set the memory size to SIZE bytes.
+ Must be called before initializing simulator. */
+/* FIXME: Rename to sim_set_mem_size. */
+
void
sim_size (size)
int size;
{
- init ();
- ARMul_MemoryInit (state, 1 << size);
+ mem_size = size;
}
-
void
-sim_set_profile ()
+ARMul_ConsolePrint (ARMul_State * state, const char *format,...)
{
+ va_list ap;
+
+ if (state->verbose)
+ {
+ va_start (ap, format);
+ vprintf (format, ap);
+ va_end (ap);
+ }
}
-void
-sim_set_profile_size ()
+
+ARMword
+ARMul_Debug (ARMul_State * state, ARMword pc, ARMword instr)
{
+
}
int
-sim_write (addr, buffer, size)
+sim_write (sd, addr, buffer, size)
+ SIM_DESC sd;
SIM_ADDR addr;
unsigned char *buffer;
int size;
}
int
-sim_read (addr, buffer, size)
+sim_read (sd, addr, buffer, size)
+ SIM_DESC sd;
SIM_ADDR addr;
unsigned char *buffer;
int size;
return size;
}
-void
-sim_trace ()
+int
+sim_trace (sd)
+ SIM_DESC sd;
{
+ (*sim_callback->printf_filtered) (sim_callback, "This simulator does not support tracing\n");
+ return 1;
}
-static int rc;
void
-sim_resume (step, siggnal)
+sim_resume (sd, step, siggnal)
+ SIM_DESC sd;
int step, siggnal;
{
+ state->EndCondition = 0;
+
if (step)
{
- rc = SIGTRAP;
- state->Reg[15] = ARMul_DoInstr (state);
+ state->Reg[15] = ARMul_DoInstr (state);
+ if (state->EndCondition == 0)
+ state->EndCondition = RDIError_BreakpointReached;
}
else
{
- state->Reg[15] = ARMul_DoProg (state);
+ state->Reg[15] = ARMul_DoProg (state);
}
+
+ FLUSHPIPE;
}
void
-sim_create_inferior (start_address, argv, env)
+sim_create_inferior (sd, start_address, argv, env)
+ SIM_DESC sd;
SIM_ADDR start_address;
char **argv;
char **env;
}
void
-sim_info (verbose)
+sim_info (sd, verbose)
+ SIM_DESC sd;
int verbose;
{
}
-int
+static int
frommem (state, memory)
struct ARMul_State *state;
unsigned char *memory;
}
-void
+static void
tomem (state, memory, val)
struct ARMul_State *state;
unsigned char *memory;
}
void
-sim_store_register (rn, memory)
+sim_store_register (sd, rn, memory)
+ SIM_DESC sd;
int rn;
unsigned char *memory;
{
}
void
-sim_fetch_register (rn, memory)
+sim_fetch_register (sd, rn, memory)
+ SIM_DESC sd;
int rn;
unsigned char *memory;
{
-void
-sim_open (name)
- char *name;
+SIM_DESC
+sim_open (kind, argv)
+ SIM_OPEN_KIND kind;
+ char **argv;
{
- /* nothing to do */
+ /* (*sim_callback->error) (sim_callback, "testing 1 2 3\n");*/
+ /* nothing to do, fudge our descriptor */
+ return (SIM_DESC) 1;
}
void
-sim_close (quitting)
+sim_close (sd, quitting)
+ SIM_DESC sd;
int quitting;
{
/* nothing to do */
}
int
-sim_load (prog, from_tty)
+sim_load (sd, prog, from_tty)
+ SIM_DESC sd;
char *prog;
int from_tty;
{
}
void
-sim_stop_reason (reason, sigrc)
+sim_stop_reason (sd, reason, sigrc)
+ SIM_DESC sd;
enum sim_stop *reason;
int *sigrc;
{
- *reason = sim_stopped;
- *sigrc = rc;
+ if (state->EndCondition == 0)
+ {
+ *reason = sim_exited;
+ *sigrc = state->Reg[0] & 255;
+ }
+ else
+ {
+ *reason = sim_stopped;
+ if (state->EndCondition == RDIError_BreakpointReached)
+ *sigrc = SIGTRAP;
+ else
+ *sigrc = 0;
+ }
}
+
void
-sim_kill ()
+sim_kill (sd)
+ SIM_DESC sd;
{
/* nothing to do */
}
void
-sim_do_command (cmd)
+sim_do_command (sd, cmd)
+ SIM_DESC sd;
char *cmd;
{
- printf_filtered ("This simulator does not accept any commands.\n");
+ (*sim_callback->printf_filtered) (sim_callback, "This simulator does not accept any commands.\n");
}
void
-sim_set_callbacks (ptr)
-struct host_callback_struct *ptr;
+sim_set_callbacks (sd, ptr)
+ SIM_DESC sd;
+ host_callback *ptr;
{
-
+ sim_callback = ptr;
}
+Wed Apr 16 16:12:03 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * simops.c (OP_5F00): Only provide system calls SYS_execv,
+ SYS_wait, SYS_wait, SYS_utime, SYS_time if defined by the host.
+
+Mon Apr 7 15:45:02 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * configure: Regenerated to track ../common/aclocal.m4 changes.
+ * config.in: Ditto.
+
Wed Apr 2 15:06:28 1997 Doug Evans <dje@canuck.cygnus.com>
* interp.c (sim_open): New arg `kind'.
(*d10v_callback->printf_filtered) (d10v_callback, " a0 a1 f0 f1 c\n");
}
- (*d10v_callback->printf_filtered) (d10v_callback, "Trap %2d 0x%.4x:", (int)OP[0], (int)PC);
+ (*d10v_callback->printf_filtered) (d10v_callback, "Trap %2d 0x%.4x:", (int)OP[0], (int)PC);
- for (i = 0; i < 16; i++)
- (*d10v_callback->printf_filtered) (d10v_callback, " %.4x", (int) State.regs[i]);
+ for (i = 0; i < 16; i++)
+ (*d10v_callback->printf_filtered) (d10v_callback, " %.4x", (int) State.regs[i]);
- for (i = 0; i < 2; i++)
- (*d10v_callback->printf_filtered) (d10v_callback, " %.2x%.8lx",
- ((int)(State.a[i] >> 32) & 0xff),
- ((unsigned long)State.a[i]) & 0xffffffff);
+ for (i = 0; i < 2; i++)
+ (*d10v_callback->printf_filtered) (d10v_callback, " %.2x%.8lx",
+ ((int)(State.a[i] >> 32) & 0xff),
+ ((unsigned long)State.a[i]) & 0xffffffff);
- (*d10v_callback->printf_filtered) (d10v_callback, " %d %d %d\n",
- State.F0 != 0, State.F1 != 0, State.C != 0);
- (*d10v_callback->flush_stdout) (d10v_callback);
- break;
+ (*d10v_callback->printf_filtered) (d10v_callback, " %d %d %d\n",
+ State.F0 != 0, State.F1 != 0, State.C != 0);
+ (*d10v_callback->flush_stdout) (d10v_callback);
+ break;
+ }
#endif
- case 0:
- /* Trap 0 is used for simulating low-level I/O */
+ case 0: /* old system call trap, to be deleted */
+ case 15: /* new system call trap */
+ /* Trap 15 is used for simulating low-level I/O */
{
errno = 0;
trace_output (OP_R2);
break;
+#ifdef SYS_execv
case SYS_execv:
RETVAL = execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL);
trace_input ("<execv>", OP_R2, OP_R3, OP_VOID);
trace_output (OP_R2);
break;
+#endif
case SYS_pipe:
{
}
break;
+#ifdef SYS_wait
case SYS_wait:
{
int status;
trace_output (OP_R2);
}
break;
+#endif
#else
case SYS_getpid:
trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
trace_output (OP_R2);
break;
+#ifdef SYS_utime
case SYS_utime:
/* Cast the second argument to void *, to avoid type mismatch
if a prototype is present. */
trace_input ("<utime>", OP_R2, OP_R3, OP_R4);
trace_output (OP_R2);
break;
+#endif
+#ifdef SYS_time
case SYS_time:
{
unsigned long ret = time (PARM1 ? MEMPTR (PARM1) : NULL);
trace_input ("<time>", OP_R2, OP_R3, OP_R4);
trace_output (OP_R2R3);
break;
+#endif
default:
abort ();
}
- RETERR = d10v_callback->get_errno(d10v_callback);
- break;
- }
-
- case 1:
- /* Trap 1 prints a string */
- {
- char *fstr = dmem_addr(State.regs[2]);
- fputs (fstr, stdout);
- break;
- }
-
- case 2:
- /* Trap 2 calls printf */
- {
- char *fstr = dmem_addr(State.regs[2]);
- (*d10v_callback->printf_filtered) (d10v_callback, fstr,
- (int16)State.regs[3],
- (int16)State.regs[4],
- (int16)State.regs[5]);
- (*d10v_callback->flush_stdout) (d10v_callback);
+ RETERR = (RETVAL == (uint16) -1) ? d10v_callback->get_errno(d10v_callback) : 0;
break;
}
-
- case 3:
- /* Trap 3 writes a character */
- putchar (State.regs[2]);
- break;
- }
}
}
+Wed Apr 16 17:55:37 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * interp.c (sim_size): Delete prototype - conflicts with
+ definition in remote-sim.h. Correct definition.
+
+Mon Apr 7 15:45:02 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * configure: Regenerated to track ../common/aclocal.m4 changes.
+ * config.in: Ditto.
+
Wed Apr 2 15:06:28 1997 Doug Evans <dje@canuck.cygnus.com>
* interp.c (sim_open): New arg `kind'.
#endif
char* pr_addr PARAMS ((SIM_ADDR addr));
+char* pr_uword64 PARAMS ((uword64 addr));
#ifndef SIGBUS
#define SIGBUS SIGSEGV
static void SignalException PARAMS((int exception,...));
static void simulate PARAMS((void));
static long getnum PARAMS((char *value));
-extern void sim_size PARAMS((unsigned int newsize));
extern void sim_set_profile PARAMS((int frequency));
static unsigned int power2 PARAMS((unsigned int value));
/*---------------------------------------------------------------------------*/
SIM_DESC
-sim_open (argv)
+sim_open (kind,argv)
+ SIM_OPEN_KIND kind;
char **argv;
{
if (callback == NULL) {
for (argc = 0; argv[argc]; argc++);
+ /* Ensure getopt is reset [don't know whether caller used it]. */
+ optind = 0;
+
while (1) {
int option_index = 0;
void
sim_size(newsize)
- unsigned int newsize;
+ int newsize;
{
char *new;
/* Used by "run", and internally, to set the simulated memory size */
#ifdef DEBUG
printf("DBG: LoadMemory() : (offset %d) : value = 0x%s%s\n",
- (int)(pAddr & LOADDRMASK),pr_addr(value1),pr_addr(value));
+ (int)(pAddr & LOADDRMASK),pr_uword64(value1),pr_uword64(value));
#endif /* DEBUG */
/* TODO: We could try and avoid the shifts when dealing with raw
#ifdef DEBUG
printf("DBG: LoadMemory() : shifted value = 0x%s%s\n",
- pr_addr(value1),pr_addr(value));
+ pr_uword64(value1),pr_uword64(value));
#endif /* DEBUG */
}
}
int raw;
{
#ifdef DEBUG
- callback->printf_filtered(callback,"DBG: StoreMemory(%d,%d,0x%s,0x%s,0x%s,0x%s,%s)\n",CCA,AccessLength,pr_addr(MemElem),pr_addr(MemElem1),pr_addr(pAddr),pr_addr(vAddr),(raw ? "isRAW" : "isREAL"));
+ callback->printf_filtered(callback,"DBG: StoreMemory(%d,%d,0x%s,0x%s,0x%s,0x%s,%s)\n",CCA,AccessLength,pr_uword64(MemElem),pr_uword64(MemElem1),pr_addr(pAddr),pr_addr(vAddr),(raw ? "isRAW" : "isREAL"));
#endif /* DEBUG */
#if defined(WARN_MEM)
int shift = 0;
#ifdef DEBUG
- printf("DBG: StoreMemory: offset = %d MemElem = 0x%s%s\n",(unsigned int)(pAddr & LOADDRMASK),pr_addr(MemElem1),pr_addr(MemElem));
+ printf("DBG: StoreMemory: offset = %d MemElem = 0x%s%s\n",(unsigned int)(pAddr & LOADDRMASK),pr_uword64(MemElem1),pr_uword64(MemElem));
#endif /* DEBUG */
if (AccessLength <= AccessLength_DOUBLEWORD) {
}
#ifdef DEBUG
- printf("DBG: StoreMemory: shift = %d MemElem = 0x%s%s\n",shift,pr_addr(MemElem1),pr_addr(MemElem));
+ printf("DBG: StoreMemory: shift = %d MemElem = 0x%s%s\n",shift,pr_uword64(MemElem1),pr_uword64(MemElem));
#endif /* DEBUG */
if (BigEndianMem) {
return paddr_str;
}
+char*
+pr_uword64(addr)
+ uword64 addr;
+{
+ char *paddr_str=get_cell();
+ sprintf(paddr_str,"%08x%08x",
+ (unsigned long)(addr>>thirty_two),(unsigned long)(addr&0xffffffff));
+ return paddr_str;
+}
+
+
/*---------------------------------------------------------------------------*/
/*> EOF interp.c <*/
+Wed Apr 16 19:30:44 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * simops.c (OP_F020): SYS_execv, SYS_time, SYS_times, SYS_utime
+ only include if implemented by host.
+ (OP_F020): Typecast arg passed to time function;
+
+Mon Apr 7 23:57:49 1997 Jeffrey A Law (law@cygnus.com)
+
+ * simops.c (syscall): Handle new mn10300 calling conventions.
+
Mon Apr 7 15:45:02 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
* configure: Regenerated to track ../common/aclocal.m4 changes.
RETVAL = execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2),
(char **)MEMPTR (PARM3));
break;
+#ifdef SYS_execv
case SYS_execv:
RETVAL = execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL);
break;
+#endif
#endif
case SYS_read:
case SYS_chmod:
RETVAL = chmod (MEMPTR (PARM1), PARM2);
break;
+#ifdef SYS_time
case SYS_time:
- RETVAL = time (MEMPTR (PARM1));
+ RETVAL = time ((void*) MEMPTR (PARM1));
break;
+#endif
+#ifdef SYS_times
case SYS_times:
{
struct tms tms;
store_mem (PARM1 + 12, 4, tms.tms_cstime);
break;
}
+#endif
case SYS_gettimeofday:
{
struct timeval t;
store_mem (PARM2 + 4, 4, tz.tz_dsttime);
break;
}
+#ifdef SYS_utime
case SYS_utime:
/* Cast the second argument to void *, to avoid type mismatch
if a prototype is present. */
RETVAL = utime (MEMPTR (PARM1), (void *) MEMPTR (PARM2));
break;
+#endif
default:
abort ();
}
+Wed Apr 16 19:53:55 1997 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * simops.c (OP_10007E0): Only provide system calls SYS_execv,
+ SYS_wait, SYS_wait, SYS_utime, SYS_time if defined by the host.
+
+Mon Apr 7 15:45:02 1997 Andrew Cagney <cagney@kremvax.cygnus.com>
+
+ * configure: Regenerated to track ../common/aclocal.m4 changes.
+ * config.in: Ditto.
+
Wed Apr 2 15:06:28 1997 Doug Evans <dje@canuck.cygnus.com>
* interp.c (sim_open): New arg `kind'.
-#include "config.h"
-
#include <signal.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#include "v850_sim.h"
#include "simops.h"
#include "sys/syscall.h"
#include "bfd.h"
#include <errno.h>
+#if !defined(__GO32__) && !defined(_WIN32)
#include <sys/stat.h>
#include <sys/times.h>
#include <sys/time.h>
+#endif
enum op_types {
OP_UNKNOWN,
OP_E0 ()
{
trace_input ("mulh", OP_REG_REG, 0);
- State.regs[OP[1]] = ((State.regs[OP[1]] & 0xffff)
- * (State.regs[OP[0]] & 0xffff));
+ State.regs[OP[1]] = (SEXT16 (State.regs[OP[1]])
+ * SEXT16 (State.regs[OP[0]]));
trace_output (OP_REG_REG);
}
int value = SEXT5 (OP[0]);
trace_input ("mulh", OP_IMM_REG, 0);
- State.regs[OP[1]] = (State.regs[OP[1]] & 0xffff) * value;
+ State.regs[OP[1]] = SEXT16 (State.regs[OP[1]]) * value;
trace_output (OP_IMM_REG);
}
void
OP_6E0 ()
{
- int value = OP[0] & 0xffff;
+ int value = SEXT16 (OP[0]);
trace_input ("mulhi", OP_IMM_REG_REG, 0);
- State.regs[OP[2]] = (State.regs[OP[1]] & 0xffff) * value;
+ State.regs[OP[2]] = SEXT16 (State.regs[OP[1]]) * value;
trace_output (OP_IMM_REG_REG);
}
RETVAL = execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2),
(char **)MEMPTR (PARM3));
break;
+#ifdef SYS_execv
case SYS_execv:
RETVAL = execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL);
break;
+#endif
#if 0
case SYS_pipe:
{
State.exception = SIG_V850_EXIT; /* PARM1 has exit status encoded */
break;
+#if !defined(__GO32__) && !defined(_WIN32)
case SYS_stat: /* added at hmsi */
/* stat system call */
{
case SYS_chmod:
RETVAL = chmod (MEMPTR (PARM1), PARM2);
break;
+#ifdef SYS_time
case SYS_time:
{
time_t now;
store_mem (PARM1, 4, now);
}
break;
+#endif
+#ifdef SYS_times
case SYS_times:
{
struct tms tms;
store_mem (PARM1 + 12, 4, tms.tms_cstime);
break;
}
+#endif
case SYS_gettimeofday:
{
struct timeval t;
store_mem (PARM2 + 4, 4, tz.tz_dsttime);
break;
}
+#ifdef SYS_utime
case SYS_utime:
/* Cast the second argument to void *, to avoid type mismatch
if a prototype is present. */
RETVAL = utime (MEMPTR (PARM1), (void *) MEMPTR (PARM2));
break;
+#endif
+#endif
default:
abort ();
}