source: rtems/c/src/exec/score/headers/object.h @ 7f6a24ab

4.104.114.84.95
Last change on this file since 7f6a24ab was 7f6a24ab, checked in by Joel Sherrill <joel.sherrill@…>, on 08/28/95 at 15:30:29

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

  • Property mode set to 100644
File size: 11.7 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_Get_information
353 *
354 *  DESCRIPTION:
355 *
356 *  Returns the information control block for the class of objects
357 *  corresponding to this id.
358 */
359
360Objects_Information *_Objects_Get_information(
361  Objects_Id  id
362);
363 
364/*
365 *  _Objects_Build_id
366 *
367 *  DESCRIPTION:
368 *
369 *  This function builds an object's id from the processor node and index
370 *  values specified.
371 *
372 */
373
374STATIC INLINE Objects_Id _Objects_Build_id(
375  Objects_Classes  the_class,
376  unsigned32       node,
377  unsigned32       index
378);
379
380/*
381 *  rtems_get_class
382 *
383 *  DESCRIPTION:
384 *
385 *  This function returns the class portion of the ID.
386 *
387 */
388 
389STATIC INLINE Objects_Classes rtems_get_class(
390  Objects_Id id
391);
392
393/*
394 *  rtems_get_node
395 *
396 *  DESCRIPTION:
397 *
398 *  This function returns the node portion of the ID.
399 *
400 */
401
402STATIC INLINE unsigned32 rtems_get_node(
403  Objects_Id id
404);
405
406/*
407 *  rtems_get_index
408 *
409 *  DESCRIPTION:
410 *
411 *  This function returns the index portion of the ID.
412 *
413 */
414
415STATIC INLINE unsigned32 rtems_get_index(
416  Objects_Id id
417);
418
419/*
420 *  _Objects_Is_class_valid
421 *
422 *  DESCRIPTION:
423 *
424 *  This function returns TRUE if the class is valid.
425 *
426 */
427 
428STATIC INLINE boolean _Objects_Is_class_valid(
429  Objects_Classes the_class
430);
431
432/*
433 *  _Objects_Is_local_node
434 *
435 *  DESCRIPTION:
436 *
437 *  This function returns TRUE if the node is of the local object, and
438 *  FALSE otherwise.
439 *
440 */
441
442STATIC INLINE boolean _Objects_Is_local_node(
443  unsigned32 node
444);
445
446/*
447 *  _Objects_Is_local_id
448 *
449 *  DESCRIPTION:
450 *
451 *  This function returns TRUE if the id is of a local object, and
452 *  FALSE otherwise.
453 *
454 */
455
456STATIC INLINE boolean _Objects_Is_local_id(
457  Objects_Id id
458);
459
460/*
461 *  _Objects_Are_ids_equal
462 *
463 *  DESCRIPTION:
464 *
465 *  This function returns TRUE if left and right are equal,
466 *  and FALSE otherwise.
467 *
468 */
469
470STATIC INLINE boolean _Objects_Are_ids_equal(
471  Objects_Id left,
472  Objects_Id right
473);
474
475/*
476 *  _Objects_Allocate
477 *
478 *  DESCRIPTION:
479 *
480 *  This function allocates a object control block from
481 *  the inactive chain of free object control blocks.
482 *
483 */
484
485STATIC INLINE Objects_Control *_Objects_Allocate(
486  Objects_Information *information
487);
488
489/*
490 *  _Objects_Free
491 *
492 *  DESCRIPTION:
493 *
494 *  This function frees a object control block to the
495 *  inactive chain of free object control blocks.
496 *
497 */
498
499STATIC INLINE void _Objects_Free(
500  Objects_Information *information,
501  Objects_Control     *the_object
502);
503
504/*
505 *  _Objects_Open
506 *
507 *  DESCRIPTION:
508 *
509 *  This function places the_object control pointer and object name
510 *  in the Local Pointer and Local Name Tables, respectively.
511 *
512 */
513
514STATIC INLINE void _Objects_Open(
515  Objects_Information *information,
516  Objects_Control     *the_object,
517  Objects_Name         name
518);
519
520/*
521 *  _Objects_Close
522 *
523 *  DESCRIPTION:
524 *
525 *  This function removes the_object control pointer and object name
526 *  in the Local Pointer and Local Name Tables.
527 *
528 */
529
530STATIC INLINE void _Objects_Close(
531  Objects_Information *information,
532  Objects_Control     *the_object
533);
534
535#include <rtems/object.inl>
536#include <rtems/objectmp.h>
537
538#ifdef __cplusplus
539}
540#endif
541
542#endif
543/* end of include file */
Note: See TracBrowser for help on using the repository browser.