source: rtems/cpukit/score/cpu/lm32/irq.c @ 9ddff29

4.115
Last change on this file since 9ddff29 was 9ddff29, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/11/11 at 08:57:36

2011-02-11 Ralf Corsépius <ralf.corsepius@…>

  • cpu.c, irq.c, rtems/score/lm32.h: Use "asm" instead of "asm" for improved c99-compliance.
  • 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_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_disable_level--;
75
76  _CPU_ISR_Enable( level );
77
78  if ( _ISR_Nest_level )
79    return;
80
81  if ( _Thread_Dispatch_necessary ) {
82
83    /* save off our stack frame so the context switcher can get to it */
84    _exception_stack_frame = ifr;
85
86    _Thread_Dispatch();
87
88    /* and make sure its clear in case we didn't dispatch. if we did, its
89     * already cleared */
90    _exception_stack_frame = NULL;
91  }
92}
93
Note: See TracBrowser for help on using the repository browser.