File indexing completed on 2025-05-11 08:24:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #ifdef HAVE_CONFIG_H
0040 #include "config.h"
0041 #endif
0042
0043 #include <rtems/sysinit.h>
0044 #include <rtems/rtems/eventimpl.h>
0045 #include <rtems/rtems/optionsimpl.h>
0046 #include <rtems/rtems/statusimpl.h>
0047 #include <rtems/score/threadimpl.h>
0048 #include <rtems/score/watchdogimpl.h>
0049
0050 rtems_status_code _Event_Seize(
0051 rtems_event_set event_in,
0052 rtems_option option_set,
0053 rtems_interval ticks,
0054 rtems_event_set *event_out,
0055 Thread_Control *executing,
0056 Event_Control *event,
0057 Thread_Wait_flags wait_class,
0058 States_Control block_state,
0059 ISR_lock_Context *lock_context
0060 )
0061 {
0062 rtems_event_set seized_events;
0063 rtems_event_set pending_events;
0064 bool success;
0065 Thread_Wait_flags intend_to_block;
0066 Per_CPU_Control *cpu_self;
0067
0068 pending_events = event->pending_events;
0069 seized_events = _Event_sets_Get( pending_events, event_in );
0070
0071 if ( !_Event_sets_Is_empty( seized_events ) &&
0072 (seized_events == event_in || _Options_Is_any( option_set )) ) {
0073 event->pending_events =
0074 _Event_sets_Clear( pending_events, seized_events );
0075 _Thread_Wait_release_default( executing, lock_context );
0076 *event_out = seized_events;
0077 return RTEMS_SUCCESSFUL;
0078 }
0079
0080 if ( _Options_Is_no_wait( option_set ) ) {
0081 _Thread_Wait_release_default( executing, lock_context );
0082 *event_out = seized_events;
0083 return RTEMS_UNSATISFIED;
0084 }
0085
0086 intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK;
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 executing->Wait.return_code = STATUS_SUCCESSFUL;
0097 executing->Wait.option = option_set;
0098 executing->Wait.count = event_in;
0099 executing->Wait.return_argument = event_out;
0100 _Thread_Wait_flags_set( executing, intend_to_block );
0101
0102 cpu_self = _Thread_Dispatch_disable_critical( lock_context );
0103 _Thread_Wait_release_default( executing, lock_context );
0104
0105 if ( ticks ) {
0106 _Thread_Add_timeout_ticks( executing, cpu_self, ticks );
0107 }
0108
0109 _Thread_Set_state( executing, block_state );
0110
0111 success = _Thread_Wait_flags_try_change_acquire(
0112 executing,
0113 intend_to_block,
0114 wait_class | THREAD_WAIT_STATE_BLOCKED
0115 );
0116 if ( !success ) {
0117 _Thread_Timer_remove( executing );
0118 _Thread_Unblock( executing );
0119 }
0120
0121 _Thread_Dispatch_direct( cpu_self );
0122 return _Status_Get_after_wait( executing );
0123 }
0124
0125 #if defined(RTEMS_MULTIPROCESSING)
0126 static void _Event_MP_Initialize( void )
0127 {
0128 _MPCI_Register_packet_processor( MP_PACKET_EVENT, _Event_MP_Process_packet );
0129 }
0130
0131 RTEMS_SYSINIT_ITEM(
0132 _Event_MP_Initialize,
0133 RTEMS_SYSINIT_CLASSIC_EVENT_MP,
0134 RTEMS_SYSINIT_ORDER_MIDDLE
0135 );
0136 #endif