OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [src/] [objectmp.c] - Blame information for rev 778

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: objectmp.c,v 1.2 2001-09-27 11:59:34 chris Exp $
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
 
27
void _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
 
57
void _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
 
80
boolean _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
 
114
void _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
 
153
Objects_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 = *(unsigned32 *)the_name;  /* XXX variable */
167
 
168
  if ( nodes_to_search > _Objects_Maximum_nodes )
169
    return OBJECTS_INVALID_NODE;
170
 
171
  if ( information->global_table == NULL )
172
    return OBJECTS_INVALID_NAME;
173
 
174
  if ( nodes_to_search == OBJECTS_SEARCH_ALL_NODES ||
175
       nodes_to_search == OBJECTS_SEARCH_OTHER_NODES ) {
176
    low_node = 1;
177
    high_node = _Objects_Maximum_nodes;
178
  } else {
179
    low_node  =
180
    high_node = nodes_to_search;
181
  }
182
 
183
  _Thread_Disable_dispatch();
184
 
185
  for ( node_index = low_node ; node_index <= high_node ; node_index++ ) {
186
 
187
    /*
188
     *  NOTE: The local node was search (if necessary) by
189
     *        _Objects_Name_to_id before this was invoked.
190
     */
191
 
192
    if ( !_Objects_Is_local_node( node_index ) ) {
193
      the_chain = &information->global_table[ node_index ];
194
 
195
      for ( the_node = the_chain->first ;
196
            !_Chain_Is_tail( the_chain, the_node ) ;
197
            the_node = the_node->next ) {
198
 
199
        the_object = (Objects_MP_Control *) the_node;
200
 
201
        if ( the_object->name == name_to_use ) {
202
          *the_id = the_object->Object.id;
203
          _Thread_Enable_dispatch();
204
          return OBJECTS_SUCCESSFUL;
205
        }
206
      }
207
    }
208
  }
209
 
210
  _Thread_Enable_dispatch();
211
  return OBJECTS_INVALID_NAME;
212
}
213
 
214
/*PAGE
215
 *
216
 *  _Objects_MP_Is_remote
217
 *
218
 */
219
 
220
void _Objects_MP_Is_remote (
221
  Objects_Information  *information,
222
  Objects_Id            the_id,
223
  Objects_Locations    *location,
224
  Objects_Control     **the_object
225
)
226
{
227
  unsigned32          node;
228
  Chain_Control      *the_chain;
229
  Chain_Node         *the_node;
230
  Objects_MP_Control *the_global_object;
231
 
232
  node = _Objects_Get_node( the_id );
233
 
234
  /*
235
   *  NOTE: The local node was search (if necessary) by
236
   *        _Objects_Name_to_id before this was invoked.
237
   *
238
   *        The NODE field of an object id cannot be 0
239
   *        because 0 is an invalid node number.
240
   */
241
 
242
  if ( node == 0 ||
243
       _Objects_Is_local_node( node ) ||
244
       node > _Objects_Maximum_nodes ||
245
       information->global_table == NULL ) {
246
 
247
    *location   = OBJECTS_ERROR;
248
    *the_object = NULL;
249
    return;
250
  }
251
 
252
  _Thread_Disable_dispatch();
253
 
254
  the_chain = &information->global_table[ node ];
255
 
256
  for ( the_node = the_chain->first ;
257
        !_Chain_Is_tail( the_chain, the_node ) ;
258
        the_node = the_node->next ) {
259
 
260
    the_global_object = (Objects_MP_Control *) the_node;
261
 
262
    if ( _Objects_Are_ids_equal( the_global_object->Object.id, the_id ) ) {
263
      _Thread_Unnest_dispatch();
264
      *location   = OBJECTS_REMOTE;
265
      *the_object = (Objects_Control *) the_global_object;
266
      return;
267
    }
268
  }
269
 
270
  _Thread_Enable_dispatch();
271
  *location   = OBJECTS_ERROR;
272
  *the_object = NULL;
273
 
274
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.