source: rtems/c/src/exec/score/headers/object.h @ 5250ff39

4.104.114.84.9
Last change on this file since 5250ff39 was 5250ff39, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 23, 1995 at 9:06:31 PM

Moved _Thread_Information -> _RTEMS_tasks_Information.

Added a table of object information control blocks.

Modified _Thread_Get so it looks up a thread regardless of which
thread management "entity" (manager, internal, etc) actually "owns" it.

  • Property mode set to 100644
File size: 11.3 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 void * Objects_Name;
33
34/*
35 *  Space for object names is allocated in multiples of this.
36 *
37 *  NOTE:  Must be a power of 2.  Matches the name manipulation routines.
38 */
39
40#define OBJECTS_NAME_ALIGNMENT     4
41
42/*
43 *  Functions which compare names are prototyped like this.
44 */
45
46typedef boolean (*Objects_Name_comparators)(
47  void       * /* name_1 */,
48  void       * /* name_2 */,
49  unsigned32   /* length */
50);
51
52/*
53 *  The following type defines the control block used to manage
54 *  object IDs.  The format is as follows (0=LSB):
55 *
56 *     Bits  0 .. 15    = index
57 *     Bits 16 .. 25    = node
58 *     Bits 26 .. 31    = class
59 */
60
61typedef unsigned32 Objects_Id;
62
63#define OBJECTS_INDEX_START_BIT  0
64#define OBJECTS_NODE_START_BIT  16
65#define OBJECTS_CLASS_START_BIT 26
66
67#define OBJECTS_INDEX_MASK      0x0000ffff
68#define OBJECTS_NODE_MASK       0x03ff0000
69#define OBJECTS_CLASS_MASK      0xfc000000
70
71#define OBJECTS_INDEX_VALID_BITS  0x0000ffff
72#define OBJECTS_NODE_VALID_BITS   0x000003ff
73#define OBJECTS_CLASS_VALID_BITS  0x000000cf
74
75/*
76 *  This enumerated type is used in the class field of the object ID.
77 */
78
79typedef enum {
80  OBJECTS_NO_CLASS             =  0,
81  OBJECTS_INTERNAL_THREADS     =  1,
82  OBJECTS_RTEMS_TASKS          =  2,
83  OBJECTS_RTEMS_TIMERS         =  3,
84  OBJECTS_RTEMS_SEMAPHORES     =  4,
85  OBJECTS_RTEMS_MESSAGE_QUEUES =  5,
86  OBJECTS_RTEMS_PARTITIONS     =  6,
87  OBJECTS_RTEMS_REGIONS        =  7,
88  OBJECTS_RTEMS_PORTS          =  8,
89  OBJECTS_RTEMS_PERIODS        =  9,
90  OBJECTS_RTEMS_EXTENSIONS     = 10
91} Objects_Classes;
92
93#define OBJECTS_CLASSES_FIRST  OBJECTS_NO_CLASS
94#define OBJECTS_CLASSES_LAST   OBJECTS_RTEMS_EXTENSIONS
95
96/*
97 *  This enumerated type lists the locations which may be returned
98 *  by _Objects_Get.  These codes indicate the success of locating
99 *  an object with the specified ID.
100 */
101
102typedef enum {
103  OBJECTS_LOCAL  = 0,         /* object is local */
104  OBJECTS_REMOTE = 1,         /* object is remote */
105  OBJECTS_ERROR  = 2          /* id was invalid */
106}  Objects_Locations;
107
108/*
109 *  The following defines the Object Control Block used to manage
110 *  each object local to this node.
111 */
112
113typedef struct {
114  Chain_Node    Node;
115  Objects_Id    id;
116  Objects_Name  name;
117}   Objects_Control;
118
119/*
120 *  The following defines the structure for the information used to
121 *  manage each class of objects.
122 */
123
124typedef struct {
125  Objects_Classes   the_class;       /* Class of this object */
126  Objects_Id        minimum_id;      /* minimum valid id of this type */
127  Objects_Id        maximum_id;      /* maximum valid id of this type */
128  unsigned32        maximum;         /* maximum number of objects */
129  Objects_Control **local_table;     /* table of local object pointers */
130  Objects_Name     *name_table;      /* table of local object names */
131  Chain_Control    *global_table;    /* pointer to global table */
132  Chain_Control     Inactive;        /* chain of inactive ctl blocks */
133  boolean           is_string;       /* TRUE if names are strings */
134  unsigned32        name_length;     /* maximum length of names */
135  boolean           is_thread;       /* TRUE if these are threads */
136                                     /*   irregardless of API */
137}   Objects_Information;
138
139/*
140 *  The following defines the data storage which contains the
141 *  node number of the local node.
142 */
143
144EXTERN unsigned32  _Objects_Local_node;
145
146/*
147 *  The following is the list of information blocks for each object
148 *  class.  From the ID, we can go to one of these information blocks,
149 *  and obtain a pointer to the appropriate object control block.
150 */
151
152EXTERN Objects_Information
153    *_Objects_Information_table[OBJECTS_CLASSES_LAST + 1];
154
155/*
156 *  The following defines the constant which may be used
157 *  with _Objects_Get to manipulate the calling task.
158 *
159 */
160
161#define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
162
163/*
164 *  The following define the constants which may be used in name searches.
165 */
166
167#define RTEMS_SEARCH_ALL_NODES   0
168#define RTEMS_SEARCH_OTHER_NODES 0x7FFFFFFE
169#define RTEMS_SEARCH_LOCAL_NODE  0x7FFFFFFF
170#define RTEMS_WHO_AM_I           0
171
172/*
173 * Parameters and return id's for _Objects_Get_next
174 */
175
176#define RTEMS_OBJECT_ID_INITIAL_INDEX   (0)
177#define RTEMS_OBJECT_ID_FINAL_INDEX     (0xffff)
178
179#define RTEMS_OBJECT_ID_INITIAL(node)   (_Objects_Build_id(      \
180                                            OBJECTS_NO_CLASS, \
181                                            node, \
182                                            RTEMS_OBJECT_ID_INITIAL_INDEX))
183#define RTEMS_OBJECT_ID_FINAL           ((Objects_Id)~0)
184
185/*
186 *  _Objects_Handler_initialization
187 *
188 *  DESCRIPTION:
189 *
190 *  This function performs the initialization necessary for this handler.
191 *
192 */
193
194void _Objects_Handler_initialization(
195  unsigned32 node,
196  unsigned32 maximum_global_objects
197);
198
199/*
200 *  _Objects_Initialize_information
201 *
202 *  DESCRIPTION:
203 *
204 *  This function initializes an object class information record.
205 *  SUPPORTS_GLOBAL is TRUE if the object class supports global
206 *  objects, and FALSE otherwise.  Maximum indicates the number
207 *  of objects required in this class and size indicates the size
208 *  in bytes of each control block for this object class.
209 *
210 */
211
212void _Objects_Initialize_information (
213  Objects_Information *information,
214  Objects_Classes      the_class,
215  boolean              supports_global,
216  unsigned32           maximum,
217  unsigned32           size,
218  boolean              is_string,
219  unsigned32           maximum_name_length,
220  boolean              is_task
221);
222
223/*
224 *  _Objects_Clear_name
225 *
226 *  DESCRIPTION:
227 *
228 *  XXX
229 */
230 
231void _Objects_Clear_name(
232  void       *name,
233  unsigned32  length
234);
235
236/*
237 *  _Objects_Copy_name_string
238 *
239 *  DESCRIPTION:
240 *
241 *  XXX
242 */
243
244void _Objects_Copy_name_string(
245  void       *source,
246  void       *destination
247);
248
249/*
250 *  _Objects_Copy_name_raw
251 *
252 *  DESCRIPTION:
253 *
254 *  XXX
255 */
256
257void _Objects_Copy_name_raw(
258  void       *source,
259  void       *destination,
260  unsigned32  length
261);
262
263/*
264 *  _Objects_Compare_name_string
265 *
266 *  DESCRIPTION:
267 *
268 *  XXX
269 */
270
271boolean _Objects_Compare_name_string(
272  void       *name_1,
273  void       *name_2,
274  unsigned32  length
275);
276
277/*
278 *  _Objects_Compare_name_raw
279 *
280 *  DESCRIPTION:
281 *
282 *  XXX
283 */
284
285boolean _Objects_Compare_name_raw(
286  void       *name_1,
287  void       *name_2,
288  unsigned32  length
289);
290/*
291 *  _Objects_Name_to_id
292 *
293 *  DESCRIPTION:
294 *
295 *  This function implements the common portion of the object
296 *  identification directives.  This directive returns the object
297 *  id associated with name.  If more than one object of this class
298 *  is named name, then the object to which the id belongs is
299 *  arbitrary.  Node indicates the extent of the search for the
300 *  id of the object named name.  If the object class supports global
301 *  objects, then the search can be limited to a particular node
302 *  or allowed to encompass all nodes.
303 *
304 */
305
306rtems_status_code _Objects_Name_to_id(
307  Objects_Information *information,
308  Objects_Name         name,
309  unsigned32           node,
310  Objects_Id          *id
311);
312
313/*
314 *  _Objects_Get
315 *
316 *  DESCRIPTION:
317 *
318 *  This function maps object ids to object control blocks.
319 *  If id corresponds to a local object, then it returns
320 *  the_object control pointer which maps to id and location
321 *  is set to OBJECTS_LOCAL.  If the object class supports global
322 *  objects and the object id is global and resides on a remote
323 *  node, then location is set to OBJECTS_REMOTE, and the_object
324 *  is undefined.  Otherwise, location is set to OBJECTS_ERROR
325 *  and the_object is undefined.
326 *
327 */
328
329Objects_Control *_Objects_Get (
330  Objects_Information *information,
331  Objects_Id           id,
332  Objects_Locations   *location
333);
334
335/*
336 *  _Objects_Get_next
337 *
338 *  DESCRIPTION:
339 *
340 *  Like _Objects_Get, but is used to find "next" open object.
341 *
342 */
343
344Objects_Control *_Objects_Get_next(
345    Objects_Information *information,
346    Objects_Id           id,
347    unsigned32          *location_p,
348    Objects_Id          *next_id_p
349);
350
351/*
352 *  _Objects_Build_id
353 *
354 *  DESCRIPTION:
355 *
356 *  This function builds an object's id from the processor node and index
357 *  values specified.
358 *
359 */
360
361STATIC INLINE Objects_Id _Objects_Build_id(
362  Objects_Classes  the_class,
363  unsigned32       node,
364  unsigned32       index
365);
366
367/*
368 *  rtems_get_class
369 *
370 *  DESCRIPTION:
371 *
372 *  This function returns the class portion of the ID.
373 *
374 */
375 
376STATIC INLINE Objects_Classes rtems_get_class(
377  Objects_Id id
378);
379
380/*
381 *  rtems_get_node
382 *
383 *  DESCRIPTION:
384 *
385 *  This function returns the node portion of the ID.
386 *
387 */
388
389STATIC INLINE unsigned32 rtems_get_node(
390  Objects_Id id
391);
392
393/*
394 *  rtems_get_index
395 *
396 *  DESCRIPTION:
397 *
398 *  This function returns the index portion of the ID.
399 *
400 */
401
402STATIC INLINE unsigned32 rtems_get_index(
403  Objects_Id id
404);
405
406/*
407 *  _Objects_Is_local_node
408 *
409 *  DESCRIPTION:
410 *
411 *  This function returns TRUE if the node is of the local object, and
412 *  FALSE otherwise.
413 *
414 */
415
416STATIC INLINE boolean _Objects_Is_local_node(
417  unsigned32 node
418);
419
420/*
421 *  _Objects_Is_local_id
422 *
423 *  DESCRIPTION:
424 *
425 *  This function returns TRUE if the id is of a local object, and
426 *  FALSE otherwise.
427 *
428 */
429
430STATIC INLINE boolean _Objects_Is_local_id(
431  Objects_Id id
432);
433
434/*
435 *  _Objects_Are_ids_equal
436 *
437 *  DESCRIPTION:
438 *
439 *  This function returns TRUE if left and right are equal,
440 *  and FALSE otherwise.
441 *
442 */
443
444STATIC INLINE boolean _Objects_Are_ids_equal(
445  Objects_Id left,
446  Objects_Id right
447);
448
449/*
450 *  _Objects_Allocate
451 *
452 *  DESCRIPTION:
453 *
454 *  This function allocates a object control block from
455 *  the inactive chain of free object control blocks.
456 *
457 */
458
459STATIC INLINE Objects_Control *_Objects_Allocate(
460  Objects_Information *information
461);
462
463/*
464 *  _Objects_Free
465 *
466 *  DESCRIPTION:
467 *
468 *  This function frees a object control block to the
469 *  inactive chain of free object control blocks.
470 *
471 */
472
473STATIC INLINE void _Objects_Free(
474  Objects_Information *information,
475  Objects_Control     *the_object
476);
477
478/*
479 *  _Objects_Open
480 *
481 *  DESCRIPTION:
482 *
483 *  This function places the_object control pointer and object name
484 *  in the Local Pointer and Local Name Tables, respectively.
485 *
486 */
487
488STATIC INLINE void _Objects_Open(
489  Objects_Information *information,
490  Objects_Control     *the_object,
491  Objects_Name         name
492);
493
494/*
495 *  _Objects_Close
496 *
497 *  DESCRIPTION:
498 *
499 *  This function removes the_object control pointer and object name
500 *  in the Local Pointer and Local Name Tables.
501 *
502 */
503
504STATIC INLINE void _Objects_Close(
505  Objects_Information *information,
506  Objects_Control     *the_object
507);
508
509#include <rtems/object.inl>
510#include <rtems/objectmp.h>
511
512#ifdef __cplusplus
513}
514#endif
515
516#endif
517/* end of include file */
Note: See TracBrowser for help on using the repository browser.