merge from gcc
[external/binutils.git] / sim / mn10300 / dv-mn103int.c
index 3056331..7ba0b9d 100644 (file)
@@ -1,27 +1,27 @@
 /*  This file is part of the program GDB, the GNU debugger.
     
-    Copyright (C) 1998 Free Software Foundation, Inc.
+    Copyright (C) 1998, 2007, 2008, 2009, 2010 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/>.
     
     */
 
 
 #include "sim-main.h"
 #include "hw-main.h"
+#include "sim-hw.h"
 
 /* DEVICE
 
@@ -41,7 +41,7 @@
 
    reg = <icr-adr> <icr-siz> <iagr-adr> <iadr-siz> <extmd-adr> <extmd-siz>
 
-   Specify the address of the ICR (total of 25 registers), IAGR and
+   Specify the address of the ICR (total of 30 registers), IAGR and
    EXTMD registers (within the parent bus).
 
    The reg property value `0x34000100 0x7C 0x34000200 0x8 0x3400280
@@ -291,6 +291,9 @@ static const struct hw_port_descriptor mn103int_ports[] = {
 static hw_io_read_buffer_method mn103int_io_read_buffer;
 static hw_io_write_buffer_method mn103int_io_write_buffer;
 static hw_port_event_method mn103int_port_event;
+static hw_ioctl_method mn103int_ioctl;
+
+
 
 static void
 attach_mn103int_regs (struct hw *me,
@@ -336,6 +339,7 @@ mn103int_finish (struct hw *me)
   set_hw_io_write_buffer (me, mn103int_io_write_buffer);
   set_hw_ports (me, mn103int_ports);
   set_hw_port_event (me, mn103int_port_event);
+  me->to_ioctl = mn103int_ioctl;
 
   /* Attach ourself to our parent bus */
   attach_mn103int_regs (me, controller);
@@ -344,15 +348,16 @@ mn103int_finish (struct hw *me)
   for (gid = 0; gid < NR_GROUPS; gid++)
     {
       struct mn103int_group *group = &controller->group[gid];
-      group->enable = 0xf;
       group->trigger = NEGATIVE_EDGE;
       group->gid = gid;
       if (FIRST_NMI_GROUP <= gid && gid <= LAST_NMI_GROUP)
        {
+         group->enable = 0xf;
          group->type = NMI_GROUP;
        }
       else if (FIRST_LEVEL_GROUP <= gid && gid <= LAST_LEVEL_GROUP)
        {
+         group->enable = 0x0;
          group->type = LEVEL_GROUP;
        }
       else
@@ -579,6 +584,12 @@ write_icr (struct hw *me,
                     group->gid, val));
          group->request &= ~EXTRACT_ID (val);
          break;
+         /* Special backdoor access to SYSEF flag from CPU.  See
+             interp.c:program_interrupt(). */
+       case 3:
+         HW_TRACE ((me, "write-icr-special group=%d:0 nmi 0x%02x",
+                    group->gid, val));
+         group->request |= EXTRACT_ID (val);
        default:
          break;
        }
@@ -801,6 +812,17 @@ mn103int_io_write_buffer (struct hw *me,
   return nr_bytes;
 }     
 
+static int
+mn103int_ioctl(struct hw *me,
+              hw_ioctl_request request,
+              va_list ap)
+{
+  struct mn103int *controller = (struct mn103int *)hw_data(me);
+  controller->group[0].request = EXTRACT_ID(4);
+  mn103int_port_event(me, 2 /* nmi_port(syserr) */, NULL, 0, 0);
+  return 0;
+}
+
 
 const struct hw_descriptor dv_mn103int_descriptor[] = {
   { "mn103int", mn103int_finish, },