1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup RTEMSScoreISR |
---|
5 | * |
---|
6 | * @brief ISR Level Type |
---|
7 | * |
---|
8 | * This include file defines the ISR Level type. It exists to |
---|
9 | * simplify include dependencies. It is part of the ISR Handler. |
---|
10 | */ |
---|
11 | |
---|
12 | /* |
---|
13 | * COPYRIGHT (c) 1989-2011. |
---|
14 | * On-Line Applications Research Corporation (OAR). |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.org/license/LICENSE. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _RTEMS_SCORE_ISR_LEVEL_h |
---|
22 | #define _RTEMS_SCORE_ISR_LEVEL_h |
---|
23 | |
---|
24 | #include <rtems/score/cpu.h> |
---|
25 | #include <rtems/score/assert.h> |
---|
26 | |
---|
27 | #ifdef __cplusplus |
---|
28 | extern "C" { |
---|
29 | #endif |
---|
30 | |
---|
31 | /** |
---|
32 | * @addtogroup RTEMSScoreISR ISR Handler |
---|
33 | * |
---|
34 | * @{ |
---|
35 | */ |
---|
36 | |
---|
37 | /** |
---|
38 | * The following type defines the control block used to manage |
---|
39 | * the interrupt level portion of the status register. |
---|
40 | */ |
---|
41 | typedef uint32_t ISR_Level; |
---|
42 | |
---|
43 | /** |
---|
44 | * @brief Disables interrupts on this processor. |
---|
45 | * |
---|
46 | * This macro disables all interrupts on this processor so that a critical |
---|
47 | * section of code is protected from concurrent access by interrupts of this |
---|
48 | * processor. Disabling of interrupts disables thread dispatching on the |
---|
49 | * processor as well. |
---|
50 | * |
---|
51 | * On SMP configurations other processors can enter such sections if not |
---|
52 | * protected by other means. |
---|
53 | * |
---|
54 | * @param[out] _level The argument @a _level will contain the previous |
---|
55 | * interrupt mask level. |
---|
56 | */ |
---|
57 | #define _ISR_Local_disable( _level ) \ |
---|
58 | do { \ |
---|
59 | _CPU_ISR_Disable( _level ); \ |
---|
60 | RTEMS_COMPILER_MEMORY_BARRIER(); \ |
---|
61 | } while (0) |
---|
62 | |
---|
63 | /** |
---|
64 | * @brief Enables interrupts on this processor. |
---|
65 | * |
---|
66 | * This macro restores the interrupt status on the processor with the |
---|
67 | * interrupt level value obtained by _ISR_Local_disable(). It is used at the end of |
---|
68 | * a critical section of code to enable interrupts so they can be processed |
---|
69 | * again. |
---|
70 | * |
---|
71 | * @param[in] _level The interrupt level previously obtained by |
---|
72 | * _ISR_Local_disable(). |
---|
73 | */ |
---|
74 | #define _ISR_Local_enable( _level ) \ |
---|
75 | do { \ |
---|
76 | RTEMS_COMPILER_MEMORY_BARRIER(); \ |
---|
77 | _CPU_ISR_Enable( _level ); \ |
---|
78 | } while (0) |
---|
79 | |
---|
80 | /** |
---|
81 | * @brief Temporarily enables interrupts on this processor. |
---|
82 | * |
---|
83 | * This macro temporarily enables interrupts to the previous |
---|
84 | * interrupt mask level and then disables all interrupts so that |
---|
85 | * the caller can continue into the second part of a critical |
---|
86 | * section. |
---|
87 | * |
---|
88 | * This routine is used to temporarily enable interrupts |
---|
89 | * during a long critical section. It is used in long sections of |
---|
90 | * critical code when a point is reached at which interrupts can |
---|
91 | * be temporarily enabled. Deciding where to flash interrupts |
---|
92 | * in a long critical section is often difficult and the point |
---|
93 | * must be selected with care to ensure that the critical section |
---|
94 | * properly protects itself. |
---|
95 | * |
---|
96 | * @param[in] _level The interrupt level previously obtained by |
---|
97 | * _ISR_Local_disable(). |
---|
98 | */ |
---|
99 | #define _ISR_Local_flash( _level ) \ |
---|
100 | do { \ |
---|
101 | RTEMS_COMPILER_MEMORY_BARRIER(); \ |
---|
102 | _CPU_ISR_Flash( _level ); \ |
---|
103 | RTEMS_COMPILER_MEMORY_BARRIER(); \ |
---|
104 | } while (0) |
---|
105 | |
---|
106 | /** |
---|
107 | * @brief Returns true if interrupts are enabled in the specified interrupt |
---|
108 | * level, otherwise returns false. |
---|
109 | * |
---|
110 | * @param[in] _level The ISR level. |
---|
111 | * |
---|
112 | * @retval true Interrupts are enabled in the interrupt level. |
---|
113 | * @retval false Otherwise. |
---|
114 | */ |
---|
115 | #define _ISR_Is_enabled( _level ) \ |
---|
116 | _CPU_ISR_Is_enabled( _level ) |
---|
117 | |
---|
118 | /** |
---|
119 | * @brief Return current interrupt level. |
---|
120 | * |
---|
121 | * This routine returns the current interrupt level. |
---|
122 | * |
---|
123 | * LM32 Specific Information: |
---|
124 | * XXX document implementation including references if appropriate |
---|
125 | * |
---|
126 | * @retval This method returns the current level. |
---|
127 | */ |
---|
128 | #define _ISR_Get_level() \ |
---|
129 | _CPU_ISR_Get_level() |
---|
130 | |
---|
131 | /** |
---|
132 | * @brief Set current interrupt level. |
---|
133 | * |
---|
134 | * This routine sets the current interrupt level to that specified |
---|
135 | * by @a _new_level. The new interrupt level is effective when the |
---|
136 | * routine exits. |
---|
137 | * |
---|
138 | * @param[in] _new_level contains the desired interrupt level. |
---|
139 | */ |
---|
140 | #define _ISR_Set_level( _new_level ) \ |
---|
141 | do { \ |
---|
142 | RTEMS_COMPILER_MEMORY_BARRIER(); \ |
---|
143 | _CPU_ISR_Set_level( _new_level ); \ |
---|
144 | RTEMS_COMPILER_MEMORY_BARRIER(); \ |
---|
145 | } while (0) |
---|
146 | |
---|
147 | /** @} */ |
---|
148 | |
---|
149 | #ifdef __cplusplus |
---|
150 | } |
---|
151 | #endif |
---|
152 | #endif |
---|