sim: mips: hoist "single" igen rules up to common builds
[binutils-gdb.git] / sim / mips / dv-tx3904cpu.c
index da28a49a60cabf7b984ab406fdd9ca82b8b94d98..56c23d8dad43f785c3bd36e28862fb2bdcccb37f 100644 (file)
@@ -1,8 +1,8 @@
 /*  This file is part of the program GDB, the GNU debugger.
 /*  This file is part of the program GDB, the GNU debugger.
-    
-    Copyright (C) 1998-2016 Free Software Foundation, Inc.
+
+    Copyright (C) 1998-2022 Free Software Foundation, Inc.
     Contributed by Cygnus Solutions.
     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 3 of the License, or
     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 3 of the License, or
 
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
-    
+
     */
 
     */
 
+/* This must come before any other includes.  */
+#include "defs.h"
 
 #include "sim-main.h"
 #include "hw-main.h"
 
 /* DEVICE
 
 
 #include "sim-main.h"
 #include "hw-main.h"
 
 /* DEVICE
 
-   
+
    tx3904cpu - tx3904 cpu virtual device
 
    tx3904cpu - tx3904 cpu virtual device
 
-   
+
    DESCRIPTION
 
    DESCRIPTION
 
-   
+
    Implements the external tx3904 functionality.  This includes the
    delivery of of interrupts generated from other devices and the
    handling of device specific registers.
 
 
    PROPERTIES
    Implements the external tx3904 functionality.  This includes the
    delivery of of interrupts generated from other devices and the
    handling of device specific registers.
 
 
    PROPERTIES
-   
+
    none
 
 
    none
 
 
@@ -86,7 +88,7 @@ struct tx3904cpu {
 
 
 
 
 
 
-/* input port ID's */ 
+/* input port ID's */
 
 enum {
   RESET_PORT,
 
 enum {
   RESET_PORT,
@@ -143,6 +145,9 @@ deliver_tx3904cpu_interrupt (struct hw *me,
   sim_cpu *cpu = STATE_CPU (sd, 0); /* NB: fix CPU 0. */
   address_word cia = CPU_PC_GET (cpu);
 
   sim_cpu *cpu = STATE_CPU (sd, 0); /* NB: fix CPU 0. */
   address_word cia = CPU_PC_GET (cpu);
 
+#define CPU cpu
+#define SD sd
+
   if (controller->pending_reset)
     {
       controller->pending_reset = 0;
   if (controller->pending_reset)
     {
       controller->pending_reset = 0;
@@ -165,13 +170,13 @@ deliver_tx3904cpu_interrupt (struct hw *me,
         was cleared with a negative pending_level. */
       CAUSE &= ~ (cause_IP_mask << cause_IP_shift);
 
         was cleared with a negative pending_level. */
       CAUSE &= ~ (cause_IP_mask << cause_IP_shift);
 
-      if(controller->pending_level > 0) /* interrupt set */
+      if (controller->pending_level > 0) /* interrupt set */
        {
          /* set hardware-interrupt subfields of CAUSE register */
          CAUSE |= (controller->pending_level & cause_IP_mask) << cause_IP_shift;
 
          /* check for enabled / unmasked interrupts */
        {
          /* set hardware-interrupt subfields of CAUSE register */
          CAUSE |= (controller->pending_level & cause_IP_mask) << cause_IP_shift;
 
          /* check for enabled / unmasked interrupts */
-         if((SR & status_IEc) &&
+         if ((SR & status_IEc) &&
             (controller->pending_level & ((SR >> status_IM_shift) & status_IM_mask)))
            {
              controller->pending_level = 0;
             (controller->pending_level & ((SR >> status_IM_shift) & status_IM_mask)))
            {
              controller->pending_level = 0;
@@ -180,13 +185,15 @@ deliver_tx3904cpu_interrupt (struct hw *me,
          else
            {
              /* reschedule soon */
          else
            {
              /* reschedule soon */
-             if(controller->event != NULL)
+             if (controller->event != NULL)
                hw_event_queue_deschedule(me, controller->event);
              controller->event =
                hw_event_queue_schedule (me, 1, deliver_tx3904cpu_interrupt, NULL);
            }
        } /* interrupt set */
     }
                hw_event_queue_deschedule(me, controller->event);
              controller->event =
                hw_event_queue_schedule (me, 1, deliver_tx3904cpu_interrupt, NULL);
            }
        } /* interrupt set */
     }
+#undef CPU
+#undef SD
 }
 
 
 }
 
 
@@ -200,26 +207,26 @@ tx3904cpu_port_event (struct hw *me,
   struct tx3904cpu *controller = hw_data (me);
 
   switch (my_port)
   struct tx3904cpu *controller = hw_data (me);
 
   switch (my_port)
-    {      
+    {
     case RESET_PORT:
       controller->pending_reset = 1;
       HW_TRACE ((me, "port-in reset"));
       break;
     case RESET_PORT:
       controller->pending_reset = 1;
       HW_TRACE ((me, "port-in reset"));
       break;
-      
+
     case NMI_PORT:
       controller->pending_nmi = 1;
       HW_TRACE ((me, "port-in nmi"));
       break;
     case NMI_PORT:
       controller->pending_nmi = 1;
       HW_TRACE ((me, "port-in nmi"));
       break;
-      
+
     case LEVEL_PORT:
       /* level == 0 means that the interrupt was cleared */
     case LEVEL_PORT:
       /* level == 0 means that the interrupt was cleared */
-      if(level == 0)
+      if (level == 0)
        controller->pending_level = -1; /* signal end of interrupt */
       else
        controller->pending_level = level;
       HW_TRACE ((me, "port-in level=%d", level));
       break;
        controller->pending_level = -1; /* signal end of interrupt */
       else
        controller->pending_level = level;
       HW_TRACE ((me, "port-in level=%d", level));
       break;
-      
+
     default:
       hw_abort (me, "bad switch");
       break;
     default:
       hw_abort (me, "bad switch");
       break;
@@ -227,7 +234,7 @@ tx3904cpu_port_event (struct hw *me,
 
   /* Schedule an event to be delivered immediately after current
      instruction. */
 
   /* Schedule an event to be delivered immediately after current
      instruction. */
-  if(controller->event != NULL)
+  if (controller->event != NULL)
     hw_event_queue_deschedule(me, controller->event);
   controller->event =
     hw_event_queue_schedule (me, 0, deliver_tx3904cpu_interrupt, NULL);
     hw_event_queue_deschedule(me, controller->event);
   controller->event =
     hw_event_queue_schedule (me, 0, deliver_tx3904cpu_interrupt, NULL);