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 #ifdef HAVE_CONFIG_H
0039 #include "config.h"
0040 #endif
0041
0042 #include <rtems/rtems/eventimpl.h>
0043 #include <rtems/rtems/statusimpl.h>
0044 #include <rtems/score/threadimpl.h>
0045 #include <rtems/score/statesimpl.h>
0046
0047
0048
0049
0050
0051 typedef enum {
0052 EVENT_MP_SEND_REQUEST = 0,
0053 EVENT_MP_SEND_RESPONSE = 1
0054 } Event_MP_Remote_operations;
0055
0056
0057
0058
0059
0060 typedef struct {
0061 rtems_packet_prefix Prefix;
0062 Event_MP_Remote_operations operation;
0063 rtems_event_set event_in;
0064 } Event_MP_Packet;
0065
0066 RTEMS_STATIC_ASSERT(
0067 sizeof(Event_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE,
0068 Event_MP_Packet
0069 );
0070
0071 static Event_MP_Packet *_Event_MP_Get_packet( Objects_Id id )
0072 {
0073 if ( !_Thread_MP_Is_remote( id ) ) {
0074 return NULL;
0075 }
0076
0077 return (Event_MP_Packet *) _MPCI_Get_packet();
0078 }
0079
0080 rtems_status_code _Event_MP_Send(
0081 rtems_id id,
0082 rtems_event_set event_in
0083 )
0084 {
0085 Event_MP_Packet *the_packet;
0086 Status_Control status;
0087
0088 the_packet = _Event_MP_Get_packet( id );
0089 if ( the_packet == NULL ) {
0090 return RTEMS_INVALID_ID;
0091 }
0092
0093 the_packet->Prefix.the_class = MP_PACKET_EVENT;
0094 the_packet->Prefix.length = sizeof ( *the_packet );
0095 the_packet->Prefix.to_convert = sizeof ( *the_packet );
0096 the_packet->operation = EVENT_MP_SEND_REQUEST;
0097 the_packet->Prefix.id = id;
0098 the_packet->event_in = event_in;
0099
0100 status = _MPCI_Send_request_packet(
0101 _Objects_Get_node( id ),
0102 &the_packet->Prefix,
0103 STATES_READY
0104 );
0105 return _Status_Get( status );
0106 }
0107
0108 static void _Event_MP_Send_response_packet (
0109 Event_MP_Remote_operations operation,
0110 Thread_Control *the_thread
0111 )
0112 {
0113 Event_MP_Packet *the_packet;
0114
0115 switch ( operation ) {
0116
0117 case EVENT_MP_SEND_RESPONSE:
0118
0119 the_packet = ( Event_MP_Packet *) the_thread->receive_packet;
0120
0121
0122
0123
0124
0125 the_packet->operation = operation;
0126 the_packet->Prefix.id = the_packet->Prefix.source_tid;
0127
0128 _MPCI_Send_response_packet(
0129 _Objects_Get_node( the_packet->Prefix.source_tid ),
0130 &the_packet->Prefix
0131 );
0132 break;
0133
0134 case EVENT_MP_SEND_REQUEST:
0135 break;
0136
0137 }
0138 }
0139
0140 void _Event_MP_Process_packet (
0141 rtems_packet_prefix *the_packet_prefix
0142 )
0143 {
0144 Event_MP_Packet *the_packet;
0145
0146 the_packet = (Event_MP_Packet *) the_packet_prefix;
0147
0148 switch ( the_packet->operation ) {
0149
0150 case EVENT_MP_SEND_REQUEST:
0151
0152 the_packet->Prefix.return_code = rtems_event_send(
0153 the_packet->Prefix.id,
0154 the_packet->event_in
0155 );
0156
0157 _Event_MP_Send_response_packet(
0158 EVENT_MP_SEND_RESPONSE,
0159 _Thread_Executing
0160 );
0161 break;
0162
0163 case EVENT_MP_SEND_RESPONSE: {
0164 _MPCI_Process_response( the_packet_prefix );
0165 _MPCI_Return_packet( the_packet_prefix );
0166
0167 break;
0168 }
0169
0170 }
0171 }
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189