sim: overhaul alignment settings management
[deliverable/binutils-gdb.git] / sim / avr / interp.c
index cce84a97f220fb23cd5bc86cef64b39ba7f34623..1626fadaa973cedf5a6e1cda2ec2d5c3a9f3ce2a 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include "config.h"
+/* This must come before any other includes.  */
+#include "defs.h"
 
 #include <string.h>
 
 #include "bfd.h"
 #include "libiberty.h"
-#include "gdb/remote-sim.h"
+#include "sim/sim.h"
 
 #include "sim-main.h"
 #include "sim-base.h"
@@ -726,13 +727,13 @@ decode (unsigned int pc)
 static void
 do_call (SIM_CPU *cpu, unsigned int npc)
 {
-  SIM_DESC sd = CPU_STATE (cpu);
+  const struct avr_sim_state *state = AVR_SIM_STATE (CPU_STATE (cpu));
   unsigned int sp = read_word (REG_SP);
 
   /* Big endian!  */
   sram[sp--] = cpu->pc;
   sram[sp--] = cpu->pc >> 8;
-  if (sd->avr_pc22)
+  if (state->avr_pc22)
     {
       sram[sp--] = cpu->pc >> 16;
       cpu->cycles++;
@@ -892,9 +893,9 @@ step_once (SIM_CPU *cpu)
        /* Fall through */
       case OP_ret:
        {
-         SIM_DESC sd = CPU_STATE (cpu);
+         const struct avr_sim_state *state = AVR_SIM_STATE (CPU_STATE (cpu));
          unsigned int sp = read_word (REG_SP);
-         if (sd->avr_pc22)
+         if (state->avr_pc22)
            {
              cpu->pc = sram[++sp] << 16;
              cpu->cycles++;
@@ -1680,11 +1681,14 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
          struct bfd *abfd, char * const *argv)
 {
   int i;
-  SIM_DESC sd = sim_state_alloc (kind, cb);
+  SIM_DESC sd = sim_state_alloc_extra (kind, cb, sizeof (struct avr_sim_state));
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
+  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
@@ -1751,6 +1755,7 @@ SIM_RC
 sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
                     char * const *argv, char * const *env)
 {
+  struct avr_sim_state *state = AVR_SIM_STATE (sd);
   SIM_CPU *cpu = STATE_CPU (sd, 0);
   SIM_ADDR addr;
 
@@ -1762,7 +1767,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
   sim_pc_set (cpu, addr);
 
   if (abfd != NULL)
-    sd->avr_pc22 = (bfd_get_mach (abfd) >= bfd_mach_avr6);
+    state->avr_pc22 = (bfd_get_mach (abfd) >= bfd_mach_avr6);
 
   return SIM_RC_OK;
 }
This page took 0.023822 seconds and 4 git commands to generate.