unit at a time
[platform/upstream/binutils.git] / sim / mn10300 / dv-mn103cpu.c
index 87c684e..04b7077 100644 (file)
@@ -1,27 +1,26 @@
-/*  This file is part of the program GDB, the GU debugger.
+/*  This file is part of the program GDB, the GNU debugger.
     
-    Copyright (C) 1998 Free Software Foundation, Inc.
+    Copyright (C) 1998-2014 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-base.h"
+#include "hw-main.h"
 
 /* DEVICE
 
@@ -33,7 +32,7 @@
 
    
    Implements the external mn10300 functionality.  This includes the
-   delivery of of interrupts generated from other devices and the
+   delivery of interrupts generated from other devices and the
    handling of device specific registers.
 
 
@@ -72,7 +71,7 @@
    ack (output)
 
    Output signal indicating that the processor is delivering a level
-   interrupt.  The value passed with the event specfies the level of
+   interrupt.  The value passed with the event specifies the level of
    the interrupt being delivered.
 
 
@@ -107,7 +106,7 @@ struct mn103cpu_block {
 
 struct mn103cpu {
   struct mn103cpu_block block;
-  hw_event *pending_handler;
+  struct hw_event *pending_handler;
   int pending_level;
   int pending_nmi;
   int pending_reset;
@@ -128,7 +127,7 @@ enum {
 };
 
 
-/* input port ID's */
+/* output port ID's */
 
 enum {
   ACK_PORT,
@@ -151,9 +150,9 @@ static const struct hw_port_descriptor mn103cpu_ports[] = {
 /* Finish off the partially created hw device.  Attach our local
    callbacks.  Wire up our port names etc */
 
-static hw_io_read_buffer_callback mn103cpu_io_read_buffer;
-static hw_io_write_buffer_callback mn103cpu_io_write_buffer;
-static hw_port_event_callback mn103cpu_port_event;
+static hw_io_read_buffer_method mn103cpu_io_read_buffer;
+static hw_io_write_buffer_method mn103cpu_io_write_buffer;
+static hw_port_event_method mn103cpu_port_event;
 
 static void
 attach_mn103cpu_regs (struct hw *me,
@@ -228,7 +227,7 @@ deliver_mn103cpu_interrupt (struct hw *me,
   else if (controller->pending_nmi)
     {
       controller->pending_nmi = 0;
-      store_half (SP - 4, CIA_GET (cpu));
+      store_word (SP - 4, CIA_GET (cpu));
       store_half (SP - 8, PSW);
       PSW &= ~PSW_IE;
       SP = SP - 8;
@@ -241,7 +240,7 @@ deliver_mn103cpu_interrupt (struct hw *me,
     {
       /* Don't clear pending level.  Request continues to be pending
          until the interrupt controller clears/changes it */
-      store_half (SP - 4, CIA_GET (cpu));
+      store_word (SP - 4, CIA_GET (cpu));
       store_half (SP - 8, PSW);
       PSW &= ~PSW_IE;
       PSW &= ~PSW_LM;
@@ -249,20 +248,26 @@ deliver_mn103cpu_interrupt (struct hw *me,
       SP = SP - 8;
       CIA_SET (cpu, 0x40000000 + controller->interrupt_vector[controller->pending_level]);
       HW_TRACE ((me, "port-out ack %d", controller->pending_level));
-      hw_port_event (me, ACK_PORT, controller->pending_level, NULL, NULL_CIA);
+      hw_port_event (me, ACK_PORT, controller->pending_level);
       HW_TRACE ((me, "int level=%d pc=0x%08lx psw=0x%04x sp=0x%08lx",
                 controller->pending_level,
                 (long) CIA_GET (cpu), (unsigned) PSW, (long) SP));
     }
 
-  /* As long as there is the potential need to deliver an interrupt we
-     keep rescheduling this routine. */
   if (controller->pending_level < 7) /* FIXME */
     {
+      /* As long as there is the potential need to deliver an
+        interrupt we keep rescheduling this routine. */
       if (controller->pending_handler != NULL)
        controller->pending_handler =
          hw_event_queue_schedule (me, 1, deliver_mn103cpu_interrupt, NULL);
     }
+  else
+    {
+      /* Don't bother re-scheduling the interrupt handler as there is
+         nothing to deliver */
+      controller->pending_handler = NULL;
+    }
 
 }
 
@@ -272,9 +277,7 @@ mn103cpu_port_event (struct hw *me,
                     int my_port,
                     struct hw *source,
                     int source_port,
-                    int level,
-                    sim_cpu *processor,
-                    sim_cia cia)
+                    int level)
 {
   struct mn103cpu *controller = hw_data (me);
 
@@ -349,9 +352,7 @@ mn103cpu_io_read_buffer (struct hw *me,
                         void *dest,
                         int space,
                         unsigned_word base,
-                        unsigned nr_bytes,
-                        sim_cpu *processor,
-                        sim_cia cia)
+                        unsigned nr_bytes)
 {
   struct mn103cpu *controller = hw_data (me);
   unsigned16 val = 0;
@@ -390,9 +391,7 @@ mn103cpu_io_write_buffer (struct hw *me,
                          const void *source,
                          int space,
                          unsigned_word base,
-                         unsigned nr_bytes,
-                         sim_cpu *cpu,
-                         sim_cia cia)
+                         unsigned nr_bytes)
 {
   struct mn103cpu *controller = hw_data (me);
   unsigned16 val;
@@ -425,7 +424,7 @@ mn103cpu_io_write_buffer (struct hw *me,
 }     
 
 
-const struct hw_device_descriptor dv_mn103cpu_descriptor[] = {
+const struct hw_descriptor dv_mn103cpu_descriptor[] = {
   { "mn103cpu", mn103cpu_finish, },
   { NULL },
 };