source: rtems/cpukit/rtems/src/signalcatch.c @ 7ee6437

5
Last change on this file since 7ee6437 was b7af3e44, checked in by Sebastian Huber <sebastian.huber@…>, on 11/08/18 at 09:57:21

rtems: Move internal structures to tasksdata.h

Update #3598.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Catch Signal
5 *  @ingroup ClassicSignal
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/sysinit.h>
22#include <rtems/rtems/signalimpl.h>
23#include <rtems/rtems/asrimpl.h>
24#include <rtems/rtems/tasksdata.h>
25#include <rtems/score/assert.h>
26#include <rtems/score/threadimpl.h>
27
28RTEMS_STATIC_ASSERT( RTEMS_DEFAULT_MODES == 0, _ASR_Create_mode_set );
29
30void _Signal_Action_handler(
31  Thread_Control   *executing,
32  Thread_Action    *action,
33  ISR_lock_Context *lock_context
34)
35{
36  RTEMS_API_Control *api;
37  ASR_Information   *asr;
38  rtems_signal_set   signal_set;
39  rtems_mode      prev_mode;
40
41  (void) action;
42
43  /*
44   *  Signal Processing
45   */
46
47  api = executing->API_Extensions[ THREAD_API_RTEMS ];
48  asr = &api->Signal;
49  signal_set = _ASR_Get_posted_signals( asr );
50
51  _Thread_State_release( executing, lock_context );
52
53  if ( signal_set == 0 ) {
54    return;
55  }
56
57  asr->nest_level += 1;
58  rtems_task_mode( asr->mode_set, RTEMS_ALL_MODE_MASKS, &prev_mode );
59
60  (*asr->handler)( signal_set );
61
62  asr->nest_level -= 1;
63  rtems_task_mode( prev_mode, RTEMS_ALL_MODE_MASKS, &prev_mode );
64}
65
66rtems_status_code rtems_signal_catch(
67  rtems_asr_entry   asr_handler,
68  rtems_mode        mode_set
69)
70{
71  Thread_Control     *executing;
72  RTEMS_API_Control  *api;
73  ASR_Information    *asr;
74  ISR_lock_Context    lock_context;
75
76  executing = _Thread_State_acquire_for_executing( &lock_context );
77  api = executing->API_Extensions[ THREAD_API_RTEMS ];
78  asr = &api->Signal;
79
80  if ( !_ASR_Is_null_handler( asr_handler ) ) {
81    asr->mode_set = mode_set;
82    asr->handler = asr_handler;
83  } else {
84    _ASR_Initialize( asr );
85  }
86
87  _Thread_State_release( executing, &lock_context );
88  return RTEMS_SUCCESSFUL;
89}
90
91#if defined(RTEMS_MULTIPROCESSING)
92static void _Signal_Manager_initialization( void )
93{
94  _MPCI_Register_packet_processor(
95    MP_PACKET_SIGNAL,
96    _Signal_MP_Process_packet
97  );
98}
99
100RTEMS_SYSINIT_ITEM(
101  _Signal_Manager_initialization,
102  RTEMS_SYSINIT_CLASSIC_SIGNAL,
103  RTEMS_SYSINIT_ORDER_MIDDLE
104);
105#endif
Note: See TracBrowser for help on using the repository browser.