source: rtems/cpukit/score/include/rtems/score/object.h @ f4a8ee1

4.104.114.84.95
Last change on this file since f4a8ee1 was f4a8ee1, checked in by Joel Sherrill <joel.sherrill@…>, on 03/17/99 at 16:01:03

Unlimited objects patch from Chris Johns <ccj@…>. Email follows:

First, the unlimited patch. I have compiled the unlmited patch for the
Linux posix BSP only and it seems to work cleanly. I would like a really
major application run on this change before commiting as the changes are
very core and significant. I am currently building all the tests to run.

I have no targets suitable to test on at the moment.

I have tested the patch for inline functions and macros.

Turning macros on has found some core bugs. I have fixed these but have
not run all the tests. Please review the patch for these changes. They
are:

1) The conditional compilation for MP support broke the core messages
code. You cannot embed a conditional macro in another macro. The Send
and Urgent Send calls are macros.

2) User extensions handler initialisation now has two parameters. I have
updated the macros to support the extra parameter.

The patch also contains the gcc-target-default.cfg fix required to build
the kernel. More of a by product than a fix for you.

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