* hppa.h (pa_opcodes): Use "cX" completer instead of "cx" in fstqx
[external/binutils.git] / sim / avr / interp.c
index e4e80c3..941aea7 100644 (file)
@@ -1,5 +1,5 @@
 /* Simulator for Atmel's AVR core.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009-2012 Free Software Foundation, Inc.
    Written by Tristan Gingold, AdaCore.
 
    This file is part of GDB, the GNU debugger.
@@ -870,7 +870,7 @@ sim_resume (SIM_DESC sd, int step, int signal)
   if (step)
     {
       cpu_exception = sim_stopped;
-      cpu_signal = TARGET_SIGNAL_TRAP;
+      cpu_signal = GDB_SIGNAL_TRAP;
     }
   else
     cpu_exception = sim_running;
@@ -985,7 +985,7 @@ sim_resume (SIM_DESC sd, int step, int signal)
            unsigned int sp = read_word (REG_SP);
            if (avr_pc22)
              {
-               pc = sram[++sp] = pc << 16;
+               pc = sram[++sp] << 16;
                cycles++;
              }
            else
@@ -1000,7 +1000,7 @@ sim_resume (SIM_DESC sd, int step, int signal)
        case OP_break:
          /* Stop on this address.  */
          cpu_exception = sim_stopped;
-         cpu_signal = TARGET_SIGNAL_TRAP;
+         cpu_signal = GDB_SIGNAL_TRAP;
          pc = ipc;
          break;
 
@@ -1622,22 +1622,26 @@ sim_trace (SIM_DESC sd)
 }
 
 int
-sim_write (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
+sim_write (SIM_DESC sd, SIM_ADDR addr, const unsigned char *buffer, int size)
 {
   int osize = size;
 
   if (addr >= 0 && addr < SRAM_VADDR)
     {
-      if (addr & 1)
-       return 0;
-      addr /= 2;
-      while (size > 1 && addr < MAX_AVR_FLASH)
+      while (size > 0 && addr < (MAX_AVR_FLASH << 1))
        {
-         flash[addr].op = buffer[0] | (buffer[1] << 8);
-         flash[addr].code = OP_unknown;
+          word val = flash[addr >> 1].op;
+
+          if (addr & 1)
+            val = (val & 0xff) | (buffer[0] << 8);
+          else
+            val = (val & 0xff00) | buffer[0];
+
+         flash[addr >> 1].op = val;
+         flash[addr >> 1].code = OP_unknown;
          addr++;
-         buffer += 2;
-         size -= 2;
+         buffer++;
+         size--;
        }
       return osize - size;
     }
@@ -1660,16 +1664,16 @@ sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
 
   if (addr >= 0 && addr < SRAM_VADDR)
     {
-      if (addr & 1)
-       return 0;
-      addr /= 2;
-      while (size > 1 && addr < MAX_AVR_FLASH)
+      while (size > 0 && addr < (MAX_AVR_FLASH << 1))
        {
-         buffer[0] = flash[addr].op;
-         buffer[1] = flash[addr].op >> 8;
+          word val = flash[addr >> 1].op;
+
+          if (addr & 1)
+            val >>= 8;
+
+          *buffer++ = val;
          addr++;
-         buffer += 2;
-         size -= 2;
+         size--;
        }
       return osize - size;
     }
@@ -1759,8 +1763,8 @@ int
 sim_stop (SIM_DESC sd)
 {
   cpu_exception = sim_stopped;
-  cpu_signal = TARGET_SIGNAL_INT;
-  return 0;
+  cpu_signal = GDB_SIGNAL_INT;
+  return 1;
 }
 
 void
@@ -1793,6 +1797,10 @@ sim_load (SIM_DESC sd, char *prog, bfd *abfd, int from_tty)
 {
   bfd *prog_bfd;
 
+  /* Clear all the memory.  */
+  memset (sram, 0, sizeof (sram));
+  memset (flash, 0, sizeof (flash));
+
   prog_bfd = sim_load_file (sd, myname, callback, prog, abfd,
                             sim_kind == SIM_OPEN_DEBUG,
                             0, sim_write);
@@ -1845,3 +1853,9 @@ sim_set_callbacks (host_callback *ptr)
 {
   callback = ptr; 
 }
+
+char **
+sim_complete_command (SIM_DESC sd, char *text, char *word)
+{
+  return NULL;
+}