source: rtems/cpukit/rtems/src/eventseize.c @ cfe8f7a

5
Last change on this file since cfe8f7a was cfe8f7a, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/20 at 14:14:06

doxygen: Switch @brief and @ingroup

This order change fixes the Latex documentation build via Doxygen.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicEvent Events
5 *
6 * @brief Event Manager Initialization
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2008.
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/sysinit.h>
23#include <rtems/rtems/eventimpl.h>
24#include <rtems/rtems/optionsimpl.h>
25#include <rtems/rtems/statusimpl.h>
26#include <rtems/score/threadimpl.h>
27#include <rtems/score/watchdogimpl.h>
28
29rtems_status_code _Event_Seize(
30  rtems_event_set    event_in,
31  rtems_option       option_set,
32  rtems_interval     ticks,
33  rtems_event_set   *event_out,
34  Thread_Control    *executing,
35  Event_Control     *event,
36  Thread_Wait_flags  wait_class,
37  States_Control     block_state,
38  ISR_lock_Context  *lock_context
39)
40{
41  rtems_event_set    seized_events;
42  rtems_event_set    pending_events;
43  bool               success;
44  Thread_Wait_flags  intend_to_block;
45  Per_CPU_Control   *cpu_self;
46
47  pending_events = event->pending_events;
48  seized_events  = _Event_sets_Get( pending_events, event_in );
49
50  if ( !_Event_sets_Is_empty( seized_events ) &&
51       (seized_events == event_in || _Options_Is_any( option_set )) ) {
52    event->pending_events =
53      _Event_sets_Clear( pending_events, seized_events );
54    _Thread_Wait_release_default( executing, lock_context );
55    *event_out = seized_events;
56    return RTEMS_SUCCESSFUL;
57  }
58
59  if ( _Options_Is_no_wait( option_set ) ) {
60    _Thread_Wait_release_default( executing, lock_context );
61    *event_out = seized_events;
62    return RTEMS_UNSATISFIED;
63  }
64
65  intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK;
66
67  /*
68   *  Note what we are waiting for BEFORE we enter the critical section.
69   *  The interrupt critical section management code needs this to be
70   *  set properly when we are marked as in the event critical section.
71   *
72   *  NOTE: Since interrupts are disabled, this isn't that much of an
73   *        issue but better safe than sorry.
74   */
75  executing->Wait.return_code     = STATUS_SUCCESSFUL;
76  executing->Wait.option          = option_set;
77  executing->Wait.count           = event_in;
78  executing->Wait.return_argument = event_out;
79  _Thread_Wait_flags_set( executing, intend_to_block );
80
81  cpu_self = _Thread_Dispatch_disable_critical( lock_context );
82  _Thread_Wait_release_default( executing, lock_context );
83
84  if ( ticks ) {
85    _Thread_Add_timeout_ticks( executing, cpu_self, ticks );
86  }
87
88  _Thread_Set_state( executing, block_state );
89
90  success = _Thread_Wait_flags_try_change_acquire(
91    executing,
92    intend_to_block,
93    wait_class | THREAD_WAIT_STATE_BLOCKED
94  );
95  if ( !success ) {
96    _Thread_Timer_remove( executing );
97    _Thread_Unblock( executing );
98  }
99
100  _Thread_Dispatch_direct( cpu_self );
101  return _Status_Get_after_wait( executing );
102}
103
104#if defined(RTEMS_MULTIPROCESSING)
105static void _Event_MP_Initialize( void )
106{
107  _MPCI_Register_packet_processor( MP_PACKET_EVENT, _Event_MP_Process_packet );
108}
109
110RTEMS_SYSINIT_ITEM(
111  _Event_MP_Initialize,
112  RTEMS_SYSINIT_CLASSIC_EVENT_MP,
113  RTEMS_SYSINIT_ORDER_MIDDLE
114);
115#endif
Note: See TracBrowser for help on using the repository browser.