File indexing completed on 2025-05-11 08:24:08
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 #define _SHM_INIT
0038
0039 #include <rtems.h>
0040 #include <shm_driver.h>
0041
0042 #include <string.h> /* memset() */
0043 #include <stdlib.h> /* malloc() */
0044 #include <assert.h>
0045
0046
0047
0048
0049
0050
0051 rtems_extensions_table MPCI_Shm_extensions;
0052
0053
0054
0055
0056
0057 rtems_mpci_entry Shm_Initialization( void )
0058
0059 {
0060 uint32_t i, all_initialized;
0061 uint32_t interrupt_cause, interrupt_value;
0062 void *interrupt_address;
0063 Shm_Node_status_control *nscb;
0064 uint32_t extension_id;
0065 uint32_t remaining_memory;
0066 uint32_t local_node;
0067
0068 local_node = rtems_object_get_local_node();
0069
0070 Shm_Get_configuration( local_node, &Shm_Configuration );
0071
0072 Shm_Interrupt_table = (Shm_Interrupt_information *) malloc(
0073 sizeof(Shm_Interrupt_information) * (SHM_MAXIMUM_NODES + 1)
0074 );
0075
0076 assert( Shm_Interrupt_table );
0077
0078 Shm_Receive_message_count = 0;
0079 Shm_Null_message_count = 0;
0080 Shm_Interrupt_count = 0;
0081
0082
0083
0084
0085
0086 Shm_Pending_initialization =
0087 Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ));
0088 Shm_Initialization_complete =
0089 Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ));
0090 Shm_Active_node =
0091 Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ));
0092
0093
0094
0095
0096
0097 Shm_Locked_queue_End_of_list = Shm_Convert( 0xffffffff );
0098 Shm_Locked_queue_Not_on_list = Shm_Convert( 0xfffffffe );
0099
0100
0101
0102
0103
0104
0105
0106
0107 Shm_Node_statuses = (Shm_Node_status_control *) START_NS_CBS;
0108 Shm_Locked_queues = (Shm_Locked_queue_Control *) START_LQ_CBS;
0109 Shm_Envelopes = (Shm_Envelope_control *) START_ENVELOPES;
0110
0111
0112
0113
0114
0115
0116 remaining_memory =
0117 ((void *)Shm_Configuration->base + Shm_Configuration->length) -
0118 ((void *)Shm_Envelopes);
0119
0120 Shm_Maximum_envelopes = remaining_memory / sizeof( Shm_Envelope_control );
0121 Shm_Maximum_envelopes -= 1;
0122
0123
0124
0125
0126
0127
0128
0129 Shm_Local_receive_queue = &Shm_Locked_queues[ local_node ];
0130 Shm_Local_node_status = &Shm_Node_statuses[ local_node ];
0131
0132
0133
0134
0135
0136
0137
0138 interrupt_address =
0139 (void *) Shm_Convert( (uint32_t)Shm_Configuration->Intr.address );
0140 interrupt_value = Shm_Convert( Shm_Configuration->Intr.value );
0141 interrupt_cause = Shm_Convert( Shm_Configuration->Intr.length );
0142
0143 if ( Shm_Configuration->poll_intr == POLLED_MODE ) Shm_install_timer();
0144 else Shm_setvec();
0145
0146 if ( Shm_Is_master_node() ) {
0147
0148
0149
0150
0151
0152 (void) memset(
0153 (void *) Shm_Configuration->base,
0154 0,
0155 Shm_Configuration->length
0156 );
0157
0158
0159
0160
0161
0162
0163
0164
0165 Shm_Locked_queue_Initialize( FREE_ENV_CB, FREE_ENV_POOL );
0166
0167 for ( i=SHM_FIRST_NODE ; i<=SHM_MAXIMUM_NODES ; i++ ) {
0168 Shm_Initialize_receive_queue( i );
0169
0170 Shm_Node_statuses[ i ].status = Shm_Pending_initialization;
0171 Shm_Node_statuses[ i ].error = 0;
0172 }
0173
0174
0175
0176
0177
0178
0179 for ( i=0 ; i<Shm_Maximum_envelopes ; i++ ) {
0180 Shm_Envelopes[ i ].index = Shm_Convert(i);
0181 Shm_Free_envelope( &Shm_Envelopes[ i ] );
0182 }
0183
0184
0185
0186
0187
0188
0189 Shm_Local_node_status->int_address = (uint32_t) interrupt_address;
0190 Shm_Local_node_status->int_value = interrupt_value;
0191 Shm_Local_node_status->int_length = interrupt_cause;
0192
0193 Shm_Local_node_status->status = Shm_Initialization_complete;
0194
0195
0196
0197
0198
0199 do {
0200 all_initialized = 1;
0201
0202 for ( i = SHM_FIRST_NODE ; i <= SHM_MAXIMUM_NODES ; i++ )
0203 if ( Shm_Node_statuses[ i ].status != Shm_Initialization_complete )
0204 all_initialized = 0;
0205
0206 } while ( all_initialized == 0 );
0207
0208
0209
0210
0211
0212 for ( i = SHM_FIRST_NODE ; i <= SHM_MAXIMUM_NODES ; i++ )
0213 Shm_Node_statuses[ i ].status = Shm_Active_node;
0214
0215 } else {
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225 Shm_Local_node_status->status = Shm_Pending_initialization;
0226
0227 do {
0228
0229 if ( Shm_Local_node_status->status == Shm_Pending_initialization ) {
0230
0231
0232
0233
0234
0235
0236 Shm_Local_node_status->int_address =
0237 (uint32_t) interrupt_address;
0238 Shm_Local_node_status->int_value = interrupt_value;
0239 Shm_Local_node_status->int_length = interrupt_cause;
0240
0241 Shm_Local_node_status->status = Shm_Initialization_complete;
0242 }
0243 } while ( Shm_Local_node_status->status != Shm_Active_node ) ;
0244 }
0245
0246
0247
0248
0249
0250 for ( i = SHM_FIRST_NODE ; i <= SHM_MAXIMUM_NODES ; i++ ) {
0251 nscb = &Shm_Node_statuses[ i ];
0252
0253 Shm_Interrupt_table[i].address = Shm_Convert_address(
0254 (void *)Shm_Convert(((vol_u32) nscb->int_address))
0255 );
0256 Shm_Interrupt_table[i].value = Shm_Convert( nscb->int_value );
0257 Shm_Interrupt_table[i].length = Shm_Convert( nscb->int_length );
0258 }
0259
0260 MPCI_Shm_extensions.fatal = MPCI_Fatal;
0261
0262 (void) rtems_extension_create(
0263 rtems_build_name( 'M', 'P', 'E', 'X' ),
0264 &MPCI_Shm_extensions,
0265 &extension_id
0266 );
0267 }