1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ClassicASRImpl |
---|
5 | * |
---|
6 | * @brief Classic ASR Implementation |
---|
7 | */ |
---|
8 | |
---|
9 | /* COPYRIGHT (c) 1989-2008. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef _RTEMS_RTEMS_ASRIMPL_H |
---|
18 | #define _RTEMS_RTEMS_ASRIMPL_H |
---|
19 | |
---|
20 | #include <rtems/rtems/asr.h> |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | /** |
---|
27 | * @defgroup ClassicASRImpl Classic ASR Implementation |
---|
28 | * |
---|
29 | * @ingroup ClassicASR |
---|
30 | * |
---|
31 | * @{ |
---|
32 | */ |
---|
33 | |
---|
34 | /** |
---|
35 | * @brief ASR_Initialize |
---|
36 | * |
---|
37 | * This routine initializes the given RTEMS_ASR information record. |
---|
38 | */ |
---|
39 | RTEMS_INLINE_ROUTINE void _ASR_Initialize ( |
---|
40 | ASR_Information *asr |
---|
41 | ) |
---|
42 | { |
---|
43 | asr->is_enabled = false; |
---|
44 | asr->handler = NULL; |
---|
45 | asr->mode_set = RTEMS_DEFAULT_MODES; |
---|
46 | asr->signals_posted = 0; |
---|
47 | asr->signals_pending = 0; |
---|
48 | asr->nest_level = 0; |
---|
49 | _ISR_lock_Initialize( &asr->Lock, "ASR" ); |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * @brief ASR_Swap_signals |
---|
54 | * |
---|
55 | * This routine atomically swaps the pending and posted signal |
---|
56 | * sets. This is done when the thread alters its mode in such a |
---|
57 | * way that the RTEMS_ASR disable/enable flag changes. |
---|
58 | */ |
---|
59 | RTEMS_INLINE_ROUTINE void _ASR_Swap_signals ( |
---|
60 | ASR_Information *asr |
---|
61 | ) |
---|
62 | { |
---|
63 | rtems_signal_set _signals; |
---|
64 | ISR_lock_Context lock_context; |
---|
65 | |
---|
66 | _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context ); |
---|
67 | _signals = asr->signals_pending; |
---|
68 | asr->signals_pending = asr->signals_posted; |
---|
69 | asr->signals_posted = _signals; |
---|
70 | _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context ); |
---|
71 | } |
---|
72 | |
---|
73 | /** |
---|
74 | * @brief ASR_Is_null_handler |
---|
75 | * |
---|
76 | * This function returns TRUE if the given asr_handler is NULL and |
---|
77 | * FALSE otherwise. |
---|
78 | */ |
---|
79 | RTEMS_INLINE_ROUTINE bool _ASR_Is_null_handler ( |
---|
80 | rtems_asr_entry asr_handler |
---|
81 | ) |
---|
82 | { |
---|
83 | return asr_handler == NULL; |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * @brief ASR_Are_signals_pending |
---|
88 | * |
---|
89 | * This function returns TRUE if there are signals pending in the |
---|
90 | * given RTEMS_ASR information record and FALSE otherwise. |
---|
91 | */ |
---|
92 | RTEMS_INLINE_ROUTINE bool _ASR_Are_signals_pending ( |
---|
93 | ASR_Information *asr |
---|
94 | ) |
---|
95 | { |
---|
96 | return asr->signals_posted != 0; |
---|
97 | } |
---|
98 | |
---|
99 | /** |
---|
100 | * @brief ASR_Post_signals |
---|
101 | * |
---|
102 | * This routine posts the given signals into the signal_set |
---|
103 | * passed in. The result is returned to the user in signal_set. |
---|
104 | * |
---|
105 | * NOTE: This must be implemented as a macro. |
---|
106 | */ |
---|
107 | RTEMS_INLINE_ROUTINE void _ASR_Post_signals( |
---|
108 | ASR_Information *asr, |
---|
109 | rtems_signal_set signals, |
---|
110 | rtems_signal_set *signal_set |
---|
111 | ) |
---|
112 | { |
---|
113 | ISR_lock_Context lock_context; |
---|
114 | |
---|
115 | _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context ); |
---|
116 | *signal_set |= signals; |
---|
117 | _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context ); |
---|
118 | } |
---|
119 | |
---|
120 | RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals( |
---|
121 | ASR_Information *asr |
---|
122 | ) |
---|
123 | { |
---|
124 | rtems_signal_set signal_set; |
---|
125 | ISR_lock_Context lock_context; |
---|
126 | |
---|
127 | _ISR_lock_ISR_disable_and_acquire( &asr->Lock, &lock_context ); |
---|
128 | signal_set = asr->signals_posted; |
---|
129 | asr->signals_posted = 0; |
---|
130 | _ISR_lock_Release_and_ISR_enable( &asr->Lock, &lock_context ); |
---|
131 | |
---|
132 | return signal_set; |
---|
133 | } |
---|
134 | |
---|
135 | /**@}*/ |
---|
136 | |
---|
137 | #ifdef __cplusplus |
---|
138 | } |
---|
139 | #endif |
---|
140 | |
---|
141 | #endif |
---|
142 | /* end of include file */ |
---|