source: rtems/cpukit/score/include/rtems/score/object.h @ 352c9b2

4.104.114.84.95
Last change on this file since 352c9b2 was 352c9b2, checked in by Joel Sherrill <joel.sherrill@…>, on 11/09/99 at 22:07:23

This patch adds the basic framework for the ITRON 3.0 API implementation
for RTEMS.

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