source: rtems/c/src/exec/score/include/rtems/score/object.h @ 95fbca1

4.104.114.84.95
Last change on this file since 95fbca1 was 95fbca1, checked in by Joel Sherrill <joel.sherrill@…>, on 08/18/95 at 21:41:27

+ Added object type field to object id.

+ Added name pointer to Object_Control.

+ Modified Object Open and Close to address name field.

+ Removed name as separate element from Thread and Proxy Control.

  • Property mode set to 100644
File size: 10.1 KB
Line 
1/*  object.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the RTEMS Object Handler.  This Handler provides mechanisms which
5 *  can be used to initialize and manipulate all RTEMS objects.
6 *
7 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
8 *  On-Line Applications Research Corporation (OAR).
9 *  All rights assigned to U.S. Government, 1994.
10 *
11 *  This material may be reproduced by or for the U.S. Government pursuant
12 *  to the copyright license under the clause at DFARS 252.227-7013.  This
13 *  notice must appear in all copies of this file and its derivatives.
14 *
15 *  $Id$
16 */
17
18#ifndef __RTEMS_OBJECTS_h
19#define __RTEMS_OBJECTS_h
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <rtems/chain.h>
26
27/*
28 *  The following type defines the control block used to manage
29 *  object names.
30 */
31
32typedef unsigned32 Objects_Name;
33
34/*
35 *  The following type defines the control block used to manage
36 *  object IDs.  The format is as follows (0=LSB):
37 *
38 *     Bits  0 .. 15    = index
39 *     Bits 16 .. 25    = node
40 *     Bits 26 .. 31    = class
41 */
42
43typedef unsigned32 Objects_Id;
44
45#define OBJECTS_INDEX_START_BIT  0
46#define OBJECTS_NODE_START_BIT  16
47#define OBJECTS_CLASS_START_BIT 26
48
49#define OBJECTS_INDEX_MASK      0x0000ffff
50#define OBJECTS_NODE_MASK       0x03ff0000
51#define OBJECTS_CLASS_MASK      0xfc000000
52
53#define OBJECTS_INDEX_VALID_BITS  0x0000ffff
54#define OBJECTS_NODE_VALID_BITS   0x000003ff
55#define OBJECTS_CLASS_VALID_BITS  0x000000cf
56
57/*
58 *  This enumerated type is used in the class field of the object ID.
59 */
60
61typedef enum {
62  OBJECTS_NO_CLASS             =  0,
63  OBJECTS_RTEMS_TASKS          =  1,
64  OBJECTS_RTEMS_TIMERS         =  2,
65  OBJECTS_RTEMS_SEMAPHORES     =  3,
66  OBJECTS_RTEMS_MESSAGE_QUEUES =  4,
67  OBJECTS_RTEMS_PARTITIONS     =  5,
68  OBJECTS_RTEMS_REGIONS        =  6,
69  OBJECTS_RTEMS_PORTS          =  7,
70  OBJECTS_RTEMS_PERIODS        =  8,
71  OBJECTS_RTEMS_EXTENSIONS     =  9
72} Objects_Classes;
73
74/*
75 *  This enumerated type lists the locations which may be returned
76 *  by _Objects_Get.  These codes indicate the success of locating
77 *  an object with the specified ID.
78 */
79
80typedef enum {
81  OBJECTS_LOCAL  = 0,         /* object is local */
82  OBJECTS_REMOTE = 1,         /* object is remote */
83  OBJECTS_ERROR  = 2          /* id was invalid */
84}  Objects_Locations;
85
86/*
87 *  The following defines the Object Control Block used to manage
88 *  each object local to this node.
89 */
90
91typedef struct {
92  Chain_Node    Node;
93  Objects_Id    id;
94  Objects_Name *name;
95}   Objects_Control;
96
97/*
98 *  The following defines the structure for the information used to
99 *  manage each class of objects.
100 */
101
102typedef struct {
103  Objects_Classes   the_class;       /* Class of this object */
104  Objects_Id        minimum_id;      /* minimum valid id of this type */
105  Objects_Id        maximum_id;      /* maximum valid id of this type */
106  unsigned32        maximum;         /* maximum number of objects */
107  Objects_Control **local_table;     /* table of local object pointers */
108  Objects_Name     *name_table;      /* table of local object names */
109  Chain_Control    *global_table;    /* pointer to global table */
110  Chain_Control     Inactive;        /* chain of inactive ctl blocks */
111}   Objects_Information;
112
113/*
114 *  The following defines the data storage which contains the
115 *  node number of the local node.
116 */
117
118EXTERN unsigned32  _Objects_Local_node;
119
120/*
121 *  The following defines the constant which may be used
122 *  with _Objects_Get to manipulate the calling task.
123 *
124 */
125
126#define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
127
128/*
129 *  The following define the constants which may be used in name searches.
130 */
131
132#define RTEMS_SEARCH_ALL_NODES   0
133#define RTEMS_SEARCH_OTHER_NODES 0x7FFFFFFE
134#define RTEMS_SEARCH_LOCAL_NODE  0x7FFFFFFF
135#define RTEMS_WHO_AM_I           0
136
137/*
138 * Parameters and return id's for _Objects_Get_next
139 */
140
141#define RTEMS_OBJECT_ID_INITIAL_INDEX   (0)
142#define RTEMS_OBJECT_ID_FINAL_INDEX     (0xffff)
143
144#define RTEMS_OBJECT_ID_INITIAL(node)   (_Objects_Build_id(      \
145                                            OBJECTS_NO_CLASS, \
146                                            node, \
147                                            RTEMS_OBJECT_ID_INITIAL_INDEX))
148#define RTEMS_OBJECT_ID_FINAL           ((Objects_Id)~0)
149
150/*
151 *  _Objects_Handler_initialization
152 *
153 *  DESCRIPTION:
154 *
155 *  This function performs the initialization necessary for this handler.
156 *
157 */
158
159void _Objects_Handler_initialization(
160  unsigned32 node,
161  unsigned32 maximum_global_objects
162);
163
164/*
165 *  _Objects_Initialize_information
166 *
167 *  DESCRIPTION:
168 *
169 *  This function initializes an object class information record.
170 *  SUPPORTS_GLOBAL is TRUE if the object class supports global
171 *  objects, and FALSE otherwise.  Maximum indicates the number
172 *  of objects required in this class and size indicates the size
173 *  in bytes of each control block for this object class.
174 *
175 */
176
177void _Objects_Initialize_information (
178  Objects_Information *information,
179  Objects_Classes      the_class,
180  boolean              supports_global,
181  unsigned32           maximum,
182  unsigned32           size
183);
184
185/*
186 *  _Objects_Name_to_id
187 *
188 *  DESCRIPTION:
189 *
190 *  This function implements the common portion of the object
191 *  identification directives.  This directive returns the object
192 *  id associated with name.  If more than one object of this class
193 *  is named name, then the object to which the id belongs is
194 *  arbitrary.  Node indicates the extent of the search for the
195 *  id of the object named name.  If the object class supports global
196 *  objects, then the search can be limited to a particular node
197 *  or allowed to encompass all nodes.
198 *
199 */
200
201rtems_status_code _Objects_Name_to_id(
202  Objects_Information *information,
203  Objects_Name         name,
204  unsigned32           node,
205  Objects_Id          *id
206);
207
208/*
209 *  _Objects_Get
210 *
211 *  DESCRIPTION:
212 *
213 *  This function maps object ids to object control blocks.
214 *  If id corresponds to a local object, then it returns
215 *  the_object control pointer which maps to id and location
216 *  is set to OBJECTS_LOCAL.  If the object class supports global
217 *  objects and the object id is global and resides on a remote
218 *  node, then location is set to OBJECTS_REMOTE, and the_object
219 *  is undefined.  Otherwise, location is set to OBJECTS_ERROR
220 *  and the_object is undefined.
221 *
222 */
223
224Objects_Control *_Objects_Get (
225  Objects_Information *information,
226  Objects_Id           id,
227  Objects_Locations   *location
228);
229
230/*
231 *  _Objects_Get_next
232 *
233 *  DESCRIPTION:
234 *
235 *  Like _Objects_Get, but is used to find "next" open object.
236 *
237 */
238
239Objects_Control *_Objects_Get_next(
240    Objects_Information *information,
241    Objects_Id           id,
242    unsigned32          *location_p,
243    Objects_Id          *next_id_p
244);
245
246/*
247 *  _Objects_Is_name_valid
248 *
249 *  DESCRIPTION:
250 *
251 *  This function returns TRUE if the name is valid, and FALSE otherwise.
252 */
253
254STATIC INLINE boolean _Objects_Is_name_valid (
255  Objects_Name name
256);
257
258/*
259 *  rtems_build_name
260 *
261 *  DESCRIPTION:
262 *
263 *  This function returns an object name composed of the four characters
264 *  C1, C2, C3, and C4.
265 *
266 *  NOTE:
267 *
268 *  This must be implemented as a macro for use in Configuration Tables.
269 *
270 */
271
272#define rtems_build_name( _C1, _C2, _C3, _C4 ) \
273  ( (_C1) << 24 | (_C2) << 16 | (_C3) << 8 | (_C4) )
274
275/*
276 *  rtems_name_to_characters
277 *
278 *  DESCRIPTION:
279 *
280 *  This function breaks the object name into the four component
281 *  characters C1, C2, C3, and C4.
282 *
283 */
284
285STATIC INLINE void rtems_name_to_characters(
286  Objects_Name  name,
287  char         *c1,
288  char         *c2,
289  char         *c3,
290  char         *c4
291);
292
293/*
294 *  _Objects_Build_id
295 *
296 *  DESCRIPTION:
297 *
298 *  This function builds an object's id from the processor node and index
299 *  values specified.
300 *
301 */
302
303STATIC INLINE Objects_Id _Objects_Build_id(
304  Objects_Classes  the_class,
305  unsigned32       node,
306  unsigned32       index
307);
308
309/*
310 *  rtems_get_class
311 *
312 *  DESCRIPTION:
313 *
314 *  This function returns the class portion of the ID.
315 *
316 */
317 
318STATIC INLINE Objects_Classes rtems_get_class(
319  Objects_Id id
320);
321
322/*
323 *  rtems_get_node
324 *
325 *  DESCRIPTION:
326 *
327 *  This function returns the node portion of the ID.
328 *
329 */
330
331STATIC INLINE unsigned32 rtems_get_node(
332  Objects_Id id
333);
334
335/*
336 *  rtems_get_index
337 *
338 *  DESCRIPTION:
339 *
340 *  This function returns the index portion of the ID.
341 *
342 */
343
344STATIC INLINE unsigned32 rtems_get_index(
345  Objects_Id id
346);
347
348/*
349 *  _Objects_Is_local_node
350 *
351 *  DESCRIPTION:
352 *
353 *  This function returns TRUE if the node is of the local object, and
354 *  FALSE otherwise.
355 *
356 */
357
358STATIC INLINE boolean _Objects_Is_local_node(
359  unsigned32 node
360);
361
362/*
363 *  _Objects_Is_local_id
364 *
365 *  DESCRIPTION:
366 *
367 *  This function returns TRUE if the id is of a local object, and
368 *  FALSE otherwise.
369 *
370 */
371
372STATIC INLINE boolean _Objects_Is_local_id(
373  Objects_Id id
374);
375
376/*
377 *  _Objects_Are_ids_equal
378 *
379 *  DESCRIPTION:
380 *
381 *  This function returns TRUE if left and right are equal,
382 *  and FALSE otherwise.
383 *
384 */
385
386STATIC INLINE boolean _Objects_Are_ids_equal(
387  Objects_Id left,
388  Objects_Id right
389);
390
391/*
392 *  _Objects_Allocate
393 *
394 *  DESCRIPTION:
395 *
396 *  This function allocates a object control block from
397 *  the inactive chain of free object control blocks.
398 *
399 */
400
401STATIC INLINE Objects_Control *_Objects_Allocate(
402  Objects_Information *information
403);
404
405/*
406 *  _Objects_Free
407 *
408 *  DESCRIPTION:
409 *
410 *  This function frees a object control block to the
411 *  inactive chain of free object control blocks.
412 *
413 */
414
415STATIC INLINE void _Objects_Free(
416  Objects_Information *information,
417  Objects_Control     *the_object
418);
419
420/*
421 *  _Objects_Open
422 *
423 *  DESCRIPTION:
424 *
425 *  This function places the_object control pointer and object name
426 *  in the Local Pointer and Local Name Tables, respectively.
427 *
428 */
429
430STATIC INLINE void _Objects_Open(
431  Objects_Information *information,
432  Objects_Control     *the_object,
433  Objects_Name         name
434);
435
436/*
437 *  _Objects_Close
438 *
439 *  DESCRIPTION:
440 *
441 *  This function removes the_object control pointer and object name
442 *  in the Local Pointer and Local Name Tables.
443 *
444 */
445
446STATIC INLINE void _Objects_Close(
447  Objects_Information *information,
448  Objects_Control     *the_object
449);
450
451#include <rtems/object.inl>
452#include <rtems/objectmp.h>
453
454#ifdef __cplusplus
455}
456#endif
457
458#endif
459/* end of include file */
Note: See TracBrowser for help on using the repository browser.