Automatic date update in version.in
[deliverable/binutils-gdb.git] / sim / mn10300 / dv-mn103iop.c
index 4e076479bc2a4ebf58753989ce4f8a498eff7cc2..25acbb0421642458cb3c15a7c07c7dd055379715 100644 (file)
@@ -1,21 +1,20 @@
 /*  This file is part of the program GDB, the GNU debugger.
     
-    Copyright (C) 1998 Free Software Foundation, Inc.
+    Copyright (C) 1998-2020 Free Software Foundation, Inc.
     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/>.
     
     */
 
@@ -25,7 +24,7 @@
 /* DEVICE
 
    
-   mn103ser - mn103002 I/O ports 0-3.
+   mn103iop - mn103002 I/O ports 0-3.
 
    
    DESCRIPTION
@@ -160,8 +159,9 @@ mn103iop_finish (struct hw *me)
       io_port->port[i].control = 0;
       io_port->port[i].pin = 0;
     }
+  io_port->port[2].output_mode = 0xff;
   io_port->p2ss = 0;
-  io_port->p4ss = 0;
+  io_port->p4ss = 0x0f;
 }
 
 
@@ -372,9 +372,17 @@ write_output_reg (struct hw *me,
                  const void *source,
                  unsigned  nr_bytes)
 {
+  unsigned8 buf = *(unsigned8 *)source;
   if ( nr_bytes == 1 )
     {
-      io_port->port[io_port_reg].output = *(unsigned16 *)source;
+      if ( io_port_reg == 3 && (buf & 0xfc) != 0 )
+       {
+         hw_abort(me, "Cannot write to read-only bits of P3OUT.");
+       }
+      else
+       {
+         io_port->port[io_port_reg].output = buf;
+       }
     }
   else
     {
@@ -391,11 +399,20 @@ write_output_mode_reg (struct hw *me,
                       const void *source,
                       unsigned  nr_bytes)
 {
+  unsigned8 buf = *(unsigned8 *)source;
   if ( nr_bytes == 1 )
     {
       /* check if there are fields which can't be written and
         take appropriate action depending what bits are set */
-      io_port->port[io_port_reg].output_mode = *(unsigned8 *)source;
+      if ( ( io_port_reg == 3 && (buf & 0xfc) != 0 )
+          || ( (io_port_reg == 0 || io_port_reg == 1)  && (buf & 0xfe) != 0 ) )
+       {
+         hw_abort(me, "Cannot write to read-only bits of output mode register.");
+       }
+      else
+       {
+         io_port->port[io_port_reg].output_mode = buf;
+       }
     }
   else
     {
@@ -412,9 +429,17 @@ write_control_reg (struct hw *me,
                   const void *source,
                   unsigned  nr_bytes)
 {
+  unsigned8 buf = *(unsigned8 *)source;
   if ( nr_bytes == 1 )
     {
-      io_port->port[io_port_reg].control = *(unsigned8 *)source;
+      if ( io_port_reg == 3 && (buf & 0xfc) != 0 )
+       {
+         hw_abort(me, "Cannot write to read-only bits of P3DIR.");
+       }
+      else
+       {
+         io_port->port[io_port_reg].control = buf;
+       }
     }
   else
     {
@@ -431,16 +456,31 @@ write_dedicated_control_reg (struct hw *me,
                             const void *source,
                             unsigned  nr_bytes)
 {
+  unsigned8 buf = *(unsigned8 *)source;
   if ( nr_bytes == 1 )
     {
       /* select on io_port_reg: */
       if ( io_port_reg == P2SS )
        {
-         io_port->p2ss = *(unsigned8 *)source;
+         if ( (buf & 0xfc)  != 0 )
+           {
+             hw_abort(me, "Cannot write to read-only bits in p2ss.");
+           }
+         else
+           {
+             io_port->p2ss = buf;
+           }
        }
       else
        {
-         io_port->p4ss = *(unsigned8 *)source;
+         if ( (buf & 0xf0) != 0 )
+           {
+             hw_abort(me, "Cannot write to read-only bits in p4ss.");
+           }
+         else
+           {
+             io_port->p4ss = buf;
+           }
        }
     }
   else
This page took 0.030899 seconds and 4 git commands to generate.