source: rtems/cpukit/score/src/objectmp.c @ 584ab9e

4.104.115
Last change on this file since 584ab9e was 584ab9e, checked in by Joel Sherrill <joel.sherrill@…>, on 12/18/08 at 17:15:13

2008-12-18 Joel Sherrill <joel.sherrill@…>

  • rtems/include/rtems/rtems/regionmp.h, sapi/include/rtems/config.h, sapi/src/exinit.c, score/Makefile.am, score/include/rtems/score/object.h, score/include/rtems/score/objectmp.h, score/src/objectmp.c: Eliminate Object Handler Initialization routine since it was all for MP configurations.
  • score/src/object.c: Removed.
  • Property mode set to 100644
File size: 6.6 KB
Line 
1/*
2 *  Multiprocessing Support for the Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/config.h>
21#include <rtems/score/interr.h>
22#include <rtems/score/object.h>
23#include <rtems/score/wkspace.h>
24#include <rtems/score/thread.h>
25
26/*PAGE
27 *
28 *  _Objects_MP_Handler_initialization
29 *
30 */
31
32void _Objects_MP_Handler_initialization(void)
33{
34  uint32_t   node;
35  uint32_t   maximum_nodes;
36  uint32_t   maximum_global_objects;
37
38  node                   = _Configuration_MP_table->node;
39  maximum_nodes          = _Configuration_MP_table->maximum_nodes;
40  maximum_global_objects = _Configuration_MP_table->maximum_global_objects;
41
42  if ( node < 1 || node > maximum_nodes )
43    _Internal_error_Occurred(
44      INTERNAL_ERROR_CORE,
45      TRUE,
46      INTERNAL_ERROR_INVALID_NODE
47    );
48
49
50  _Objects_Local_node    = node;
51  _Objects_Maximum_nodes = maximum_nodes;
52  _Objects_MP_Maximum_global_objects = maximum_global_objects;
53
54  if ( maximum_global_objects == 0 ) {
55    _Chain_Initialize_empty( &_Objects_MP_Inactive_global_objects );
56    return;
57  }
58
59  _Chain_Initialize(
60    &_Objects_MP_Inactive_global_objects,
61    _Workspace_Allocate_or_fatal_error(
62      maximum_global_objects * sizeof( Objects_MP_Control )
63    ),
64    maximum_global_objects,
65    sizeof( Objects_MP_Control )
66  );
67
68}
69
70/*PAGE
71 *
72 *  _Objects_MP_Open
73 *
74 */
75
76void _Objects_MP_Open (
77  Objects_Information *information,
78  Objects_MP_Control  *the_global_object,
79  uint32_t             the_name,      /* XXX -- wrong for variable */
80  Objects_Id           the_id
81)
82{
83  the_global_object->Object.id = the_id;
84  the_global_object->name      = the_name;
85
86  _Chain_Prepend(
87    &information->global_table[ _Objects_Get_node( the_id ) ],
88    &the_global_object->Object.Node
89  );
90
91}
92
93/*PAGE
94 *
95 *  _Objects_MP_Allocate_and_open
96 *
97 */
98
99bool _Objects_MP_Allocate_and_open (
100  Objects_Information *information,
101  uint32_t             the_name,      /* XXX -- wrong for variable */
102  Objects_Id           the_id,
103  bool                 is_fatal_error
104)
105{
106  Objects_MP_Control  *the_global_object;
107
108  the_global_object = _Objects_MP_Allocate_global_object();
109  if ( _Objects_MP_Is_null_global_object( the_global_object ) ) {
110
111    if ( is_fatal_error == FALSE )
112      return FALSE;
113
114    _Internal_error_Occurred(
115      INTERNAL_ERROR_CORE,
116      TRUE,
117      INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS
118    );
119
120  }
121
122  _Objects_MP_Open( information, the_global_object, the_name, the_id );
123
124  return TRUE;
125}
126
127/*PAGE
128 *
129 *  _Objects_MP_Close
130 *
131 */
132
133void _Objects_MP_Close (
134  Objects_Information *information,
135  Objects_Id           the_id
136)
137{
138  Chain_Control      *the_chain;
139  Chain_Node         *the_node;
140  Objects_MP_Control *the_object;
141
142  the_chain = &information->global_table[ _Objects_Get_node( the_id ) ];
143
144  for ( the_node = the_chain->first ;
145        !_Chain_Is_tail( the_chain, the_node ) ;
146        the_node = the_node->next ) {
147
148    the_object = (Objects_MP_Control *) the_node;
149
150    if ( _Objects_Are_ids_equal( the_object->Object.id, the_id ) ) {
151
152      _Chain_Extract( the_node );
153      _Objects_MP_Free_global_object( the_object );
154      return;
155    }
156
157  }
158
159  _Internal_error_Occurred(
160    INTERNAL_ERROR_CORE,
161    TRUE,
162    INTERNAL_ERROR_INVALID_GLOBAL_ID
163  );
164}
165
166/*PAGE
167 *
168 *  _Objects_MP_Global_name_search
169 *
170 */
171
172Objects_Name_or_id_lookup_errors _Objects_MP_Global_name_search (
173  Objects_Information *information,
174  Objects_Name         the_name,
175  uint32_t             nodes_to_search,
176  Objects_Id          *the_id
177)
178{
179  uint32_t            low_node;
180  uint32_t            high_node;
181  uint32_t            node_index;
182  Chain_Control      *the_chain;
183  Chain_Node         *the_node;
184  Objects_MP_Control *the_object;
185  uint32_t            name_to_use;
186
187  name_to_use = the_name.name_u32;  /* XXX only fixed length names */
188
189  if ( nodes_to_search > _Objects_Maximum_nodes )
190    return OBJECTS_INVALID_NODE;
191
192  if ( information->global_table == NULL )
193    return OBJECTS_INVALID_NAME;
194
195  if ( nodes_to_search == OBJECTS_SEARCH_ALL_NODES ||
196       nodes_to_search == OBJECTS_SEARCH_OTHER_NODES ) {
197    low_node = 1;
198    high_node = _Objects_Maximum_nodes;
199  } else {
200    low_node  =
201    high_node = nodes_to_search;
202  }
203
204  _Thread_Disable_dispatch();
205
206  for ( node_index = low_node ; node_index <= high_node ; node_index++ ) {
207
208    /*
209     *  NOTE: The local node was search (if necessary) by
210     *        _Objects_Name_to_id_XXX before this was invoked.
211     */
212
213    if ( !_Objects_Is_local_node( node_index ) ) {
214      the_chain = &information->global_table[ node_index ];
215
216      for ( the_node = the_chain->first ;
217            !_Chain_Is_tail( the_chain, the_node ) ;
218            the_node = the_node->next ) {
219
220        the_object = (Objects_MP_Control *) the_node;
221
222        if ( the_object->name == name_to_use ) {
223          *the_id = the_object->Object.id;
224          _Thread_Enable_dispatch();
225          return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
226        }
227      }
228    }
229  }
230
231  _Thread_Enable_dispatch();
232  return OBJECTS_INVALID_NAME;
233}
234
235/*PAGE
236 *
237 *  _Objects_MP_Is_remote
238 *
239 */
240
241void _Objects_MP_Is_remote (
242  Objects_Information  *information,
243  Objects_Id            the_id,
244  Objects_Locations    *location,
245  Objects_Control     **the_object
246)
247{
248  uint32_t            node;
249  Chain_Control      *the_chain;
250  Chain_Node         *the_node;
251  Objects_MP_Control *the_global_object;
252
253  node = _Objects_Get_node( the_id );
254
255  /*
256   *  NOTE: The local node was search (if necessary) by
257   *        _Objects_Name_to_id_XXX before this was invoked.
258   *
259   *        The NODE field of an object id cannot be 0
260   *        because 0 is an invalid node number.
261   */
262
263  if ( node == 0 ||
264       _Objects_Is_local_node( node ) ||
265       node > _Objects_Maximum_nodes ||
266       information->global_table == NULL ) {
267
268    *location   = OBJECTS_ERROR;
269    *the_object = NULL;
270    return;
271  }
272
273  _Thread_Disable_dispatch();
274
275  the_chain = &information->global_table[ node ];
276
277  for ( the_node = the_chain->first ;
278        !_Chain_Is_tail( the_chain, the_node ) ;
279        the_node = the_node->next ) {
280
281    the_global_object = (Objects_MP_Control *) the_node;
282
283    if ( _Objects_Are_ids_equal( the_global_object->Object.id, the_id ) ) {
284      _Thread_Unnest_dispatch();
285      *location   = OBJECTS_REMOTE;
286      *the_object = (Objects_Control *) the_global_object;
287      return;
288    }
289  }
290
291  _Thread_Enable_dispatch();
292  *location   = OBJECTS_ERROR;
293  *the_object = NULL;
294
295}
Note: See TracBrowser for help on using the repository browser.