merge from gcc
[external/binutils.git] / sim / m68hc11 / interrupts.h
index 39069cd..9965615 100644 (file)
@@ -1,22 +1,22 @@
 /* interrupts.h -- 68HC11 Interrupts Emulation
-   Copyright 1999, 2000 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Written by Stephane Carrez (stcarrez@worldnet.fr)
 
 This file is part of GDB, GAS, and the GNU binutils.
 
-GDB, GAS, and the GNU binutils are free software; you can redistribute
-them and/or modify them under the terms of the GNU General Public
-License as published by the Free Software Foundation; either version
-1, or (at your option) any later version.
+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
+(at your option) any later version.
 
-GDB, GAS, and the GNU binutils are distributed in the hope that they
-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.
+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 file; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef _M6811_SIM_INTERRUPTS_H
 #define _M6811_SIM_INTERRUPTS_H
@@ -79,6 +79,39 @@ struct interrupt_def
   unsigned char    enabled_mask;
 };
 
+#define MAX_INT_HISTORY 64
+
+/* Structure used to keep track of interrupt history.
+   This is used to understand in which order interrupts were
+   raised and when.  */
+struct interrupt_history
+{
+  enum M6811_INT   type;
+
+  /* CPU cycle when interrupt handler is called.  */
+  signed64         taken_cycle;   
+
+  /* CPU cycle when the interrupt is first raised by the device.  */
+  signed64         raised_cycle;
+};
+
+#define SIM_STOP_WHEN_RAISED 1
+#define SIM_STOP_WHEN_TAKEN  2
+
+/* Information and control of pending interrupts.  */
+struct interrupt
+{
+  /* CPU cycle when the interrupt is raised by the device.  */
+  signed64         cpu_cycle;
+
+  /* Number of times the interrupt was raised.  */
+  unsigned long    raised_count;
+
+  /* Controls whether we must stop the simulator.  */
+  int              stop_mode;
+};
+
+
 /* Management of 68HC11 interrupts:
     - We use a table of 'interrupt_def' to describe the interrupts that must be
       raised depending on IO register flags (enable and present flags).
@@ -102,6 +135,7 @@ struct interrupts {
   /* Priority order of interrupts.  This is controlled by setting the HPRIO
      IO register.  */
   enum M6811_INT    interrupt_order[M6811_INT_NUMBER];
+  struct interrupt  interrupts[M6811_INT_NUMBER];
 
   /* Simulator statistics to report useful debug information to users.  */
 
@@ -109,17 +143,25 @@ struct interrupts {
   signed64          start_mask_cycle;
   signed64          min_mask_cycles;
   signed64          max_mask_cycles;
+  signed64          last_mask_cycles;
 
   /* - Same for XIRQ.  */
   signed64          xirq_start_mask_cycle;
   signed64          xirq_min_mask_cycles;
   signed64          xirq_max_mask_cycles;
+  signed64          xirq_last_mask_cycles;
 
   /* - Total number of interrupts raised.  */
   unsigned long     nb_interrupts_raised;
+
+  /* Interrupt history to help understand which interrupts
+     were raised recently and in which order.  */
+  int               history_index;
+  struct interrupt_history interrupts_history[MAX_INT_HISTORY];
 };
 
-extern int  interrupts_initialize     (struct _sim_cpu* cpu);
+extern void interrupts_initialize     (SIM_DESC sd, struct _sim_cpu* cpu);
+extern void interrupts_reset          (struct interrupts* interrupts);
 extern void interrupts_update_pending (struct interrupts* interrupts);
 extern int  interrupts_get_current    (struct interrupts* interrupts);
 extern int  interrupts_process        (struct interrupts* interrupts);