Fix clearing of interrupts in 68hc11 simulator
authorStephane Carrez <stcarrez@nerim.fr>
Sun, 10 Sep 2000 12:58:53 +0000 (12:58 +0000)
committerStephane Carrez <stcarrez@nerim.fr>
Sun, 10 Sep 2000 12:58:53 +0000 (12:58 +0000)
sim/m68hc11/ChangeLog
sim/m68hc11/interrupts.c

index 0f25891fb1240d47ca379bbc9d64c15c2acc0a41..89d6cfbc1ad9e48ffa0a59fa253776ac2d2c224c 100644 (file)
@@ -1,3 +1,9 @@
+2000-09-10  Stephane Carrez  <Stephane.Carrez@worldnet.fr>
+
+       * interrupts.c (interrupts_update_pending): Clear the mask of
+       pending interrupts here.
+       (interrupts_get_current): Don't clear the mask of pending interrupts.
+
 2000-09-10  Stephane Carrez  <Stephane.Carrez@worldnet.fr>
 
        * sim-main.h: Define cycle_to_string.
index 655c4006f9d3b68ca793d84081b32b23558821ed..44771bb4e03f426f81cfee7beb2ca9f1f96ab319 100644 (file)
@@ -102,13 +102,21 @@ interrupts_update_pending (struct interrupts *interrupts)
        {
          data = ioregs[idef->enable_paddr];
          if (!(data & idef->enabled_mask))
-           continue;
+            {
+              /* Disable it.  */
+              interrupts->pending_mask &= ~(1 << idef->int_number);
+              continue;
+            }
        }
 
       /* Interrupt is enabled, see if it's there.  */
       data = ioregs[idef->int_paddr];
       if (!(data & idef->int_mask))
-       continue;
+        {
+          /* Disable it.  */
+          interrupts->pending_mask &= ~(1 << idef->int_number);
+          continue;
+        }
 
       /* Ok, raise it.  */
       interrupts->pending_mask |= (1 << idef->int_number);
@@ -159,14 +167,17 @@ interrupts_get_current (struct interrupts *interrupts)
     }
 
   /* Returns the first interrupt number which is pending.
-     The interrupt priority is specified by the table `interrupt_order'.  */
+     The interrupt priority is specified by the table `interrupt_order'.
+     For these interrupts, the pending mask is cleared when the program
+     performs some actions on the corresponding device.  If the device
+     is not reset, the interrupt remains and will be re-raised when
+     we return from the interrupt (see 68HC11 pink book).  */
   for (i = 0; i < M6811_INT_NUMBER; i++)
     {
       enum M6811_INT int_number = interrupts->interrupt_order[i];
 
       if (interrupts->pending_mask & (1 << int_number))
        {
-         interrupts->pending_mask &= ~(1 << int_number);
          return int_number;
        }
     }