Make the assembler generate an error if there is an attempt to define a section with...
[deliverable/binutils-gdb.git] / sim / mn10300 / interp.c
index f6f093d6a8c5300a86a440ffef7e957ed2282ceb..7f0655f3f472ef1a660a29f25c2fd01c2db163f8 100644 (file)
@@ -24,7 +24,6 @@
 #include "bfd.h"
 
 
-host_callback *mn10300_callback;
 struct _state State;
 
 
@@ -87,17 +86,19 @@ mn10300_pc_set (sim_cpu *cpu, sim_cia pc)
   PC = pc;
 }
 
+static int mn10300_reg_fetch (SIM_CPU *, int, unsigned char *, int);
+static int mn10300_reg_store (SIM_CPU *, int, unsigned char *, int);
+
 /* These default values correspond to expected usage for the chip.  */
 
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind,
          host_callback *cb,
          struct bfd *abfd,
-         char **argv)
+         char * const *argv)
 {
   int i;
   SIM_DESC sd = sim_state_alloc (kind, cb);
-  mn10300_callback = cb;
 
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
@@ -124,9 +125,7 @@ sim_open (SIM_OPEN_KIND kind,
   sim_do_command (sd, "memory region 0,0x100000");
   sim_do_command (sd, "memory region 0x40000000,0x200000");
 
-  /* getopt will print the error message so we just have to exit if this fails.
-     FIXME: Hmmm...  in the case of gdb we need getopt to call
-     print_filtered.  */
+  /* The parser will print an error message for us, so we silently return.  */
   if (sim_parse_args (sd, argv) != SIM_RC_OK)
     {
       /* Uninstall the modules to avoid memory leaks,
@@ -310,6 +309,8 @@ sim_open (SIM_OPEN_KIND kind,
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = mn10300_reg_fetch;
+      CPU_REG_STORE (cpu) = mn10300_reg_store;
       CPU_PC_FETCH (cpu) = mn10300_pc_get;
       CPU_PC_STORE (cpu) = mn10300_pc_set;
     }
@@ -317,19 +318,11 @@ sim_open (SIM_OPEN_KIND kind,
   return sd;
 }
 
-
-void
-sim_close (SIM_DESC sd, int quitting)
-{
-  sim_module_uninstall (sd);
-}
-
-
 SIM_RC
 sim_create_inferior (SIM_DESC sd,
                     struct bfd *prog_bfd,
-                    char **argv,
-                    char **env)
+                    char * const *argv,
+                    char * const *env)
 {
   memset (&State, 0, sizeof (State));
   if (prog_bfd != NULL) {
@@ -348,68 +341,23 @@ sim_create_inferior (SIM_DESC sd,
 /* FIXME These would more efficient to use than load_mem/store_mem,
    but need to be changed to use the memory map.  */
 
-uint8
-get_byte (uint8 *x)
-{
-  return *x;
-}
-
-uint16
-get_half (uint8 *x)
-{
-  uint8 *a = x;
-  return (a[1] << 8) + (a[0]);
-}
-
-uint32
-get_word (uint8 *x)
-{
-  uint8 *a = x;
-  return (a[3]<<24) + (a[2]<<16) + (a[1]<<8) + (a[0]);
-}
-
-void
-put_byte (uint8 *addr, uint8 data)
-{
-  uint8 *a = addr;
-  a[0] = data;
-}
-
-void
-put_half (uint8 *addr, uint16 data)
-{
-  uint8 *a = addr;
-  a[0] = data & 0xff;
-  a[1] = (data >> 8) & 0xff;
-}
-
-void
-put_word (uint8 *addr, uint32 data)
-{
-  uint8 *a = addr;
-  a[0] = data & 0xff;
-  a[1] = (data >> 8) & 0xff;
-  a[2] = (data >> 16) & 0xff;
-  a[3] = (data >> 24) & 0xff;
-}
-
-int
-sim_fetch_register (SIM_DESC sd,
-                   int rn,
-                   unsigned char *memory,
-                   int length)
+static int
+mn10300_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  put_word (memory, State.regs[rn]);
+  reg_t reg = State.regs[rn];
+  uint8 *a = memory;
+  a[0] = reg;
+  a[1] = reg >> 8;
+  a[2] = reg >> 16;
+  a[3] = reg >> 24;
   return length;
 }
  
-int
-sim_store_register (SIM_DESC sd,
-                   int rn,
-                   unsigned char *memory,
-                   int length)
+static int
+mn10300_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  State.regs[rn] = get_word (memory);
+  uint8 *a = memory;
+  State.regs[rn] = (a[3] << 24) + (a[2] << 16) + (a[1] << 8) + a[0];
   return length;
 }
 
@@ -465,10 +413,7 @@ program_interrupt (SIM_DESC sd,
 
   /* avoid infinite recursion */
   if (in_interrupt)
-    {
-      (*mn10300_callback->printf_filtered) (mn10300_callback, 
-                                           "ERROR: recursion in program_interrupt during software exception dispatch.");
-    }
+    sim_io_printf (sd, "ERROR: recursion in program_interrupt during software exception dispatch.");
   else
     {
       in_interrupt = 1;
@@ -629,7 +574,7 @@ reg2val_64 (const void *reg, sim_fpu *val)
 /* Round the given sim_fpu value to double precision, following the
    target platform rounding and denormalization conventions.  On
    AM33/2.0, round_near is the only rounding mode.  */
-int
+static int
 round_64 (sim_fpu *val)
 {
   return sim_fpu_round_64 (val, sim_fpu_round_near, sim_fpu_denorm_zero);
@@ -657,7 +602,7 @@ fp_double_prec = {
 
 /* Check whether overflow, underflow or inexact exceptions should be
    raised.  */
-int
+static int
 fpu_status_ok (sim_fpu_status stat)
 {
   if ((stat & sim_fpu_status_overflow)
This page took 0.028815 seconds and 4 git commands to generate.