source: rtems/cpukit/score/cpu/lm32/irq.c @ 180b106

4.115
Last change on this file since 180b106 was 180b106, checked in by Sebastian Huber <sebastian.huber@…>, on 08/18/11 at 06:45:35

2011-08-18 Sebastien Bourdeauducq <sebastien.bourdeauducq@…>

PR 1868/lm32

  • irq.c: Bugfix.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  lm32 interrupt handler
3 *
4 *  Derived from c4x/irq.c and nios2/irq.c
5 *
6 *  COPYRIGHT (c) 1989-2009.
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$
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/thread.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/percpu.h>
25
26/*
27 *  This routine provides the RTEMS interrupt management.
28 *
29 *  Upon entry, interrupts are disabled
30 */
31
32#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
33  unsigned long    *_old_stack_ptr;
34#endif
35
36void *_exception_stack_frame;
37
38register unsigned long  *stack_ptr __asm__ ("sp");
39
40void __ISR_Handler(uint32_t vector, CPU_Interrupt_frame *ifr)
41{
42  register uint32_t   level;
43  _exception_stack_frame = NULL;
44
45  /* Interrupts are disabled upon entry to this Handler */
46
47  _Thread_Dispatch_increment_disable_level();
48
49#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
50  if ( _ISR_Nest_level == 0 ) {
51    /* Install irq stack */
52    _old_stack_ptr = stack_ptr;
53    stack_ptr = _CPU_Interrupt_stack_high - 4;
54  }
55#endif
56
57  _ISR_Nest_level++;
58
59  if ( _ISR_Vector_table[ vector] )
60  {
61    (*_ISR_Vector_table[ vector ])(vector, ifr);
62  };
63
64  /* Make sure that interrupts are disabled again */
65  _CPU_ISR_Disable( level );
66
67  _ISR_Nest_level--;
68
69#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
70  if( _ISR_Nest_level == 0)
71    stack_ptr = _old_stack_ptr;
72#endif
73
74  _Thread_Dispatch_decrement_disable_level();
75
76  _CPU_ISR_Enable( level );
77
78  if ( _ISR_Nest_level )
79    return;
80
81  if ( _Thread_Dispatch_necessary && !_Thread_Dispatch_in_critical_section() ) {
82    /* save off our stack frame so the context switcher can get to it */
83    _exception_stack_frame = ifr;
84
85    _Thread_Dispatch();
86
87    /* and make sure its clear in case we didn't dispatch. if we did, its
88     * already cleared */
89    _exception_stack_frame = NULL;
90  }
91}
92
Note: See TracBrowser for help on using the repository browser.