source: rtems/cpukit/score/src/objectmp.c @ 22ce0881

4.104.114.95
Last change on this file since 22ce0881 was def9eef, checked in by Joel Sherrill <joel.sherrill@…>, on 01/28/08 at 17:19:01

2008-01-28 Joel Sherrill <joel.sherrill@…>

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