]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/m68hc11/interp.c
sim: overhaul & unify endian settings management
[thirdparty/binutils-gdb.git] / sim / m68hc11 / interp.c
index 03cb7fcf4ae9f7bdf5edf0588e81345f55cd031c..7d28f40d71dd811a73e1bc4f5356d0fda614d073 100644 (file)
@@ -1,5 +1,5 @@
 /* interp.c -- Simulator for Motorola 68HC11/68HC12
-   Copyright (C) 1999-2020 Free Software Foundation, Inc.
+   Copyright (C) 1999-2021 Free Software Foundation, Inc.
    Written by Stephane Carrez (stcarrez@nerim.fr)
 
 This file is part of GDB, the GNU debugger.
@@ -17,6 +17,9 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "defs.h"
+
 #include "sim-main.h"
 #include "sim-assert.h"
 #include "sim-hw.h"
@@ -100,7 +103,7 @@ sim_get_info (SIM_DESC sd, char *cmd)
          sim_io_eprintf (sd, "Valid devices: cpu timer sio eeprom\n");
          return;
        }
-      hw_dev = sim_hw_parse (sd, dev_list[i].device);
+      hw_dev = sim_hw_parse (sd, "%s", dev_list[i].device);
       if (hw_dev == 0)
        {
          sim_io_eprintf (sd, "Device '%s' not found\n", dev_list[i].device);
@@ -138,7 +141,7 @@ sim_board_reset (SIM_DESC sd)
       cpu_type = "/m68hc12";
     }
   
-  hw_cpu = sim_hw_parse (sd, cpu_type);
+  hw_cpu = sim_hw_parse (sd, "%s", cpu_type);
   if (hw_cpu == 0)
     {
       sim_io_eprintf (sd, "%s cpu not found in device tree.", cpu_type);
@@ -172,7 +175,7 @@ sim_hw_configure (SIM_DESC sd)
          /* Allocate core managed memory */
 
          /* the monitor  */
-         sim_do_commandf (sd, "memory region 0x%lx@%d,0x%lx",
+         sim_do_commandf (sd, "memory region 0x%x@%d,0x%x",
                           /* MONITOR_BASE, MONITOR_SIZE */
                           0x8000, M6811_RAM_LEVEL, 0x8000);
          sim_do_commandf (sd, "memory region 0x000@%d,0x8000",
@@ -180,7 +183,7 @@ sim_hw_configure (SIM_DESC sd)
          sim_hw_parse (sd, "/m68hc11/reg 0x1000 0x03F");
           if (cpu->bank_start < cpu->bank_end)
             {
-              sim_do_commandf (sd, "memory region 0x%lx@%d,0x100000",
+              sim_do_commandf (sd, "memory region 0x%x@%d,0x100000",
                                cpu->bank_virtual, M6811_RAM_LEVEL);
               sim_hw_parse (sd, "/m68hc11/use_bank 1");
             }
@@ -234,13 +237,13 @@ sim_hw_configure (SIM_DESC sd)
       if (hw_tree_find_property (device_tree, "/m68hc12/reg") == 0)
        {
          /* Allocate core external memory.  */
-         sim_do_commandf (sd, "memory region 0x%lx@%d,0x%lx",
+         sim_do_commandf (sd, "memory region 0x%x@%d,0x%x",
                           0x8000, M6811_RAM_LEVEL, 0x8000);
          sim_do_commandf (sd, "memory region 0x000@%d,0x8000",
                           M6811_RAM_LEVEL);
           if (cpu->bank_start < cpu->bank_end)
             {
-              sim_do_commandf (sd, "memory region 0x%lx@%d,0x100000",
+              sim_do_commandf (sd, "memory region 0x%x@%d,0x100000",
                                cpu->bank_virtual, M6811_RAM_LEVEL);
               sim_hw_parse (sd, "/m68hc12/use_bank 1");
             }
@@ -403,8 +406,11 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
 
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  current_target_byte_order = BFD_ENDIAN_BIG;
+
   /* 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;