source: rtems/c/src/libchip/shmdr/init.c @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/11/95 at 19:35:39

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 7.0 KB
Line 
1/*  Shm_Initialization
2 *
3 *  This routine is the shared memory communications initerface
4 *  driver initialization routine.
5 *
6 *  Input parameters:  NONE
7 *
8 *  Output parameters: NONE
9 *
10 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  This material may be reproduced by or for the U.S. Government pursuant
15 *  to the copyright license under the clause at DFARS 252.227-7013.  This
16 *  notice must appear in all copies of this file and its derivatives.
17 *
18 *  $Id$
19 */
20
21#define _SHM_INIT
22
23#include <rtems.h>
24#include <shm.h>
25
26#include <string.h>    /* memset() */
27
28/*
29 * User extension to install MPCI_Fatal as a fatal error
30 * handler extension
31 */
32 
33rtems_extensions_table MPCI_Shm_extensions;
34
35rtems_mpci_entry Shm_Initialization( void )
36
37{
38  rtems_unsigned32         i, all_initialized;
39  rtems_unsigned32         interrupt_cause, interrupt_value;
40  void                    *interrupt_address;
41  Shm_Node_status_control *nscb;
42  rtems_unsigned32         extension_id;    /* for installation of MPCI_Fatal */
43  rtems_unsigned32         remaining_memory;
44/* XXX these should use "public" methods to set their values.... */
45  rtems_configuration_table   *configuration = _Configuration_Table;
46  rtems_multiprocessing_table *mp_configuration = _Configuration_MP_table;
47
48  Shm_RTEMS_Configuration    = configuration;
49  Shm_RTEMS_MP_Configuration = mp_configuration;
50
51  Shm_Local_node    = Shm_RTEMS_MP_Configuration->node;
52  Shm_Maximum_nodes = Shm_RTEMS_MP_Configuration->maximum_nodes;
53
54  Shm_Get_configuration( Shm_Local_node, &Shm_Configuration );
55
56  Shm_Receive_message_count = 0;
57  Shm_Null_message_count    = 0;
58  Shm_Interrupt_count       = 0;
59
60  /*
61   *  Set the Node Status indicators
62   */
63
64  Shm_Pending_initialization =
65    Shm_Convert(rtems_build_name( 'P', 'E', 'N', 'D' ));
66  Shm_Initialization_complete =
67    Shm_Convert(rtems_build_name( 'C', 'O', 'M', 'P' ));
68  Shm_Active_node =
69    Shm_Convert(rtems_build_name( 'A', 'C', 'T', 'V' ));
70
71  /*
72   *  Initialize the constants used by the Locked Queue code.
73   */
74
75  Shm_Locked_queue_End_of_list = Shm_Convert( 0xffffffff );
76  Shm_Locked_queue_Not_on_list = Shm_Convert( 0xfffffffe );
77
78  /*
79   *  Set the base addresses for the:
80   *     + Node Status Table
81   *     + Free Pool and Receive Queues
82   *     + Envelopes
83   */
84
85  Shm_Node_statuses  = (Shm_Node_status_control *) START_NS_CBS;
86  Shm_Locked_queues  = (Shm_Locked_queue_Control *) START_LQ_CBS;
87  Shm_Envelopes      = (Shm_Envelope_control *) START_ENVELOPES;
88
89  /*
90   *  Calculate the maximum number of envelopes which can be
91   *  placed the remaining shared memory.
92   */
93
94  remaining_memory =
95     ((void *)Shm_Configuration->base + Shm_Configuration->length) -
96     ((void *)Shm_Envelopes);
97
98  Shm_Maximum_envelopes = remaining_memory / sizeof( Shm_Envelope_control );
99  Shm_Maximum_envelopes -= 1;
100
101  /*
102   *  Set the pointer to the receive queue for the local node.
103   *  When we receive a node, we will get it from here before
104   *  processing it.
105   */
106
107  Shm_Local_receive_queue  = &Shm_Locked_queues[ Shm_Local_node ];
108  Shm_Local_node_status    = &Shm_Node_statuses[ Shm_Local_node ];
109
110  /*
111   *  Convert local interrupt cause information into the
112   *  neutral format so other nodes will be able to
113   *  understand it.
114   */
115
116  interrupt_address =
117    (void *) Shm_Convert( (rtems_unsigned32)Shm_Configuration->Intr.address );
118  interrupt_value   = Shm_Convert( Shm_Configuration->Intr.value );
119  interrupt_cause   = Shm_Convert( Shm_Configuration->Intr.length );
120
121  if ( Shm_Configuration->poll_intr == POLLED_MODE ) Shm_setclockvec();
122  else                                               Shm_setvec();
123
124  if ( Shm_Is_master_node() ) {
125
126    /*
127     *  Zero out the shared memory area.
128     */
129
130    (void) memset(
131      (void *) Shm_Configuration->base,
132      0,
133      Shm_Configuration->length
134    );
135
136    /*
137     *  Initialize all of the locked queues (the free envelope
138     *  pool and a receive queue per node) and set all of the
139     *  node's status so they will be waiting to initialization
140     *  to complete.
141     */
142
143    Shm_Locked_queue_Initialize( FREE_ENV_CB, FREE_ENV_POOL );
144
145    for ( i=SHM_FIRST_NODE ; i<=Shm_Maximum_nodes ; i++ ) {
146      Shm_Initialize_receive_queue( i );
147
148      Shm_Node_statuses[ i ].status = Shm_Pending_initialization;
149      Shm_Node_statuses[ i ].error  = 0;
150    }
151
152    /*
153     *  Initialize all of the envelopes and place them in the
154     *  free pool.
155     */
156
157    for ( i=0 ; i<Shm_Maximum_envelopes ; i++ ) {
158      Shm_Envelopes[ i ].index = Shm_Convert(i);
159      Shm_Free_envelope( &Shm_Envelopes[ i ] );
160    }
161
162    /*
163     *  Initialize this node's interrupt information in the
164     *  shared area so other nodes can interrupt us.
165     */
166
167    Shm_Local_node_status->int_address = (rtems_unsigned32) interrupt_address;
168    Shm_Local_node_status->int_value   = interrupt_value;
169    Shm_Local_node_status->int_length  = interrupt_cause;
170
171    Shm_Local_node_status->status      = Shm_Initialization_complete;
172
173    /*
174     *  Loop until all nodes have completed initialization.
175     */
176
177    do {
178      all_initialized = 1;
179
180      for ( i = SHM_FIRST_NODE ; i <= Shm_Maximum_nodes ; i++ )
181        if ( Shm_Node_statuses[ i ].status != Shm_Initialization_complete )
182          all_initialized = 0;
183
184    } while ( all_initialized == 0 );
185
186    /*
187     *  Tell the other nodes we think that the system is up.
188     */
189
190    for ( i = SHM_FIRST_NODE ; i <= Shm_Maximum_nodes ; i++ )
191      Shm_Node_statuses[ i ].status = Shm_Active_node;
192
193  } else {   /* is not MASTER node */
194
195    /*
196     *  Initialize the node status for the non-master nodes.
197     *  Because the master node zeroes out memory, it is
198     *  necessary for them to keep putting their values in
199     *  the node status area until the master says they
200     *  should become active.
201     */
202
203    Shm_Local_node_status->status = Shm_Pending_initialization;
204
205    do {
206
207      if ( Shm_Local_node_status->status == Shm_Pending_initialization ) {
208
209        /*
210         *  Initialize this node's interrupt information in the
211         *  shared area so other nodes can interrupt us.
212         */
213
214        Shm_Local_node_status->int_address =
215          (rtems_unsigned32) interrupt_address;
216        Shm_Local_node_status->int_value   = interrupt_value;
217        Shm_Local_node_status->int_length  = interrupt_cause;
218
219        Shm_Local_node_status->status      = Shm_Initialization_complete;
220      }
221    } while ( Shm_Local_node_status->status != Shm_Active_node ) ;
222  }
223
224  /*
225   *  Initialize the Interrupt Information Table
226   */
227
228  for ( i = SHM_FIRST_NODE ; i <= Shm_Maximum_nodes ; i++ ) {
229    nscb = &Shm_Node_statuses[ i ];
230
231    Shm_Interrupt_table[i].address = Shm_Convert_address(
232      (void *)Shm_Convert(((vol_u32) nscb->int_address))
233    );
234    Shm_Interrupt_table[i].value = Shm_Convert( nscb->int_value );
235    Shm_Interrupt_table[i].length = Shm_Convert( nscb->int_length );
236  }
237
238  MPCI_Shm_extensions.fatal = MPCI_Fatal;
239  (void) rtems_extension_create(
240    rtems_build_name( 'M', 'P', 'E', 'X' ),
241    &MPCI_Shm_extensions,
242    &extension_id
243  );
244}
Note: See TracBrowser for help on using the repository browser.