Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:22

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSImplClassicSignalMP
0007  *
0008  * @brief This source file contains the implementation to support the Signal
0009  *   Manager in multiprocessing (MP) configurations.
0010  */
0011 
0012 /*
0013  *  COPYRIGHT (c) 1989-2008.
0014  *  On-Line Applications Research Corporation (OAR).
0015  *
0016  * Redistribution and use in source and binary forms, with or without
0017  * modification, are permitted provided that the following conditions
0018  * are met:
0019  * 1. Redistributions of source code must retain the above copyright
0020  *    notice, this list of conditions and the following disclaimer.
0021  * 2. Redistributions in binary form must reproduce the above copyright
0022  *    notice, this list of conditions and the following disclaimer in the
0023  *    documentation and/or other materials provided with the distribution.
0024  *
0025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0030  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0033  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0034  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0035  * POSSIBILITY OF SUCH DAMAGE.
0036  */
0037 
0038 #ifdef HAVE_CONFIG_H
0039 #include "config.h"
0040 #endif
0041 
0042 #include <rtems/rtems/signalimpl.h>
0043 #include <rtems/rtems/optionsimpl.h>
0044 #include <rtems/rtems/statusimpl.h>
0045 #include <rtems/score/statesimpl.h>
0046 #include <rtems/score/threadimpl.h>
0047 #include <rtems/score/threadqimpl.h>
0048 
0049 /**
0050  *  The following enumerated type defines the list of
0051  *  remote signal operations.
0052  */
0053 typedef enum {
0054   SIGNAL_MP_SEND_REQUEST  = 0,
0055   SIGNAL_MP_SEND_RESPONSE = 1
0056 }   Signal_MP_Remote_operations;
0057 
0058 /**
0059  *  The following data structure defines the packet used to perform
0060  *  remote signal operations.
0061  */
0062 typedef struct {
0063   rtems_packet_prefix          Prefix;
0064   Signal_MP_Remote_operations  operation;
0065   rtems_signal_set             signal_set;
0066 }   Signal_MP_Packet;
0067 
0068 RTEMS_STATIC_ASSERT(
0069   sizeof(Signal_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE,
0070   Signal_MP_Packet
0071 );
0072 
0073 static Signal_MP_Packet *_Signal_MP_Get_packet( Objects_Id id )
0074 {
0075   if ( !_Thread_MP_Is_remote( id ) ) {
0076     return NULL;
0077   }
0078 
0079   return (Signal_MP_Packet *) _MPCI_Get_packet();
0080 }
0081 
0082 /*
0083  *  _Signal_MP_Send_process_packet
0084  *
0085  *  This subprogram is not needed since there are no process
0086  *  packets to be sent by this manager.
0087  *
0088  */
0089 
0090 rtems_status_code _Signal_MP_Send(
0091   rtems_id         id,
0092   rtems_signal_set signal_set
0093 )
0094 {
0095   Signal_MP_Packet *the_packet;
0096   Status_Control    status;
0097 
0098   the_packet = _Signal_MP_Get_packet( id );
0099   if ( the_packet == NULL ) {
0100     return RTEMS_INVALID_ID;
0101   }
0102 
0103   the_packet->Prefix.the_class  = MP_PACKET_SIGNAL;
0104   the_packet->Prefix.length     = sizeof( *the_packet );
0105   the_packet->Prefix.to_convert = sizeof( *the_packet );
0106   the_packet->operation         = SIGNAL_MP_SEND_REQUEST;
0107   the_packet->Prefix.id         = id;
0108   the_packet->signal_set        = signal_set;
0109 
0110   status = _MPCI_Send_request_packet(
0111     _Objects_Get_node( id ),
0112     &the_packet->Prefix,
0113     STATES_READY
0114   );
0115   return _Status_Get( status );
0116 }
0117 
0118 static void _Signal_MP_Send_response_packet (
0119   Signal_MP_Remote_operations  operation,
0120   Thread_Control              *the_thread
0121 )
0122 {
0123   Signal_MP_Packet *the_packet;
0124 
0125   switch ( operation ) {
0126 
0127     case SIGNAL_MP_SEND_RESPONSE:
0128 
0129       the_packet = ( Signal_MP_Packet *) the_thread->receive_packet;
0130 
0131 /*
0132  *  The packet being returned already contains the class, length, and
0133  *  to_convert fields, therefore they are not set in this routine.
0134  */
0135       the_packet->operation = operation;
0136       the_packet->Prefix.id = the_packet->Prefix.source_tid;
0137 
0138       _MPCI_Send_response_packet(
0139         _Objects_Get_node( the_packet->Prefix.source_tid ),
0140         &the_packet->Prefix
0141       );
0142       break;
0143 
0144     case SIGNAL_MP_SEND_REQUEST:
0145       break;
0146 
0147   }
0148 }
0149 
0150 void _Signal_MP_Process_packet (
0151   rtems_packet_prefix  *the_packet_prefix
0152 )
0153 {
0154   Signal_MP_Packet *the_packet;
0155 
0156   the_packet = (Signal_MP_Packet *) the_packet_prefix;
0157 
0158   switch ( the_packet->operation ) {
0159 
0160     case SIGNAL_MP_SEND_REQUEST:
0161 
0162       the_packet->Prefix.return_code = rtems_signal_send(
0163         the_packet->Prefix.id,
0164         the_packet->signal_set
0165       );
0166 
0167       _Signal_MP_Send_response_packet(
0168         SIGNAL_MP_SEND_RESPONSE,
0169         _Thread_Executing
0170       );
0171       break;
0172 
0173     case SIGNAL_MP_SEND_RESPONSE:
0174 
0175       _MPCI_Process_response( the_packet_prefix );
0176       _MPCI_Return_packet( the_packet_prefix );
0177       break;
0178 
0179   }
0180 }
0181 
0182 /*
0183  *  _Signal_MP_Send_object_was_deleted
0184  *
0185  *  This subprogram is not needed since there are no objects
0186  *  deleted by this manager.
0187  *
0188  */
0189 
0190 /*
0191  *  _Signal_MP_Send_extract_proxy
0192  *
0193  *  This subprogram is not needed since there are no objects
0194  *  deleted by this manager.
0195  *
0196  */
0197 
0198 /* end of file */