This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Interrupt attach patch (2)


Cyg_Interrupt:attach updates the interrupt level before installing the vector. Depending on the hardware, updating the interrupt level can immediately cause an interrupt, resulting in the interrupt occurring before the handler is installed.

NOTE: I sent an incorrect patch earlier, but hopefully this won't reach you because I didn't reply to the gmane authorizer.
? interrupt.patch
? packages/packages
Index: packages/kernel/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/ChangeLog,v
retrieving revision 1.141
diff -u -5 -p -r1.141 ChangeLog
--- packages/kernel/current/ChangeLog	8 Jan 2007 16:20:13 -0000	1.141
+++ packages/kernel/current/ChangeLog	4 May 2007 10:44:48 -0000
@@ -1,5 +1,13 @@
+2207-05-04 Dave Lawrence
+        * src/intr/intr.cxx Cyg_Interrupt::attach(void)
+        Do not update interrupt level until after the handler
+        pointer has been installed in the vector table.  On some
+        hardware it may be impossible to ensure that there is no
+        interrupt pending so the handler must be in place before
+        the interrupt has a chance of being triggered.
+
 2007-01-07  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/sync/mbox.cxx (Cyg_Mbox::get): Fix compiler warning with gcc
 	version 4.1.2.
 
Index: packages/kernel/current/src/intr/intr.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/src/intr/intr.cxx,v
retrieving revision 1.18
diff -u -5 -p -r1.18 intr.cxx
--- packages/kernel/current/src/intr/intr.cxx	11 Aug 2006 09:29:31 -0000	1.18
+++ packages/kernel/current/src/intr/intr.cxx	4 May 2007 10:44:49 -0000
@@ -454,12 +454,10 @@ Cyg_Interrupt::attach(void)
     CYG_ASSERT( vector >= CYGNUM_HAL_ISR_MIN, "Invalid vector");
     CYG_ASSERT( vector <= CYGNUM_HAL_ISR_MAX, "Invalid vector");
 
     CYG_INSTRUMENT_INTR(ATTACH, vector, 0);
 
-    HAL_INTERRUPT_SET_LEVEL( vector, priority );
-    
 #ifdef CYGIMP_KERNEL_INTERRUPTS_CHAIN
 
     CYG_ASSERT( next == NULL , "Cyg_Interrupt already on a list");
 
     cyg_uint32 index;
@@ -494,10 +492,12 @@ Cyg_Interrupt::attach(void)
             p = &n->next;
         }
         next = *p;
         *p = this;
     }
+
+    HAL_INTERRUPT_SET_LEVEL( vector, priority );
     
 #else
     
     {
         int in_use;
@@ -505,10 +505,11 @@ Cyg_Interrupt::attach(void)
 
         HAL_INTERRUPT_IN_USE( vector, in_use );
         CYG_ASSERT( 0 == in_use, "Interrupt vector not free.");
 
         HAL_INTERRUPT_ATTACH( vector, isr, data, this );
+        HAL_INTERRUPT_SET_LEVEL( vector, priority );
     }
 
 #endif    
     CYG_REPORT_RETURN();
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]