source: rtems/cpukit/score/src/objectmp.c @ 879a047

4.104.114.84.95
Last change on this file since 879a047 was 1e0f4c80, checked in by Joel Sherrill <joel.sherrill@…>, on 09/22/95 at 17:27:56

Removed unnecessary include files.

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