source: rtems/cpukit/score/src/objectmp.c @ 2ec764f8

Last change on this file since 2ec764f8 was 2ec764f8, checked in by Joel Sherrill <joel.sherrill@…>, on 06/12/03 at 15:40:32

2003-06-12 Joel Sherrill <joel@…>

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