source: rtems/cpukit/score/cpu/nios2/irq.c @ 67518231

4.115
Last change on this file since 67518231 was e2d0c68, checked in by Sebastian Huber <sebastian.huber@…>, on 09/01/11 at 15:52:12

2011-09-01 Sebastian Huber <sebastian.huber@…>

  • cpu.c, cpu_asm.S: Removed files.
  • nios2-context-initialize.c, nios2-context-switch.S, nios2-fatal-halt.c, nios2-initialize-vectors.c, nios2-initialize.c, nios2-isr-get-level.c, nios2-isr-install-raw-handler.c, nios2-isr-install-vector.c, nios2-isr-is-in-progress.c, nios2-isr-set-level.c, nios2-thread-dispatch-disabled.c, rtems/score/nios2-utility.h: New files.
  • Makefile.am, preinstall.am: Reflect changes above.
  • irq.c: Update due to API changes.
  • rtems/score/cpu.h: New functions _CPU_Initialize_vectors(), _CPU_ISR_Set_level(), and _CPU_Fatal_halt() (instead of macros). Support for external interrupt controller (EIC). Documentation changes.
  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 *  NIOS2 exception and interrupt handler
3 *
4 *  Derived from c4x/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$
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#include <rtems/score/nios2-utility.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
36register unsigned long  *stack_ptr __asm__ ("sp");
37
38RTEMS_INLINE_ROUTINE void __IIC_Handler(void)
39{
40  uint32_t active;
41  uint32_t mask;
42  uint32_t vector;
43
44  /*
45   * Obtain from the interrupt controller a bit list of pending interrupts,
46   * and then process the highest priority interrupt. This process loops,
47   * loading the active interrupt list on each pass until ipending
48   * return zero.
49   *
50   * The maximum interrupt latency for the highest priority interrupt is
51   * reduced by finding out which interrupts are pending as late as possible.
52   * Consider the case where the high priority interupt is asserted during
53   * the interrupt entry sequence for a lower priority interrupt to see why
54   * this is the case.
55   */
56
57  active = _Nios2_Get_ctlreg_ipending();
58
59  while (active)
60  {
61    vector = 0;
62    mask = 1;
63
64    /*
65     * Test each bit in turn looking for an active interrupt. Once one is
66     * found call it to clear the interrupt condition.
67     */
68
69    while (active)
70    {
71      if (active & mask)
72      {
73        if ( _ISR_Vector_table[ vector] )
74          (*_ISR_Vector_table[ vector ])(vector, NULL);
75        active &= ~mask;
76      }
77      mask <<= 1;
78      ++vector;
79    };
80
81    active = _Nios2_Get_ctlreg_ipending();
82  }
83 
84}
85
86void __ISR_Handler(void)
87{
88  register uint32_t level;
89
90  /* Interrupts are disabled upon entry to this Handler */
91
92#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
93  if ( _ISR_Nest_level == 0 ) {
94    /* Install irq stack */
95    _old_stack_ptr = stack_ptr;
96    stack_ptr = _CPU_Interrupt_stack_high - 4;
97  }
98#endif
99
100  _ISR_Nest_level++;
101
102  _Thread_Dispatch_increment_disable_level();
103
104  __IIC_Handler();
105 
106  /* Make sure that interrupts are disabled again */
107  _CPU_ISR_Disable( level );
108
109  _Thread_Dispatch_decrement_disable_level();
110
111  _ISR_Nest_level--;
112
113  if( _ISR_Nest_level == 0) {
114#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
115    stack_ptr = _old_stack_ptr;
116#endif
117
118    if( !_Thread_Dispatch_in_critical_section() )
119    {
120      if ( _Thread_Dispatch_necessary ) {
121        _CPU_ISR_Enable( level );
122        _Thread_Dispatch();
123        /* may have switched to another task and not return here immed. */
124        _CPU_ISR_Disable( level ); /* Keep _pairs_ of Enable/Disable */
125      }
126    }
127  }
128
129  _CPU_ISR_Enable( level );
130}
131
132void __Exception_Handler(CPU_Exception_frame *efr)
133{
134  _CPU_Fatal_halt(0xECC0);
135}
Note: See TracBrowser for help on using the repository browser.