]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/d10v/interp.c
2002-05-28 Elena Zannoni <ezannoni@redhat.com>
[thirdparty/binutils-gdb.git] / sim / d10v / interp.c
index 33b5dca30a5cc7c8a0102c5b5161d8bf23618206..0b02d8aea9b71ac9280f75304fa9c712460386c5 100644 (file)
@@ -5,7 +5,7 @@
 #include "remote-sim.h"
 
 #include "d10v_sim.h"
-#include "sim-d10v.h"
+#include "gdb/sim-d10v.h"
 
 enum _leftright { LEFT_FIRST, RIGHT_FIRST };
 
@@ -99,8 +99,6 @@ lookup_hash (ins, size)
     {
       if (h->next == NULL)
        {
-         (*d10v_callback->printf_filtered)
-           (d10v_callback, "ERROR: Illegal instruction %x at PC %x\n", ins, PC);
          State.exception = SIGILL;
          State.pc_changed = 1; /* Don't increment the PC. */
          return NULL;
@@ -965,6 +963,32 @@ sim_resume (sd, step, siggnal)
   if (step)
     sim_stop (sd);
 
+  switch (siggnal)
+    {
+    case 0:
+      break;
+#ifdef SIGBUS
+    case SIGBUS:
+#endif
+    case SIGSEGV:
+      SET_BPC (PC);
+      SET_BPSW (PSW);
+      SET_HW_PSW ((PSW & (PSW_F0_BIT | PSW_F1_BIT | PSW_C_BIT)));
+      JMP (AE_VECTOR_START);
+      SLOT_FLUSH ();
+      break;
+    case SIGILL:
+      SET_BPC (PC);
+      SET_BPSW (PSW);
+      SET_HW_PSW ((PSW & (PSW_F0_BIT | PSW_F1_BIT | PSW_C_BIT)));
+      JMP (RIE_VECTOR_START);
+      SLOT_FLUSH ();
+      break;
+    default:
+      /* just ignore it */
+      break;
+    }
+
   do
     {
       iaddr = imem_addr ((uint32)PC << 2);
@@ -1053,15 +1077,12 @@ sim_resume (sd, step, siggnal)
     State.exception = SIGTRAP;
 }
 
-int
-sim_trace (sd)
-     SIM_DESC sd;
+void
+sim_set_trace (void)
 {
 #ifdef DEBUG
   d10v_debug = DEBUG;
 #endif
-  sim_resume (sd, 0, 0);
-  return 1;
 }
 
 void
@@ -1181,24 +1202,13 @@ sim_create_inferior (sd, abfd, argv, env)
   /* reset all state information */
   memset (&State.regs, 0, (int)&State.mem - (int)&State.regs);
 
-  if (argv)
-    {
-      /* a hack to set r0/r1 with argc/argv */
-      /* some high memory that won't be overwritten by the stack soon */
-      bfd_vma addr = 0x7C00;
-      int p = 20;
-      int i = 0;
-      while (argv[i])
-       {
-         int size = strlen (argv[i]) + 1;
-         SW (addr + 2*i, addr + p); 
-         sim_write (sd, addr + 0, argv[i], size);
-         p += size;
-         i++;
-       }
-      SET_GPR (0, addr);
-      SET_GPR (1, i);
-    }
+  /* There was a hack here to copy the values of argc and argv into r0
+     and r1.  The values were also saved into some high memory that
+     won't be overwritten by the stack (0x7C00).  The reason for doing
+     this was to allow the 'run' program to accept arguments.  Without
+     the hack, this is not possible anymore.  If the simulator is run
+     from the debugger, arguments cannot be passed in, so this makes
+     no difference.  */
 
   /* set PC */
   if (abfd != NULL)
@@ -1231,7 +1241,8 @@ sim_create_inferior (sd, abfd, argv, env)
       set_imap_register (1, 0x1000);
       set_dmap_register (0, 0x2000);
       set_dmap_register (1, 0x2000);
-      set_dmap_register (2, 0x0000); /* Old DMAP, Value is not 0x2000 */
+      set_dmap_register (2, 0x2000); /* DMAP2 initial internal value is
+                                       0x2000 on the new board. */
       set_dmap_register (3, 0x0000);
     }
 
@@ -1267,6 +1278,15 @@ sim_stop_reason (sd, reason, sigrc)
       *sigrc = GPR (0);
       break;
 
+    case SIG_D10V_BUS:
+      *reason = sim_stopped;
+#ifdef SIGBUS
+      *sigrc = SIGBUS;
+#else
+      *sigrc = SIGSEGV;
+#endif
+      break;
+
     default:                           /* some signal */
       *reason = sim_stopped;
       if (stop_simulator && !State.exception)