This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / sim / mn10300 / dv-mn103iop.c
index 4e076479bc2a4ebf58753989ce4f8a498eff7cc2..f1379fc9b8dcd019a28fc141366e8736c60e8085 100644 (file)
@@ -25,7 +25,7 @@
 /* DEVICE
 
    
-   mn103ser - mn103002 I/O ports 0-3.
+   mn103iop - mn103002 I/O ports 0-3.
 
    
    DESCRIPTION
@@ -160,8 +160,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 +373,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 +400,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 +430,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 +457,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.025461 seconds and 4 git commands to generate.