[7f04cb18] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
[4c20da4b] | 4 | * @ingroup RTEMSScoreMPCI |
---|
[7f04cb18] | 5 | * |
---|
| 6 | * @brief MPCI Layer Implementation |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | * COPYRIGHT (c) 1989-2009. |
---|
| 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 |
---|
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
---|
[7f04cb18] | 16 | */ |
---|
| 17 | |
---|
| 18 | #ifndef _RTEMS_SCORE_MPCIIMPL_H |
---|
| 19 | #define _RTEMS_SCORE_MPCIIMPL_H |
---|
| 20 | |
---|
| 21 | #include <rtems/score/mpci.h> |
---|
[dce48791] | 22 | #include <rtems/score/status.h> |
---|
[7f04cb18] | 23 | |
---|
| 24 | #ifdef __cplusplus |
---|
| 25 | extern "C" { |
---|
| 26 | #endif |
---|
| 27 | |
---|
| 28 | /** |
---|
[4c20da4b] | 29 | * @addtogroup RTEMSScoreMPCI |
---|
[7f04cb18] | 30 | * |
---|
| 31 | * @{ |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | * For packets associated with requests that don't already have a timeout, |
---|
| 36 | * use the one specified by this MPCI driver. The value specified by |
---|
| 37 | * the MPCI driver sets an upper limit on how long a remote request |
---|
| 38 | * should take to complete. |
---|
| 39 | */ |
---|
| 40 | #define MPCI_DEFAULT_TIMEOUT 0xFFFFFFFF |
---|
| 41 | |
---|
| 42 | /** |
---|
| 43 | * The following defines the type for packet processing routines |
---|
| 44 | * invoked by the MPCI Receive server. |
---|
| 45 | */ |
---|
| 46 | typedef void (*MPCI_Packet_processor)( MP_packet_Prefix * ); |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * The following enumerated type defines the list of |
---|
| 50 | * internal MP operations. |
---|
| 51 | */ |
---|
| 52 | typedef enum { |
---|
| 53 | MPCI_PACKETS_SYSTEM_VERIFY = 0 |
---|
| 54 | } MPCI_Internal_Remote_operations; |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * The following data structure defines the packet used to perform |
---|
| 58 | * remote event operations. |
---|
| 59 | */ |
---|
| 60 | typedef struct { |
---|
| 61 | /** This field is the general header for all packets. */ |
---|
| 62 | MP_packet_Prefix Prefix; |
---|
| 63 | /** This value specifies the operation. */ |
---|
| 64 | MPCI_Internal_Remote_operations operation; |
---|
| 65 | /** This is the maximum number of nodes in the system. It must agree |
---|
| 66 | * on all nodes. |
---|
| 67 | */ |
---|
| 68 | uint32_t maximum_nodes; |
---|
| 69 | /** This field is the maximum number of concurrently existent |
---|
| 70 | * globally offered objects. |
---|
| 71 | */ |
---|
| 72 | uint32_t maximum_global_objects; |
---|
| 73 | } MPCI_Internal_packet; |
---|
| 74 | |
---|
| 75 | /** |
---|
| 76 | * The following thread queue is used to maintain a list of tasks |
---|
| 77 | * which currently have outstanding remote requests. |
---|
| 78 | */ |
---|
[358bd740] | 79 | extern Thread_queue_Control _MPCI_Remote_blocked_threads; |
---|
[7f04cb18] | 80 | |
---|
| 81 | /** |
---|
| 82 | * The following define the internal pointers to the user's |
---|
| 83 | * configuration information. |
---|
| 84 | */ |
---|
[358bd740] | 85 | extern MPCI_Control *_MPCI_table; |
---|
[7f04cb18] | 86 | |
---|
| 87 | /** |
---|
| 88 | * @brief Pointer to MP thread control block. |
---|
| 89 | * |
---|
| 90 | * The following is used to determine when the multiprocessing receive |
---|
| 91 | * thread is executing so that a proxy can be allocated instead of |
---|
| 92 | * blocking the multiprocessing receive thread. |
---|
| 93 | */ |
---|
[358bd740] | 94 | extern Thread_Control *_MPCI_Receive_server_tcb; |
---|
[7f04cb18] | 95 | |
---|
| 96 | /** |
---|
| 97 | * The following table contains the process packet routines provided |
---|
| 98 | * by each object that supports MP operations. |
---|
| 99 | */ |
---|
[358bd740] | 100 | extern MPCI_Packet_processor |
---|
| 101 | _MPCI_Packet_processors[ MP_PACKET_CLASSES_LAST + 1 ]; |
---|
[7f04cb18] | 102 | |
---|
| 103 | /** |
---|
| 104 | * This routine registers the MPCI packet processor for the |
---|
| 105 | * designated object class. |
---|
| 106 | * |
---|
| 107 | * @param[in] the_class is the class indicator for packets which will |
---|
| 108 | * be processed by @a the_packet_processor method. |
---|
| 109 | * @param[in] the_packet_processor is a pointer to a method which is |
---|
| 110 | * invoked when packets with @a the_class are received. |
---|
| 111 | */ |
---|
| 112 | void _MPCI_Register_packet_processor( |
---|
| 113 | MP_packet_Classes the_class, |
---|
| 114 | MPCI_Packet_processor the_packet_processor |
---|
| 115 | |
---|
| 116 | ); |
---|
| 117 | |
---|
| 118 | /** |
---|
| 119 | * This function obtains a packet by invoking the user provided |
---|
| 120 | * MPCI get packet callout. |
---|
| 121 | * |
---|
| 122 | * @retval This method returns a pointer to a MPCI packet which can be |
---|
| 123 | * filled in by the caller and used to perform a subsequent |
---|
| 124 | * remote operation. |
---|
| 125 | */ |
---|
| 126 | MP_packet_Prefix *_MPCI_Get_packet ( void ); |
---|
| 127 | |
---|
| 128 | /** |
---|
| 129 | * @brief Deallocate a packet. |
---|
| 130 | * |
---|
| 131 | * This routine deallocates a packet by invoking the user provided |
---|
| 132 | * MPCI return packet callout. |
---|
| 133 | * |
---|
| 134 | * @param[in] the_packet is the MP packet to deallocate. |
---|
| 135 | */ |
---|
| 136 | void _MPCI_Return_packet ( |
---|
| 137 | MP_packet_Prefix *the_packet |
---|
| 138 | ); |
---|
| 139 | |
---|
| 140 | /** |
---|
| 141 | * @brief Send a process packet. |
---|
| 142 | * |
---|
| 143 | * This routine sends a process packet by invoking the user provided |
---|
| 144 | * MPCI send callout. |
---|
| 145 | * |
---|
| 146 | * @param[in] destination is the node which should receive this packet. |
---|
| 147 | * @param[in] the_packet is the packet to be sent. |
---|
| 148 | */ |
---|
| 149 | void _MPCI_Send_process_packet ( |
---|
| 150 | uint32_t destination, |
---|
| 151 | MP_packet_Prefix *the_packet |
---|
| 152 | ); |
---|
| 153 | |
---|
| 154 | /** |
---|
| 155 | * @brief Send a request packet. |
---|
| 156 | * |
---|
| 157 | * This routine sends a request packet by invoking the user provided |
---|
| 158 | * MPCI send callout. |
---|
| 159 | * |
---|
| 160 | * @param[in] destination is the node which should receive this packet. |
---|
| 161 | * @param[in] the_packet is the packet to be sent. |
---|
| 162 | * @param[in] extra_state is the extra thread state bits which should be |
---|
| 163 | * set in addition to the remote operation pending state. It |
---|
| 164 | * may indicate the caller is blocking on a message queue |
---|
| 165 | * operation. |
---|
| 166 | * |
---|
| 167 | * @retval This method returns the operation status from the remote node. |
---|
| 168 | */ |
---|
[dce48791] | 169 | Status_Control _MPCI_Send_request_packet( |
---|
| 170 | uint32_t destination, |
---|
| 171 | MP_packet_Prefix *the_packet, |
---|
| 172 | States_Control extra_state |
---|
[7f04cb18] | 173 | ); |
---|
| 174 | |
---|
| 175 | /** |
---|
| 176 | * @brief Send a response packet. |
---|
| 177 | * |
---|
| 178 | * This routine sends a response packet by invoking the user provided |
---|
| 179 | * MPCI send callout. |
---|
| 180 | * |
---|
| 181 | * @param[in] destination is the node which should receive this packet. |
---|
| 182 | * @param[in] the_packet is the packet to be sent. |
---|
| 183 | */ |
---|
| 184 | void _MPCI_Send_response_packet ( |
---|
| 185 | uint32_t destination, |
---|
| 186 | MP_packet_Prefix *the_packet |
---|
| 187 | ); |
---|
| 188 | |
---|
| 189 | /** |
---|
| 190 | * @brief Receive a packet. |
---|
| 191 | * |
---|
| 192 | * This routine receives a packet by invoking the user provided |
---|
| 193 | * MPCI receive callout. |
---|
| 194 | * |
---|
| 195 | * @retval This method returns the packet received. |
---|
| 196 | */ |
---|
| 197 | MP_packet_Prefix *_MPCI_Receive_packet ( void ); |
---|
| 198 | |
---|
| 199 | /** |
---|
| 200 | * @brief Pass a packet to the thread. |
---|
| 201 | * |
---|
| 202 | * This routine is responsible for passing @a the_packet to the thread |
---|
| 203 | * waiting on the remote operation to complete. The unblocked thread is |
---|
| 204 | * responsible for eventually freeing @a the_packet. |
---|
| 205 | * |
---|
| 206 | * @param[in] the_packet is the response packet to be processed. |
---|
| 207 | * |
---|
| 208 | * @retval This method returns a pointer to the thread which was if unblocked |
---|
| 209 | * or NULL if the waiting thread no longer exists. |
---|
| 210 | */ |
---|
| 211 | Thread_Control *_MPCI_Process_response ( |
---|
| 212 | MP_packet_Prefix *the_packet |
---|
| 213 | ); |
---|
| 214 | |
---|
| 215 | /** |
---|
| 216 | * @brief Receive and process all packets. |
---|
| 217 | * |
---|
| 218 | * This is the server thread which receives and processes all MCPI packets. |
---|
| 219 | * |
---|
| 220 | * @param[in] ignored is the thread argument. It is not used. |
---|
| 221 | */ |
---|
[885c342e] | 222 | void _MPCI_Receive_server( |
---|
| 223 | Thread_Entry_numeric_type ignored |
---|
[7f04cb18] | 224 | ); |
---|
| 225 | |
---|
| 226 | /** |
---|
| 227 | * @brief Announce the availability of a packet. |
---|
| 228 | * |
---|
| 229 | * This routine informs RTEMS of the availability of an MPCI packet. |
---|
| 230 | */ |
---|
| 231 | void _MPCI_Announce ( void ); |
---|
| 232 | |
---|
| 233 | /** |
---|
| 234 | * @brief Perform a process on another node. |
---|
| 235 | * |
---|
| 236 | * This routine performs a remote procedure call so that a |
---|
| 237 | * process operation can be performed on another node. |
---|
| 238 | * |
---|
| 239 | * @param[in] operation is the remote operation to perform. |
---|
| 240 | */ |
---|
| 241 | void _MPCI_Internal_packets_Send_process_packet ( |
---|
| 242 | MPCI_Internal_Remote_operations operation |
---|
| 243 | ); |
---|
| 244 | |
---|
| 245 | /** |
---|
| 246 | * _MPCI_Internal_packets_Send_request_packet |
---|
| 247 | * |
---|
| 248 | * This routine performs a remote procedure call so that a |
---|
| 249 | * directive operation can be initiated on another node. |
---|
| 250 | * |
---|
| 251 | * This routine is not needed since there are no request |
---|
| 252 | * packets to be sent by this manager. |
---|
| 253 | */ |
---|
| 254 | |
---|
| 255 | /** |
---|
| 256 | * _MPCI_Internal_packets_Send_response_packet |
---|
| 257 | * |
---|
| 258 | * This routine performs a remote procedure call so that a |
---|
| 259 | * directive can be performed on another node. |
---|
| 260 | * |
---|
| 261 | * This routine is not needed since there are no response |
---|
| 262 | * packets to be sent by this manager. |
---|
| 263 | */ |
---|
| 264 | |
---|
| 265 | /** |
---|
| 266 | * @brief Perform requested action from another node. |
---|
| 267 | * |
---|
| 268 | * This routine performs the actions specific to this package for |
---|
| 269 | * the request from another node. |
---|
| 270 | */ |
---|
| 271 | void _MPCI_Internal_packets_Process_packet ( |
---|
| 272 | MP_packet_Prefix *the_packet_prefix |
---|
| 273 | ); |
---|
| 274 | |
---|
| 275 | /** |
---|
| 276 | * _MPCI_Internal_packets_Send_object_was_deleted |
---|
| 277 | * |
---|
| 278 | * This routine is invoked indirectly by the thread queue |
---|
| 279 | * when a proxy has been removed from the thread queue and |
---|
| 280 | * the remote node must be informed of this. |
---|
| 281 | * |
---|
| 282 | * This routine is not needed since there are no objects |
---|
| 283 | * deleted by this manager. |
---|
| 284 | */ |
---|
| 285 | |
---|
| 286 | /** |
---|
| 287 | * _MPCI_Internal_packets_Send_extract_proxy |
---|
| 288 | * |
---|
| 289 | * This routine is invoked when a task is deleted and it |
---|
| 290 | * has a proxy which must be removed from a thread queue and |
---|
| 291 | * the remote node must be informed of this. |
---|
| 292 | * |
---|
| 293 | * This routine is not needed since there are no objects |
---|
| 294 | * deleted by this manager. |
---|
| 295 | */ |
---|
| 296 | |
---|
| 297 | /** |
---|
| 298 | * @brief Obtain an internal thread. |
---|
| 299 | * |
---|
| 300 | * This routine is used to obtain an internal threads MP packet. |
---|
| 301 | */ |
---|
| 302 | MPCI_Internal_packet *_MPCI_Internal_packets_Get_packet ( void ); |
---|
| 303 | |
---|
[0b9f4721] | 304 | /** |
---|
| 305 | * This function returns true if the the_packet_class is valid, |
---|
| 306 | * and false otherwise. |
---|
| 307 | * |
---|
| 308 | * @note Check for lower bounds (MP_PACKET_CLASSES_FIRST ) is unnecessary |
---|
| 309 | * because this enum starts at lower bound of zero. |
---|
| 310 | */ |
---|
| 311 | |
---|
| 312 | RTEMS_INLINE_ROUTINE bool _Mp_packet_Is_valid_packet_class ( |
---|
| 313 | MP_packet_Classes the_packet_class |
---|
| 314 | ) |
---|
| 315 | { |
---|
| 316 | return ( the_packet_class <= MP_PACKET_CLASSES_LAST ); |
---|
| 317 | } |
---|
| 318 | |
---|
[7f04cb18] | 319 | /**@}*/ |
---|
| 320 | |
---|
| 321 | #ifdef __cplusplus |
---|
| 322 | } |
---|
| 323 | #endif |
---|
| 324 | |
---|
| 325 | #endif |
---|
| 326 | /* end of include file */ |
---|