source: rtems/cpukit/rtems/include/rtems/rtems/asrimpl.h @ 92dee4ab

5
Last change on this file since 92dee4ab was 92dee4ab, checked in by Sebastian Huber <sebastian.huber@…>, on 03/17/16 at 05:51:56

rtems: Avoid Giant lock in rtems_signal_catch()

Update #2555.

  • Property mode set to 100644
File size: 3.5 KB
Line 
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.org/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
23extern "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 */
39RTEMS_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}
50
51RTEMS_INLINE_ROUTINE void _ASR_Create( ASR_Information *asr )
52{
53  _ISR_lock_Initialize( &asr->Lock, "ASR" );
54  RTEMS_STATIC_ASSERT( RTEMS_DEFAULT_MODES == 0, _ASR_Create_mode_set );
55}
56
57RTEMS_INLINE_ROUTINE void _ASR_Destroy( ASR_Information *asr )
58{
59  _ISR_lock_Destroy( &asr->Lock );
60}
61
62RTEMS_INLINE_ROUTINE void _ASR_Acquire(
63  ASR_Information  *asr,
64  ISR_lock_Context *lock_context
65)
66{
67  _ISR_lock_ISR_disable_and_acquire( &asr->Lock, lock_context );
68}
69
70RTEMS_INLINE_ROUTINE void _ASR_Release(
71  ASR_Information  *asr,
72  ISR_lock_Context *lock_context
73)
74{
75  _ISR_lock_Release_and_ISR_enable( &asr->Lock, lock_context );
76}
77
78/**
79 *  @brief ASR_Swap_signals
80 *
81 *  This routine atomically swaps the pending and posted signal
82 *  sets.  This is done when the thread alters its mode in such a
83 *  way that the RTEMS_ASR disable/enable flag changes.
84 */
85RTEMS_INLINE_ROUTINE void _ASR_Swap_signals (
86  ASR_Information *asr
87)
88{
89  rtems_signal_set _signals;
90  ISR_lock_Context lock_context;
91
92  _ASR_Acquire( asr, &lock_context );
93    _signals             = asr->signals_pending;
94    asr->signals_pending = asr->signals_posted;
95    asr->signals_posted  = _signals;
96  _ASR_Release( asr, &lock_context );
97}
98
99/**
100 *  @brief ASR_Is_null_handler
101 *
102 *  This function returns TRUE if the given asr_handler is NULL and
103 *  FALSE otherwise.
104 */
105RTEMS_INLINE_ROUTINE bool _ASR_Is_null_handler (
106  rtems_asr_entry asr_handler
107)
108{
109  return asr_handler == NULL;
110}
111
112/**
113 *  @brief ASR_Are_signals_pending
114 *
115 *  This function returns TRUE if there are signals pending in the
116 *  given RTEMS_ASR information record and FALSE otherwise.
117 */
118RTEMS_INLINE_ROUTINE bool _ASR_Are_signals_pending (
119  ASR_Information *asr
120)
121{
122  return asr->signals_posted != 0;
123}
124
125/**
126 *  @brief ASR_Post_signals
127 *
128 *  This routine posts the given signals into the signal_set
129 *  passed in.  The result is returned to the user in signal_set.
130 *
131 *  NOTE:  This must be implemented as a macro.
132 */
133RTEMS_INLINE_ROUTINE void _ASR_Post_signals(
134  ASR_Information  *asr,
135  rtems_signal_set  signals,
136  rtems_signal_set *signal_set
137)
138{
139  ISR_lock_Context lock_context;
140
141  _ASR_Acquire( asr, &lock_context );
142    *signal_set |= signals;
143  _ASR_Release( asr, &lock_context );
144}
145
146RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals(
147  ASR_Information *asr
148)
149{
150  rtems_signal_set signal_set;
151  ISR_lock_Context lock_context;
152
153  _ASR_Acquire( asr, &lock_context );
154    signal_set = asr->signals_posted;
155    asr->signals_posted = 0;
156  _ASR_Release( asr, &lock_context );
157
158  return signal_set;
159}
160
161/**@}*/
162
163#ifdef __cplusplus
164}
165#endif
166
167#endif
168/* end of include file */
Note: See TracBrowser for help on using the repository browser.