Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSScoreMPCI
0007  *
0008  * @brief This header file provides interfaces of the
0009  *   @ref RTEMSScoreMPCI which are only used by the implementation.
0010  */
0011 
0012 /*
0013  *  COPYRIGHT (c) 1989-2009.
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 #ifndef _RTEMS_SCORE_MPCIIMPL_H
0039 #define _RTEMS_SCORE_MPCIIMPL_H
0040 
0041 #include <rtems/score/mpci.h>
0042 #include <rtems/score/thread.h>
0043 #include <rtems/score/threadq.h>
0044 #include <rtems/score/watchdog.h>
0045 #include <rtems/score/status.h>
0046 
0047 #ifdef __cplusplus
0048 extern "C" {
0049 #endif
0050 
0051 /**
0052  * @addtogroup RTEMSScoreMPCI
0053  *
0054  * @{
0055  */
0056 
0057 /**
0058  *  For packets associated with requests that don't already have a timeout,
0059  *  use the one specified by this MPCI driver.  The value specified by
0060  *   the MPCI driver sets an upper limit on how long a remote request
0061  *   should take to complete.
0062  */
0063 #define MPCI_DEFAULT_TIMEOUT    0xFFFFFFFF
0064 
0065 /**
0066  *  The following defines the type for packet processing routines
0067  *  invoked by the MPCI Receive server.
0068  */
0069 typedef void (*MPCI_Packet_processor)( MP_packet_Prefix * );
0070 
0071 /**
0072  *  The following enumerated type defines the list of
0073  *  internal MP operations.
0074  */
0075 typedef enum {
0076   MPCI_PACKETS_SYSTEM_VERIFY  =  0
0077 }   MPCI_Internal_Remote_operations;
0078 
0079 /**
0080  *  The following data structure defines the packet used to perform
0081  *  remote event operations.
0082  */
0083 typedef struct {
0084   /** This field is the general header for all packets. */
0085   MP_packet_Prefix                 Prefix;
0086   /** This value specifies the operation. */
0087   MPCI_Internal_Remote_operations  operation;
0088   /** This is the maximum number of nodes in the system. It must agree
0089    *  on all nodes.
0090    */
0091   uint32_t                         maximum_nodes;
0092   /** This field is the maximum number of concurrently existent
0093    *  globally offered objects.
0094    */
0095   uint32_t                         maximum_global_objects;
0096 }    MPCI_Internal_packet;
0097 
0098 /**
0099  *  The following thread queue is used to maintain a list of tasks
0100  *  which currently have outstanding remote requests.
0101  */
0102 extern Thread_queue_Control _MPCI_Remote_blocked_threads;
0103 
0104 /**
0105  *  The following define the internal pointers to the user's
0106  *  configuration information.
0107  */
0108 extern MPCI_Control *_MPCI_table;
0109 
0110 /**
0111  *  @brief Pointer to MP thread control block.
0112  *
0113  *  The following is used to determine when the multiprocessing receive
0114  *  thread is executing so that a proxy can be allocated instead of
0115  *  blocking the multiprocessing receive thread.
0116  */
0117 extern Thread_Control *_MPCI_Receive_server_tcb;
0118 
0119 /**
0120  *  The following table contains the process packet routines provided
0121  *  by each object that supports MP operations.
0122  */
0123 extern MPCI_Packet_processor
0124 _MPCI_Packet_processors[ MP_PACKET_CLASSES_LAST + 1 ];
0125 
0126 /**
0127  * @brief Registers the MPCI packet processor for the designated object class.
0128  *
0129  * @param the_class The class indicator for packets which will
0130  *            be processed by @a the_packet_processor method.
0131  * @param the_packet_processor Pointer to a method which is
0132  *            invoked when packets with @a the_class are received.
0133  */
0134 void _MPCI_Register_packet_processor(
0135   MP_packet_Classes      the_class,
0136   MPCI_Packet_processor  the_packet_processor
0137 
0138 );
0139 
0140 /**
0141  * @brief Obtains a packet by invoking the user provided
0142  *          MPCI get packet callout.
0143  *
0144  * @return Returns a pointer to a MPCI packet which can be
0145  *          filled in by the caller and used to perform a subsequent
0146  *          remote operation.
0147  */
0148 MP_packet_Prefix *_MPCI_Get_packet ( void );
0149 
0150 /**
0151  * @brief Deallocates a packet.
0152  *
0153  * This routine deallocates a packet by invoking the user provided
0154  * MPCI return packet callout.
0155  *
0156  * @param[out] the_packet The MP packet to deallocate.
0157  */
0158 void _MPCI_Return_packet (
0159   MP_packet_Prefix *the_packet
0160 );
0161 
0162 /**
0163  * @brief Sends a process packet.
0164  *
0165  * This routine sends a process packet by invoking the user provided
0166  * MPCI send callout.
0167  *
0168  * @param destination The node which should receive this packet.
0169  * @param the_packet The packet to be sent.
0170  */
0171 void _MPCI_Send_process_packet (
0172   uint32_t          destination,
0173   MP_packet_Prefix *the_packet
0174 );
0175 
0176 /**
0177  * @brief Sends a request packet.
0178  *
0179  * This routine sends a request packet by invoking the user provided
0180  * MPCI send callout.
0181  *
0182  * @param destination The node which should receive this packet.
0183  * @param the_packet The packet to be sent.
0184  * @param extra_state The extra thread state bits which should be
0185  *            set in addition to the remote operation pending state.  It
0186  *            may indicate the caller is blocking on a message queue
0187  *            operation.
0188  *
0189  * @ret This method returns the operation status from the remote node.
0190  */
0191 Status_Control _MPCI_Send_request_packet(
0192   uint32_t          destination,
0193   MP_packet_Prefix *the_packet,
0194   States_Control    extra_state
0195 );
0196 
0197 /**
0198  * @brief Sends a response packet.
0199  *
0200  * This routine sends a response packet by invoking the user provided
0201  * MPCI send callout.
0202  *
0203  * @param destination The node which should receive this packet.
0204  * @param the_packet The packet to be sent.
0205  */
0206 void _MPCI_Send_response_packet (
0207   uint32_t          destination,
0208   MP_packet_Prefix *the_packet
0209 );
0210 
0211 /**
0212  * @brief Receives a packet.
0213  *
0214  * This routine receives a packet by invoking the user provided
0215  * MPCI receive callout.
0216  *
0217  * @return This method returns the packet received.
0218  */
0219 MP_packet_Prefix  *_MPCI_Receive_packet ( void );
0220 
0221 /**
0222  * @brief Passes a packet to the thread.
0223  *
0224  * This routine is responsible for passing @a the_packet to the thread
0225  * waiting on the remote operation to complete.  The unblocked thread is
0226  * responsible for eventually freeing @a the_packet.
0227  *
0228  * @param the_packet is the response packet to be processed.
0229  *
0230  * @retval pointer This method returns a pointer to the thread which was unblocked
0231  * @retval NULL The waiting thread no longer exists.
0232  */
0233 Thread_Control *_MPCI_Process_response (
0234   MP_packet_Prefix *the_packet
0235 );
0236 
0237 /**
0238  * @brief Receives and processes all packets.
0239  *
0240  * This is the server thread which receives and processes all MCPI packets.
0241  *
0242  * @param ignored The thread argument.  It is not used.
0243  */
0244 void _MPCI_Receive_server(
0245   Thread_Entry_numeric_type ignored
0246 );
0247 
0248 /**
0249  * @brief Announces the availability of a packet.
0250  *
0251  * This routine informs RTEMS of the availability of an MPCI packet.
0252  */
0253 void _MPCI_Announce ( void );
0254 
0255 /**
0256  * @brief Performs a process on another node.
0257  *
0258  * This routine performs a remote procedure call so that a
0259  * process operation can be performed on another node.
0260  *
0261  * @param operation The remote operation to perform.
0262  */
0263 void _MPCI_Internal_packets_Send_process_packet (
0264    MPCI_Internal_Remote_operations operation
0265 );
0266 
0267 /**
0268  *  _MPCI_Internal_packets_Send_request_packet
0269  *
0270  *  This routine performs a remote procedure call so that a
0271  *  directive operation can be initiated on another node.
0272  *
0273  *  This routine is not needed since there are no request
0274  *  packets to be sent by this manager.
0275  */
0276 
0277 /**
0278  *  _MPCI_Internal_packets_Send_response_packet
0279  *
0280  *  This routine performs a remote procedure call so that a
0281  *  directive can be performed on another node.
0282  *
0283  *  This routine is not needed since there are no response
0284  *  packets to be sent by this manager.
0285  */
0286 
0287 /**
0288  * @brief Performs requested action from another node.
0289  *
0290  * This routine performs the actions specific to this package for
0291  * the request from another node.
0292  *
0293  * @param the_packet_prefix The packet prefix for this method.
0294  */
0295 void _MPCI_Internal_packets_Process_packet (
0296   MP_packet_Prefix *the_packet_prefix
0297 );
0298 
0299 /**
0300  *  _MPCI_Internal_packets_Send_object_was_deleted
0301  *
0302  *  This routine is invoked indirectly by the thread queue
0303  *  when a proxy has been removed from the thread queue and
0304  *  the remote node must be informed of this.
0305  *
0306  *  This routine is not needed since there are no objects
0307  *  deleted by this manager.
0308  */
0309 
0310 /**
0311  *  _MPCI_Internal_packets_Send_extract_proxy
0312  *
0313  *  This routine is invoked when a task is deleted and it
0314  *  has a proxy which must be removed from a thread queue and
0315  *  the remote node must be informed of this.
0316  *
0317  *  This routine is not needed since there are no objects
0318  *  deleted by this manager.
0319  */
0320 
0321 /**
0322  * @brief Obtains an internal thread.
0323  *
0324  * This routine is used to obtain an internal threads MP packet.
0325  *
0326  * @retval pointer The pointer to the obtained packet.
0327  * @retval NULL Something went wrong.
0328  */
0329 MPCI_Internal_packet *_MPCI_Internal_packets_Get_packet ( void );
0330 
0331 /**
0332  * @brief Checks if the packet class is valid.
0333  *
0334  * @param the_packet_class The packet class to perform the validation on.
0335  *
0336  * @retval true @a the_packet_class is valid.
0337  * @retval false @a the_packet_class is not valid.
0338  *
0339  * @note Check for lower bounds (MP_PACKET_CLASSES_FIRST ) is unnecessary
0340  *       because this enum starts at lower bound of zero.
0341  */
0342 
0343 static inline bool _Mp_packet_Is_valid_packet_class (
0344   MP_packet_Classes the_packet_class
0345 )
0346 {
0347   return ( the_packet_class <= MP_PACKET_CLASSES_LAST );
0348 }
0349 
0350 /** @} */
0351 
0352 #ifdef __cplusplus
0353 }
0354 #endif
0355 
0356 #endif
0357 /* end of include file */