source: rtems/cpukit/score/include/rtems/score/object.h @ 9b3f187

4.104.114.84.95
Last change on this file since 9b3f187 was 9b3f187, checked in by Joel Sherrill <joel.sherrill@…>, on 11/29/04 at 22:45:43

2004-11-29 Joel Sherrill <joel@…>

  • libcsupport/src/mallocfreespace.c, rtems/Makefile.am, rtems/include/rtems/rtems/region.h, score/Makefile.am, score/include/rtems/score/heap.h, score/src/heapgetinfo.c: Add capability to return information about just the free blocks in a region or heap. Also changed the semantics of free space available to be the largest block of memory that can be allocated.
  • rtems/src/regiongetfreeinfo.c, score/src/heapgetfreeinfo.c: New files. : score/include/rtems/score/object.h, score/src/objectinitializeinformation.c: Remove warning.
  • Property mode set to 100644
File size: 15.1 KB
Line 
1/**
2 * @file  rtems/score/object.h
3 */
4 
5/*
6 *  This include file contains all the constants and structures associated
7 *  with the Object Handler.  This Handler provides mechanisms which
8 *  can be used to initialize and manipulate all objects which have
9 *  ids.
10 *
11 *  COPYRIGHT (c) 1989-2004.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21#ifndef __OBJECTS_h
22#define __OBJECTS_h
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#include <rtems/score/chain.h>
29#include <rtems/score/isr.h>
30
31/*
32 *  Mask to enable unlimited objects.  This is used in the configuration
33 *  table when specifying the number of configured objects.
34 */
35
36#define OBJECTS_UNLIMITED_OBJECTS 0x80000000
37
38/*
39 *  The following type defines the control block used to manage
40 *  object names.
41 */
42
43typedef void * Objects_Name;
44
45/*
46 *  Space for object names is allocated in multiples of this.
47 *
48 *  NOTE:  Must be a power of 2.  Matches the name manipulation routines.
49 */
50
51#define OBJECTS_NAME_ALIGNMENT     sizeof( uint32_t   )
52
53/*
54 *  Functions which compare names are prototyped like this.
55 */
56
57typedef boolean (*Objects_Name_comparators)(
58  void       * /* name_1 */,
59  void       * /* name_2 */,
60  uint16_t     /* length */
61);
62
63#if defined(RTEMS_USE_16_BIT_OBJECT)
64/*
65 *  The following type defines the control block used to manage
66 *  object IDs.  The format is as follows (0=LSB):
67 *
68 *     Bits  0 ..  7    = index  (up to 254 objects of a type)
69 *     Bits  8 .. 10    = API    (up to 7 API classes)
70 *     Bits 11 .. 15    = class  (up to 31 object types per API)
71 */
72
73typedef uint16_t   Objects_Id;
74typedef uint8_t    Objects_Maximum;
75
76#define OBJECTS_INDEX_START_BIT  0
77#define OBJECTS_API_START_BIT    8
78#define OBJECTS_CLASS_START_BIT 11
79
80#define OBJECTS_INDEX_MASK      (Objects_Id)0x000000ff
81#define OBJECTS_API_MASK        (Objects_Id)0x00000700
82#define OBJECTS_CLASS_MASK      (Objects_Id)0x0000F800
83
84#else
85/*
86 *  The following type defines the control block used to manage
87 *  object IDs.  The format is as follows (0=LSB):
88 *
89 *     Bits  0 .. 15    = index  (up to 65535 objects of a type)
90 *     Bits 16 .. 23    = node   (up to 255 nodes)
91 *     Bits 24 .. 26    = API    (up to 7 API classes)
92 *     Bits 27 .. 31    = class  (up to 31 object types per API)
93 */
94
95typedef uint32_t   Objects_Id;
96typedef uint16_t   Objects_Maximum;
97
98#define OBJECTS_INDEX_START_BIT  0
99#define OBJECTS_NODE_START_BIT  16
100#define OBJECTS_API_START_BIT   24
101#define OBJECTS_CLASS_START_BIT 27
102
103#define OBJECTS_INDEX_MASK      (Objects_Id)0x0000ffff
104#define OBJECTS_NODE_MASK       (Objects_Id)0x00ff0000
105#define OBJECTS_API_MASK        (Objects_Id)0x07000000
106#define OBJECTS_CLASS_MASK      (Objects_Id)0xf8000000
107
108#define OBJECTS_INDEX_VALID_BITS  (Objects_Id)0x0000ffff
109#define OBJECTS_NODE_VALID_BITS   (Objects_Id)0x000000ff
110#define OBJECTS_API_VALID_BITS    (Objects_Id)0x00000007
111#define OBJECTS_CLASS_VALID_BITS  (Objects_Id)0x0000001f
112#endif
113
114/*
115 *  This enumerated type is used in the class field of the object ID.
116 */
117
118#define OBJECTS_NO_CLASS 0
119
120typedef enum {
121  OBJECTS_NO_API       = 0,
122  OBJECTS_INTERNAL_API = 1,
123  OBJECTS_CLASSIC_API  = 2,
124  OBJECTS_POSIX_API    = 3,
125  OBJECTS_ITRON_API    = 4
126} Objects_APIs;
127
128#define OBJECTS_APIS_LAST OBJECTS_ITRON_API
129
130typedef enum {
131  OBJECTS_INTERNAL_NO_CLASS =  0,
132  OBJECTS_INTERNAL_THREADS  =  1,
133  OBJECTS_INTERNAL_MUTEXES  =  2
134} Objects_Internal_API;
135
136#define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_MUTEXES
137
138typedef enum {
139  OBJECTS_CLASSIC_NO_CLASS     = 0,
140  OBJECTS_RTEMS_TASKS          = 1,
141  OBJECTS_RTEMS_TIMERS         = 2,
142  OBJECTS_RTEMS_SEMAPHORES     = 3,
143  OBJECTS_RTEMS_MESSAGE_QUEUES = 4,
144  OBJECTS_RTEMS_PARTITIONS     = 5,
145  OBJECTS_RTEMS_REGIONS        = 6,
146  OBJECTS_RTEMS_PORTS          = 7,
147  OBJECTS_RTEMS_PERIODS        = 8,
148  OBJECTS_RTEMS_EXTENSIONS     = 9
149} Objects_Classic_API;
150
151#define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_EXTENSIONS
152
153typedef enum {
154  OBJECTS_POSIX_NO_CLASS            = 0,
155  OBJECTS_POSIX_THREADS             = 1,
156  OBJECTS_POSIX_KEYS                = 2,
157  OBJECTS_POSIX_INTERRUPTS          = 3,
158  OBJECTS_POSIX_MESSAGE_QUEUE_FDS   = 4,
159  OBJECTS_POSIX_MESSAGE_QUEUES      = 5,
160  OBJECTS_POSIX_MUTEXES             = 6,
161  OBJECTS_POSIX_SEMAPHORES          = 7,
162  OBJECTS_POSIX_CONDITION_VARIABLES = 8
163} Objects_POSIX_API;
164
165#define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_CONDITION_VARIABLES
166
167typedef enum {
168  OBJECTS_ITRON_NO_CLASS              = 0,
169  OBJECTS_ITRON_TASKS                 = 1,
170  OBJECTS_ITRON_EVENTFLAGS            = 2,
171  OBJECTS_ITRON_MAILBOXES             = 3,
172  OBJECTS_ITRON_MESSAGE_BUFFERS       = 4,
173  OBJECTS_ITRON_PORTS                 = 5,
174  OBJECTS_ITRON_SEMAPHORES            = 6,
175  OBJECTS_ITRON_VARIABLE_MEMORY_POOLS = 7,
176  OBJECTS_ITRON_FIXED_MEMORY_POOLS    = 8
177} Objects_ITRON_API;
178
179#define OBJECTS_ITRON_CLASSES_LAST OBJECTS_ITRON_FIXED_MEMORY_POOLS
180
181/*
182 *  This enumerated type lists the locations which may be returned
183 *  by _Objects_Get.  These codes indicate the success of locating
184 *  an object with the specified ID.
185 */
186
187typedef enum {
188  OBJECTS_LOCAL  = 0,         /* object is local */
189  OBJECTS_REMOTE = 1,         /* object is remote */
190  OBJECTS_ERROR  = 2          /* id was invalid */
191} Objects_Locations;
192
193/*
194 *  The following type defines the callout used when a local task
195 *  is extracted from a remote thread queue (i.e. it's proxy must
196 *  extracted from the remote queue).
197 */
198
199typedef void ( *Objects_Thread_queue_Extract_callout )( void * );
200
201/*
202 *  The following defines the Object Control Block used to manage
203 *  each object local to this node.
204 */
205
206typedef struct {
207  Chain_Node     Node;
208  Objects_Id     id;
209  Objects_Name   name;
210} Objects_Control;
211
212/*
213 *  The following defines the structure for the information used to
214 *  manage each class of objects.
215 */
216
217typedef struct {
218  Objects_APIs      the_api;            /* API of this object */
219  uint16_t          the_class;          /* class of this object */
220  Objects_Id        minimum_id;         /* minimum valid id of this type */
221  Objects_Id        maximum_id;         /* maximum valid id of this type */
222  Objects_Maximum   maximum;            /* maximum number of objects */
223  boolean           auto_extend;        /* TRUE if unlimited objects */
224  uint32_t          allocation_size;    /* number of objects in a block */
225  uint32_t          size;               /* size of the objects */
226  Objects_Control **local_table;
227  Objects_Name     *name_table;
228  Chain_Control     Inactive;           /* chain of inactive ctl blocks */
229  Objects_Maximum   inactive;           /* number of objects on the InActive list */
230  uint32_t         *inactive_per_block; /* used to release a block */
231  void            **object_blocks;      /* the object memory to remove */
232  boolean           is_string;          /* TRUE if names are strings */
233  uint16_t          name_length;        /* maximum length of names */
234  Objects_Thread_queue_Extract_callout extract;
235#if defined(RTEMS_MULTIPROCESSING)
236  Chain_Control    *global_table;       /* pointer to global table */
237#endif
238}   Objects_Information;
239
240/*
241 *  The following defines the data storage which contains the
242 *  node number of the local node.
243 */
244
245#if defined(RTEMS_MULTIPROCESSING)
246SCORE_EXTERN uint16_t    _Objects_Local_node;
247SCORE_EXTERN uint16_t    _Objects_Maximum_nodes;
248#else
249#define _Objects_Local_node    1
250#define _Objects_Maximum_nodes 1
251#endif
252
253/*
254 *  The following is the list of information blocks per API for each object
255 *  class.  From the ID, we can go to one of these information blocks,
256 *  and obtain a pointer to the appropriate object control block.
257 */
258
259SCORE_EXTERN Objects_Information
260    **_Objects_Information_table[OBJECTS_APIS_LAST + 1];
261
262/*
263 *  The following defines the constant which may be used
264 *  with _Objects_Get to manipulate the calling task.
265 *
266 */
267
268#define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
269
270/*
271 *  The following define the constants which may be used in name searches.
272 */
273
274#define OBJECTS_SEARCH_ALL_NODES   0
275#define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE
276#define OBJECTS_SEARCH_LOCAL_NODE  0x7FFFFFFF
277#define OBJECTS_WHO_AM_I           0
278
279/*
280 * Parameters and return id's for _Objects_Get_next
281 */
282
283#define OBJECTS_ID_INITIAL_INDEX   (0)
284#define OBJECTS_ID_FINAL_INDEX     (0xffff)
285
286#define OBJECTS_ID_INITIAL(_api, _class, _node) \
287  _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX )
288#define OBJECTS_ID_FINAL           ((Objects_Id)~0)
289
290/*
291 *  _Objects_Handler_initialization
292 *
293 *  DESCRIPTION:
294 *
295 *  This function performs the initialization necessary for this handler.
296 *
297 */
298
299void _Objects_Handler_initialization(
300  uint32_t   node,
301  uint32_t   maximum_nodes,
302  uint32_t   maximum_global_objects
303);
304
305/*
306 *  _Objects_Extend_information
307 *
308 *  DESCRIPTION:
309 *
310 *  This function extends an object class information record.
311 */
312
313void _Objects_Extend_information(
314  Objects_Information *information
315);
316
317/*
318 *  _Objects_Shrink_information
319 *
320 *  DESCRIPTION:
321 *
322 *  This function shrink an object class information record.
323 */
324
325void _Objects_Shrink_information(
326  Objects_Information *information
327);
328
329/*
330 *  _Objects_Initialize_information
331 *
332 *  DESCRIPTION:
333 *
334 *  This function initializes an object class information record.
335 *  SUPPORTS_GLOBAL is TRUE if the object class supports global
336 *  objects, and FALSE otherwise.  Maximum indicates the number
337 *  of objects required in this class and size indicates the size
338 *  in bytes of each control block for this object class.  The
339 *  name length and string designator are also set.  In addition,
340 *  the class may be a task, therefore this information is also included.
341 */
342
343void _Objects_Initialize_information (
344  Objects_Information *information,
345  Objects_APIs         the_api,
346  uint32_t             the_class,
347  Objects_Maximum      maximum,
348  uint16_t             size,
349  boolean              is_string,
350  uint32_t             maximum_name_length
351#if defined(RTEMS_MULTIPROCESSING)
352  ,
353  boolean              supports_global,
354  Objects_Thread_queue_Extract_callout extract
355#endif
356);
357
358/*PAGE
359 *
360 *  _Objects_Allocate
361 *
362 *  DESCRIPTION:
363 *
364 *  This function allocates a object control block from
365 *  the inactive chain of free object control blocks.
366 */
367
368Objects_Control *_Objects_Allocate(
369  Objects_Information *information
370);
371
372/*
373 *  _Objects_Allocate_by_index
374 *
375 *  DESCRIPTION:
376 *
377 *  This function allocates the object control block
378 *  specified by the index from the inactive chain of
379 *  free object control blocks.
380 */
381
382Objects_Control *_Objects_Allocate_by_index(
383  Objects_Information *information,
384  uint16_t             index,
385  uint16_t             sizeof_control
386);
387
388/*PAGE
389 *
390 *  _Objects_Free
391 *
392 *  DESCRIPTION:
393 *
394 *  This function frees a object control block to the
395 *  inactive chain of free object control blocks.
396 */
397
398void _Objects_Free(
399  Objects_Information *information,
400  Objects_Control     *the_object
401);
402
403/*
404 *  _Objects_Clear_name
405 *
406 *  DESCRIPTION:
407 *
408 *  This method zeroes out the name.
409 */
410
411void _Objects_Clear_name(
412  void       *name,
413  uint16_t    length
414);
415
416/*
417 *  _Objects_Copy_name_string
418 *
419 *  DESCRIPTION:
420 *
421 *  This method copies a string style object name from source to destination.
422 */
423
424void _Objects_Copy_name_string(
425  void       *source,
426  void       *destination,
427  uint16_t    length
428);
429
430/*
431 *  _Objects_Copy_name_raw
432 *
433 *  DESCRIPTION:
434 *
435 *  This method copies a raw style object name from source to destination.
436 */
437
438void _Objects_Copy_name_raw(
439  void       *source,
440  void       *destination,
441  uint16_t    length
442);
443
444/*
445 *  _Objects_Compare_name_string
446 *
447 *  DESCRIPTION:
448 *
449 *  This method compares two string style object names.
450 */
451
452boolean _Objects_Compare_name_string(
453  void       *name_1,
454  void       *name_2,
455  uint16_t    length
456);
457
458/*
459 *  _Objects_Compare_name_raw
460 *
461 *  DESCRIPTION:
462 *
463 *  This method compares two raw style object names.
464 */
465
466boolean _Objects_Compare_name_raw(
467  void       *name_1,
468  void       *name_2,
469  uint16_t    length
470);
471
472/*
473 *  _Objects_Name_to_id
474 *
475 *  DESCRIPTION:
476 *
477 *  This function implements the common portion of the object
478 *  identification directives.  This directive returns the object
479 *  id associated with name.  If more than one object of this class
480 *  is named name, then the object to which the id belongs is
481 *  arbitrary.  Node indicates the extent of the search for the
482 *  id of the object named name.  If the object class supports global
483 *  objects, then the search can be limited to a particular node
484 *  or allowed to encompass all nodes.
485 *
486 */
487
488typedef enum {
489  OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL,
490  OBJECTS_INVALID_NAME,
491  OBJECTS_INVALID_ADDRESS,
492  OBJECTS_INVALID_ID,
493  OBJECTS_INVALID_NODE
494} Objects_Name_or_id_lookup_errors;
495
496#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL
497#define OBJECTS_NAME_ERRORS_LAST  OBJECTS_INVALID_NODE
498
499Objects_Name_or_id_lookup_errors _Objects_Name_to_id(
500  Objects_Information *information,
501  Objects_Name         name,
502  uint32_t             node,
503  Objects_Id          *id
504);
505
506/*
507 *  _Objects_Id_to_Name
508 *
509 *  DESCRIPTION:
510 *
511 *  This function implements the common portion of the object Id
512 *  to name directives.  This function returns the name
513 *  associated with object id.
514 *
515 *  NOTE:
516 *
517 *  This function currently does not support string names.
518 */
519
520Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
521  Objects_Id      id,
522  Objects_Name   *name
523);
524
525/*
526 *  _Objects_Get
527 *
528 *  DESCRIPTION:
529 *
530 *  This function maps object ids to object control blocks.
531 *  If id corresponds to a local object, then it returns
532 *  the_object control pointer which maps to id and location
533 *  is set to OBJECTS_LOCAL.  If the object class supports global
534 *  objects and the object id is global and resides on a remote
535 *  node, then location is set to OBJECTS_REMOTE, and the_object
536 *  is undefined.  Otherwise, location is set to OBJECTS_ERROR
537 *  and the_object is undefined.
538 *
539 *  NOTE: _Objects_Get returns with dispatching disabled for
540 *        local and remote objects.
541 *        _Objects_Get_isr_disable returns with dispatching
542 *        disabled for remote objects and interrupts for local
543 *        objects.
544 */
545
546Objects_Control *_Objects_Get (
547  Objects_Information *information,
548  Objects_Id           id,
549  Objects_Locations   *location
550);
551
552Objects_Control *_Objects_Get_isr_disable(
553  Objects_Information *information,
554  Objects_Id           id,
555  Objects_Locations   *location,
556  ISR_Level           *level
557);
558
559Objects_Control *_Objects_Get_by_index (
560  Objects_Information *information,
561  Objects_Id           id,
562  Objects_Locations   *location
563);
564
565Objects_Control *_Objects_Get_no_protection(
566  Objects_Information *information,
567  Objects_Id           id,
568  Objects_Locations   *location
569);
570
571/*
572 *  _Objects_Get_next
573 *
574 *  DESCRIPTION:
575 *
576 *  Like _Objects_Get, but is used to find "next" open object.
577 *
578 */
579
580Objects_Control *_Objects_Get_next(
581    Objects_Information *information,
582    Objects_Id           id,
583    Objects_Locations   *location_p,
584    Objects_Id          *next_id_p
585);
586
587/*
588 *  Pieces of object.inl are promoted out to the user
589 */
590
591#include <rtems/score/object.inl>
592#if defined(RTEMS_MULTIPROCESSING)
593#include <rtems/score/objectmp.h>
594#endif
595
596#ifdef __cplusplus
597}
598#endif
599
600#endif
601/* end of include file */
Note: See TracBrowser for help on using the repository browser.