Updated copyright notices for most files.
[deliverable/binutils-gdb.git] / sim / m68hc11 / dv-m68hc11.c
index 21064296adbb7cf8d1ca4a066ede130deccbaff7..0ac12c0c64f94a61167254719d6be215961ae902 100644 (file)
@@ -1,21 +1,21 @@
 /*  dv-m68hc11.c -- CPU 68HC11&68HC12 as a device.
-    Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
-    Written by Stephane Carrez (stcarrez@worldnet.fr)
+    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2007, 2008
+    Free Software Foundation, Inc.
+    Written by Stephane Carrez (stcarrez@nerim.fr)
     (From a driver model Contributed by Cygnus Solutions.)
     
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
+    the Free Software Foundation; either version 3 of the License, or
     (at your option) any later version.
-    
+
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     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, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
     */
 
@@ -24,6 +24,7 @@
 #include "sim-hw.h"
 #include "hw-main.h"
 #include "sim-options.h"
+#include "hw-base.h"
 #include <limits.h>
 
 /* DEVICE
@@ -159,6 +160,7 @@ enum {
   SET_PORT_A,
   SET_PORT_C,
   SET_PORT_D,
+  CPU_WRITE_PORT,
   PORT_A,
   PORT_B,
   PORT_C,
@@ -178,6 +180,8 @@ static const struct hw_port_descriptor m68hc11cpu_ports[] = {
   { "set-port-c", SET_PORT_C,    0, input_port, },
   { "set-port-d", SET_PORT_D,    0, input_port, },
 
+  { "cpu-write-port", CPU_WRITE_PORT,    0, input_port, },
+
   /* Events generated for connection to other devices.  */
   { "cpu-reset", CPU_RESET_PORT, 0, output_port, },
 
@@ -317,6 +321,13 @@ attach_m68hc11_regs (struct hw *me,
       cpu->cpu_frequency = 8*1000*1000;
     }
 
+  if (hw_find_property (me, "use_bank") != NULL)
+    hw_attach_address (hw_parent (me), 0,
+                       exec_map,
+                       cpu->bank_start,
+                       cpu->bank_end - cpu->bank_start,
+                       me);
+
   cpu_mode = "expanded";
   if (hw_find_property (me, "mode") != NULL)
     cpu_mode = hw_find_string_property (me, "mode");
@@ -532,6 +543,9 @@ m68hc11cpu_port_event (struct hw *me,
       m68hc11cpu_set_port (me, cpu, M6811_PORTD, level);
       break;
 
+    case CPU_WRITE_PORT:
+      break;
+
     default:
       hw_abort (me, "bad switch");
       break;
@@ -794,13 +808,15 @@ m68hc11_option_handler (SIM_DESC sd, sim_cpu *cpu,
                                "      %d       %d    %35.35s\n",
                                osc->name, freq,
                                cur_value, next_value,
-                               cycle_to_string (cpu, t));
+                               cycle_to_string (cpu, t,
+                                                PRINT_TIME | PRINT_CYCLE));
               else
                 sim_io_printf (sd, " %4.4s  %8.8s hz "
                                "      %d       %d    %35.35s\n",
                                osc->name, freq,
                                cur_value, next_value,
-                               cycle_to_string (cpu, t));
+                               cycle_to_string (cpu, t,
+                                                PRINT_TIME | PRINT_CYCLE));
             }
         }
       break;      
@@ -829,6 +845,14 @@ m68hc11cpu_io_read_buffer (struct hw *me,
   sd  = hw_system (me);
   cpu = STATE_CPU (sd, 0);
 
+  if (base >= cpu->bank_start && base < cpu->bank_end)
+    {
+      address_word virt_addr = phys_to_virt (cpu, base);
+      if (virt_addr != base)
+        return sim_core_read_buffer (sd, cpu, space, dest,
+                                     virt_addr, nr_bytes);
+    }
+
   /* Handle reads for the sub-devices.  */
   base -= controller->attach_address;
   result = sim_core_read_buffer (sd, cpu,
@@ -842,7 +866,7 @@ m68hc11cpu_io_read_buffer (struct hw *me,
        break;
 
       memcpy (dest, &cpu->ios[base], 1);
-      dest++;
+      dest = (char*) dest + 1;
       base++;
       byte++;
       nr_bytes--;
@@ -1068,6 +1092,14 @@ m68hc11cpu_io_write_buffer (struct hw *me,
 
   sd = hw_system (me); 
   cpu = STATE_CPU (sd, 0);  
+
+  if (base >= cpu->bank_start && base < cpu->bank_end)
+    {
+      address_word virt_addr = phys_to_virt (cpu, base);
+      if (virt_addr != base)
+        return sim_core_write_buffer (sd, cpu, space, source,
+                                      virt_addr, nr_bytes);
+    }
   base -= controller->attach_address;
   result = sim_core_write_buffer (sd, cpu,
                                  io_map, source, base, nr_bytes);
@@ -1083,7 +1115,7 @@ m68hc11cpu_io_write_buffer (struct hw *me,
 
       val = *((uint8*) source);
       m68hc11cpu_io_write (me, cpu, base, val);
-      source++;
+      source = (char*) source + 1;
       base++;
       byte++;
       nr_bytes--;
This page took 0.029431 seconds and 4 git commands to generate.