source: rtems/cpukit/score/cpu/nios2/nios2-iic-irq.c @ 2afb22b

5
Last change on this file since 2afb22b was d2bacb6c, checked in by Sebastian Huber <sebastian.huber@…>, on 05/17/16 at 13:57:48

score: _Thread_Dispatch_increment_disable_level()

Avoid _Thread_Dispatch_increment_disable_level() and
_Thread_Dispatch_decrement_disable_level() and thus the Giant
lock.

This is a preparation to remove the Giant lock.

Update #2555.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief NIOS2 Exception and Interrupt Handler
5 *
6 * @note Derived from c4x/irq.c
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2007.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifdef HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/system.h>
23#include <rtems/score/cpu.h>
24#include <rtems/score/isr.h>
25#include <rtems/score/threaddispatch.h>
26#include <rtems/score/nios2-utility.h>
27#include <rtems/score/interr.h>
28
29/*
30 *  This routine provides the RTEMS interrupt management.
31 *
32 *  Upon entry, interrupts are disabled
33 */
34
35#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
36  unsigned long    *_old_stack_ptr;
37#endif
38
39/*
40 * Prototypes
41 */
42void __ISR_Handler(void);
43void __Exception_Handler(CPU_Exception_frame *efr);
44
45register unsigned long  *stack_ptr __asm__ ("sp");
46
47RTEMS_INLINE_ROUTINE void __IIC_Handler(void)
48{
49  uint32_t active;
50  uint32_t mask;
51  uint32_t vector;
52
53  /*
54   * Obtain from the interrupt controller a bit list of pending interrupts,
55   * and then process the highest priority interrupt. This process loops,
56   * loading the active interrupt list on each pass until ipending
57   * return zero.
58   *
59   * The maximum interrupt latency for the highest priority interrupt is
60   * reduced by finding out which interrupts are pending as late as possible.
61   * Consider the case where the high priority interupt is asserted during
62   * the interrupt entry sequence for a lower priority interrupt to see why
63   * this is the case.
64   */
65
66  active = _Nios2_Get_ctlreg_ipending();
67
68  while (active)
69  {
70    vector = 0;
71    mask = 1;
72
73    /*
74     * Test each bit in turn looking for an active interrupt. Once one is
75     * found call it to clear the interrupt condition.
76     */
77
78    while (active)
79    {
80      if (active & mask)
81      {
82        if ( _ISR_Vector_table[ vector] )
83          (*_ISR_Vector_table[ vector ])(vector);
84        active &= ~mask;
85      }
86      mask <<= 1;
87      ++vector;
88    };
89
90    active = _Nios2_Get_ctlreg_ipending();
91  }
92
93}
94
95void __ISR_Handler(void)
96{
97  register uint32_t level;
98
99  /* Interrupts are disabled upon entry to this Handler */
100
101#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
102  if ( _ISR_Nest_level == 0 ) {
103    /* Install irq stack */
104    _old_stack_ptr = stack_ptr;
105    stack_ptr = _CPU_Interrupt_stack_high - 4;
106  }
107#endif
108
109  _ISR_Nest_level++;
110
111  _Thread_Dispatch_disable();
112
113  __IIC_Handler();
114
115  /* Make sure that interrupts are disabled again */
116  _CPU_ISR_Disable( level );
117
118  _Thread_Dispatch_unnest( _Per_CPU_Get() );
119
120  _ISR_Nest_level--;
121
122  if( _ISR_Nest_level == 0) {
123#if( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE)
124    stack_ptr = _old_stack_ptr;
125#endif
126
127    if( _Thread_Dispatch_is_enabled() )
128    {
129      if ( _Thread_Dispatch_necessary ) {
130        _CPU_ISR_Enable( level );
131        _Thread_Dispatch();
132        /* may have switched to another task and not return here immed. */
133        _CPU_ISR_Disable( level ); /* Keep _pairs_ of Enable/Disable */
134      }
135    }
136  }
137
138  _CPU_ISR_Enable( level );
139}
140
141void __Exception_Handler(CPU_Exception_frame *efr)
142{
143  _CPU_Fatal_halt(RTEMS_FATAL_SOURCE_EXCEPTION, 0xECC0); /* source ignored */
144}
Note: See TracBrowser for help on using the repository browser.