source: rtems/cpukit/score/include/rtems/score/object.h @ 97e2729d

4.104.114.84.95
Last change on this file since 97e2729d was 97e2729d, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 23, 1998 at 5:38:09 PM

Added --disable-multiprocessing flag and modified a lot of files to make
it work.

  • Property mode set to 100644
File size: 9.8 KB
Line 
1/*  object.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with the Object Handler.  This Handler provides mechanisms which
5 *  can be used to initialize and manipulate all objects which have
6 *  ids.
7 *
8 *  COPYRIGHT (c) 1989-1998.
9 *  On-Line Applications Research Corporation (OAR).
10 *  Copyright assigned to U.S. Government, 1994.
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.OARcorp.com/rtems/license.html.
15 *
16 *  $Id$
17 */
18
19#ifndef __OBJECTS_h
20#define __OBJECTS_h
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <rtems/score/chain.h>
27
28/*
29 *  The following type defines the control block used to manage
30 *  object names.
31 */
32
33typedef void * Objects_Name;
34
35/*
36 *  Space for object names is allocated in multiples of this.
37 *
38 *  NOTE:  Must be a power of 2.  Matches the name manipulation routines.
39 */
40
41#define OBJECTS_NAME_ALIGNMENT     sizeof( unsigned32 )
42
43/*
44 *  Functions which compare names are prototyped like this.
45 */
46
47typedef boolean (*Objects_Name_comparators)(
48  void       * /* name_1 */,
49  void       * /* name_2 */,
50  unsigned32   /* length */
51);
52
53/*
54 *  The following type defines the control block used to manage
55 *  object IDs.  The format is as follows (0=LSB):
56 *
57 *     Bits  0 .. 15    = index
58 *     Bits 16 .. 25    = node
59 *     Bits 26 .. 31    = class
60 */
61
62typedef unsigned32 Objects_Id;
63
64#define OBJECTS_INDEX_START_BIT  0
65#define OBJECTS_NODE_START_BIT  16
66#define OBJECTS_CLASS_START_BIT 26
67
68#define OBJECTS_INDEX_MASK      0x0000ffff
69#define OBJECTS_NODE_MASK       0x03ff0000
70#define OBJECTS_CLASS_MASK      0xfc000000
71
72#define OBJECTS_INDEX_VALID_BITS  0x0000ffff
73#define OBJECTS_NODE_VALID_BITS   0x000003ff
74#define OBJECTS_CLASS_VALID_BITS  0x000000cf
75
76/*
77 *  This enumerated type is used in the class field of the object ID.
78 */
79
80typedef enum {
81  OBJECTS_NO_CLASS                  =  0,
82  OBJECTS_INTERNAL_THREADS          =  1,
83  OBJECTS_RTEMS_TASKS               =  2,
84  OBJECTS_POSIX_THREADS             =  3,
85  OBJECTS_RTEMS_TIMERS              =  4,
86  OBJECTS_RTEMS_SEMAPHORES          =  5,
87  OBJECTS_RTEMS_MESSAGE_QUEUES      =  6,
88  OBJECTS_RTEMS_PARTITIONS          =  7,
89  OBJECTS_RTEMS_REGIONS             =  8,
90  OBJECTS_RTEMS_PORTS               =  9,
91  OBJECTS_RTEMS_PERIODS             = 10,
92  OBJECTS_RTEMS_EXTENSIONS          = 11,
93  OBJECTS_POSIX_KEYS                = 12,
94  OBJECTS_POSIX_INTERRUPTS          = 13,
95  OBJECTS_POSIX_MESSAGE_QUEUES      = 14,
96  OBJECTS_POSIX_MUTEXES             = 15,
97  OBJECTS_POSIX_SEMAPHORES          = 16,
98  OBJECTS_POSIX_CONDITION_VARIABLES = 17
99} Objects_Classes;
100 
101#define OBJECTS_CLASSES_FIRST               OBJECTS_NO_CLASS
102#define OBJECTS_CLASSES_LAST                OBJECTS_POSIX_CONDITION_VARIABLES
103#define OBJECTS_CLASSES_FIRST_THREAD_CLASS  OBJECTS_INTERNAL_THREADS
104#define OBJECTS_CLASSES_LAST_THREAD_CLASS   OBJECTS_POSIX_THREADS
105
106/*
107 *  This enumerated type lists the locations which may be returned
108 *  by _Objects_Get.  These codes indicate the success of locating
109 *  an object with the specified ID.
110 */
111
112typedef enum {
113  OBJECTS_LOCAL  = 0,         /* object is local */
114  OBJECTS_REMOTE = 1,         /* object is remote */
115  OBJECTS_ERROR  = 2          /* id was invalid */
116}  Objects_Locations;
117
118/*
119 *  The following defines the Object Control Block used to manage
120 *  each object local to this node.
121 */
122
123typedef struct {
124  Chain_Node    Node;
125  Objects_Id    id;
126  Objects_Name  name;
127}   Objects_Control;
128
129/*
130 *  The following defines the structure for the information used to
131 *  manage each class of objects.
132 */
133
134typedef struct {
135  Objects_Classes   the_class;       /* Class of this object */
136  Objects_Id        minimum_id;      /* minimum valid id of this type */
137  Objects_Id        maximum_id;      /* maximum valid id of this type */
138  unsigned32        maximum;         /* maximum number of objects */
139  Objects_Control **local_table;     /* table of local object pointers */
140  Objects_Name     *name_table;      /* table of local object names */
141  Chain_Control    *global_table;    /* pointer to global table */
142  Chain_Control     Inactive;        /* chain of inactive ctl blocks */
143  boolean           is_string;       /* TRUE if names are strings */
144  unsigned32        name_length;     /* maximum length of names */
145  boolean           is_thread;       /* TRUE if these are threads */
146                                     /*   irregardless of API */
147}   Objects_Information;
148
149/*
150 *  The following defines the data storage which contains the
151 *  node number of the local node.
152 */
153
154SCORE_EXTERN unsigned32  _Objects_Local_node;
155SCORE_EXTERN unsigned32  _Objects_Maximum_nodes;
156
157/*
158 *  The following is the list of information blocks for each object
159 *  class.  From the ID, we can go to one of these information blocks,
160 *  and obtain a pointer to the appropriate object control block.
161 */
162
163SCORE_EXTERN Objects_Information
164    *_Objects_Information_table[OBJECTS_CLASSES_LAST + 1];
165
166/*
167 *  The following defines the constant which may be used
168 *  with _Objects_Get to manipulate the calling task.
169 *
170 */
171
172#define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
173
174/*
175 *  The following define the constants which may be used in name searches.
176 */
177
178#define OBJECTS_SEARCH_ALL_NODES   0
179#define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE
180#define OBJECTS_SEARCH_LOCAL_NODE  0x7FFFFFFF
181#define OBJECTS_WHO_AM_I           0
182
183/*
184 * Parameters and return id's for _Objects_Get_next
185 */
186
187#define OBJECTS_ID_INITIAL_INDEX   (0)
188#define OBJECTS_ID_FINAL_INDEX     (0xffff)
189
190#define OBJECTS_ID_INITIAL(_class, _node) \
191  _Objects_Build_id( (_class), (_node), OBJECTS_ID_INITIAL_INDEX )
192
193#define OBJECTS_ID_FINAL           ((Objects_Id)~0)
194
195/*
196 *  _Objects_Handler_initialization
197 *
198 *  DESCRIPTION:
199 *
200 *  This function performs the initialization necessary for this handler.
201 *
202 */
203
204void _Objects_Handler_initialization(
205  unsigned32 node,
206  unsigned32 maximum_nodes,
207  unsigned32 maximum_global_objects
208);
209
210/*
211 *  _Objects_Initialize_information
212 *
213 *  DESCRIPTION:
214 *
215 *  This function initializes an object class information record.
216 *  SUPPORTS_GLOBAL is TRUE if the object class supports global
217 *  objects, and FALSE otherwise.  Maximum indicates the number
218 *  of objects required in this class and size indicates the size
219 *  in bytes of each control block for this object class.  The
220 *  name length and string designator are also set.  In addition,
221 *  the class may be a task, therefore this information is also included.
222 */
223
224void _Objects_Initialize_information (
225  Objects_Information *information,
226  Objects_Classes      the_class,
227  boolean              supports_global,
228  unsigned32           maximum,
229  unsigned32           size,
230  boolean              is_string,
231  unsigned32           maximum_name_length,
232  boolean              is_task
233);
234
235/*
236 *  _Objects_Clear_name
237 *
238 *  DESCRIPTION:
239 *
240 *  XXX
241 */
242 
243void _Objects_Clear_name(
244  void       *name,
245  unsigned32  length
246);
247
248/*
249 *  _Objects_Copy_name_string
250 *
251 *  DESCRIPTION:
252 *
253 *  XXX
254 */
255
256void _Objects_Copy_name_string(
257  void       *source,
258  void       *destination
259);
260
261/*
262 *  _Objects_Copy_name_raw
263 *
264 *  DESCRIPTION:
265 *
266 *  XXX
267 */
268
269void _Objects_Copy_name_raw(
270  void       *source,
271  void       *destination,
272  unsigned32  length
273);
274
275/*
276 *  _Objects_Compare_name_string
277 *
278 *  DESCRIPTION:
279 *
280 *  XXX
281 */
282
283boolean _Objects_Compare_name_string(
284  void       *name_1,
285  void       *name_2,
286  unsigned32  length
287);
288
289/*
290 *  _Objects_Compare_name_raw
291 *
292 *  DESCRIPTION:
293 *
294 *  XXX
295 */
296
297boolean _Objects_Compare_name_raw(
298  void       *name_1,
299  void       *name_2,
300  unsigned32  length
301);
302/*
303 *  _Objects_Name_to_id
304 *
305 *  DESCRIPTION:
306 *
307 *  This function implements the common portion of the object
308 *  identification directives.  This directive returns the object
309 *  id associated with name.  If more than one object of this class
310 *  is named name, then the object to which the id belongs is
311 *  arbitrary.  Node indicates the extent of the search for the
312 *  id of the object named name.  If the object class supports global
313 *  objects, then the search can be limited to a particular node
314 *  or allowed to encompass all nodes.
315 *
316 */
317
318typedef enum {
319  OBJECTS_SUCCESSFUL,
320  OBJECTS_INVALID_NAME,
321  OBJECTS_INVALID_NODE
322} Objects_Name_to_id_errors;
323
324#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_SUCCESSFUL
325#define OBJECTS_NAME_ERRORS_LAST  OBJECTS_INVALID_NODE
326
327Objects_Name_to_id_errors _Objects_Name_to_id(
328  Objects_Information *information,
329  Objects_Name         name,
330  unsigned32           node,
331  Objects_Id          *id
332);
333
334/*
335 *  _Objects_Get
336 *
337 *  DESCRIPTION:
338 *
339 *  This function maps object ids to object control blocks.
340 *  If id corresponds to a local object, then it returns
341 *  the_object control pointer which maps to id and location
342 *  is set to OBJECTS_LOCAL.  If the object class supports global
343 *  objects and the object id is global and resides on a remote
344 *  node, then location is set to OBJECTS_REMOTE, and the_object
345 *  is undefined.  Otherwise, location is set to OBJECTS_ERROR
346 *  and the_object is undefined.
347 *
348 */
349
350Objects_Control *_Objects_Get (
351  Objects_Information *information,
352  Objects_Id           id,
353  Objects_Locations   *location
354);
355
356/*
357 *  _Objects_Get_next
358 *
359 *  DESCRIPTION:
360 *
361 *  Like _Objects_Get, but is used to find "next" open object.
362 *
363 */
364
365Objects_Control *_Objects_Get_next(
366    Objects_Information *information,
367    Objects_Id           id,
368    Objects_Locations   *location_p,
369    Objects_Id          *next_id_p
370);
371
372/*
373 *  _Objects_Get_information
374 *
375 *  DESCRIPTION:
376 *
377 *  Returns the information control block for the class of objects
378 *  corresponding to this id.
379 */
380
381Objects_Information *_Objects_Get_information(
382  Objects_Id  id
383);
384 
385/*
386 *  Pieces of object.inl are promoted out to the user
387 */
388
389#include <rtems/score/object.inl>
390#if defined(RTEMS_MULTIPROCESSING)
391#include <rtems/score/objectmp.h>
392#endif
393
394#ifdef __cplusplus
395}
396#endif
397
398#endif
399/* end of include file */
Note: See TracBrowser for help on using the repository browser.