This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 30th, 2011  |  syntax: None  |  size: 2.32 KB  |  views: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  *  lm32 exception and interrupt handler
  3.  *
  4.  *  Derived from c4x/irq.c and nios2/irq.c
  5.  *
  6.  *  COPYRIGHT (c) 1989-2007.
  7.  *  On-Line Applications Research Corporation (OAR).
  8.  *
  9.  *  The license and distribution terms for this file may be
  10.  *  found in the file LICENSE in this distribution or at
  11.  *  http://www.rtems.com/license/LICENSE.
  12.  *
  13.  *  $Id: irq.c,v 1.9 2011/04/21 19:05:14 jennifer Exp $
  14.  */
  15.  
  16. #ifdef HAVE_CONFIG_H
  17. #include "config.h"
  18. #endif
  19.  
  20. #include <rtems/system.h>
  21. #include <rtems/score/cpu.h>
  22. #include <rtems/score/isr.h>
  23. #include <rtems/score/thread.h>
  24.  
  25. /*
  26.  *  This routine provides the RTEMS interrupt management.
  27.  *
  28.  *  Upon entry, interrupts are disabled
  29.  */
  30.  
  31. #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
  32.   unsigned long    *_old_stack_ptr;
  33. #endif
  34.  
  35. void *_exception_stack_frame;
  36.  
  37. register unsigned long  *stack_ptr __asm__ ("sp");
  38.  
  39. void __ISR_Handler(uint32_t vector, CPU_Interrupt_frame *ifr)
  40. {
  41.   register uint32_t   level;
  42.   _exception_stack_frame = NULL;
  43.  
  44.   /* Interrupts are disabled upon entry to this Handler */
  45.  
  46. #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
  47.   if ( _ISR_Nest_level == 0 ) {
  48.     /* Install irq stack */
  49.     _old_stack_ptr = stack_ptr;
  50.     stack_ptr = _CPU_Interrupt_stack_high - 4;
  51.   }
  52. #endif
  53.  
  54.   _ISR_Nest_level++;
  55.  
  56.   _Thread_Dispatch_increment_disable_level();
  57.  
  58.   if ( _ISR_Vector_table[ vector] )
  59.   {
  60.     (*_ISR_Vector_table[ vector ])(vector, ifr);
  61.   };
  62.  
  63.   /* Make sure that interrupts are disabled again */
  64.   _CPU_ISR_Disable( level );
  65.  
  66.   _Thread_Dispatch_decrement_disable_level();
  67.  
  68.   _ISR_Nest_level--;
  69.  
  70.   if( _ISR_Nest_level == 0) {
  71. #if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
  72.     stack_ptr = _old_stack_ptr;
  73. #endif
  74.  
  75.     if( !_Thread_Dispatch_in_critical_section() )
  76.     {
  77.       if ( _Thread_Dispatch_necessary ) {
  78.         _CPU_ISR_Enable( level );
  79.         /* save off our stack frame so the context switcher can get to it */
  80.         _exception_stack_frame = ifr;
  81.         _Thread_Dispatch();
  82.         /* and make sure its clear in case we didn't dispatch. if we did, its
  83.          * already cleared */
  84.         _exception_stack_frame = NULL;
  85.         /* may have switched to another task and not return here immed. */
  86.         _CPU_ISR_Disable( level ); /* Keep _pairs_ of Enable/Disable */
  87.       }
  88.     }
  89.   }
  90.  
  91.   _CPU_ISR_Enable( level );
  92. }
clone this paste RAW Paste Data