source: rtems/cpukit/score/src/objectinitializeinformation.c @ 484a769

4.104.114.95
Last change on this file since 484a769 was 484a769, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/04/08 at 17:46:39

Convert to "bool".

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/address.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/object.h>
23#if defined(RTEMS_MULTIPROCESSING)
24#include <rtems/score/objectmp.h>
25#endif
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#include <rtems/score/sysstate.h>
29#include <rtems/score/isr.h>
30
31/*PAGE
32 *
33 *  _Objects_Initialize_information
34 *
35 *  This routine initializes all object information related data structures.
36 *
37 *  Input parameters:
38 *    information         - object information table
39 *    maximum             - maximum objects of this class
40 *    size                - size of this object's control block
41 *    is_string           - TRUE if names for this object are strings
42 *    maximum_name_length - maximum length of each object's name
43 *    When multiprocessing is configured,
44 *      supports_global     - TRUE if this is a global object class
45 *      extract_callout     - pointer to threadq extract callout
46 *
47 *  Output parameters:  NONE
48 */
49
50void _Objects_Initialize_information(
51  Objects_Information *information,
52  Objects_APIs         the_api,
53  uint32_t             the_class,
54  uint32_t             maximum,
55  uint16_t             size,
56  bool                 is_string,
57  uint32_t             maximum_name_length
58#if defined(RTEMS_MULTIPROCESSING)
59  ,
60  bool                 supports_global,
61  Objects_Thread_queue_Extract_callout extract
62#endif
63)
64{
65  static Objects_Control *null_local_table = NULL;
66  uint32_t                minimum_index;
67  uint32_t                name_length;
68#if defined(RTEMS_MULTIPROCESSING)
69  uint32_t                index;
70#endif
71
72  information->the_api            = the_api;
73  information->the_class          = the_class;
74  information->is_string          = is_string;
75
76  information->local_table        = 0;
77  information->inactive_per_block = 0;
78  information->object_blocks      = 0;
79
80  information->inactive           = 0;
81
82  /*
83   *  Set the entry in the object information table.
84   */
85
86  _Objects_Information_table[ the_api ][ the_class ] = information;
87
88  /*
89   *  Set the size of the object
90   */
91
92  information->size = size;
93
94  /*
95   *  Are we operating in unlimited, or auto-extend mode
96   */
97
98  information->auto_extend =
99        (maximum & OBJECTS_UNLIMITED_OBJECTS) ? TRUE : FALSE;
100  maximum                 &= ~OBJECTS_UNLIMITED_OBJECTS;
101
102  /*
103   *  The allocation unit is the maximum value
104   */
105
106  information->allocation_size = maximum;
107
108  /*
109   *  Provide a null local table entry for the case of any empty table.
110   */
111
112  information->local_table = &null_local_table;
113
114  /*
115   *  Calculate minimum and maximum Id's
116   */
117
118  if ( maximum == 0 ) minimum_index = 0;
119  else                minimum_index = 1;
120
121  information->minimum_id =
122    _Objects_Build_id( the_api, the_class, _Objects_Local_node, minimum_index );
123
124  /*
125   *  Calculate the maximum name length
126   */
127
128  name_length = maximum_name_length;
129
130  if ( name_length & (OBJECTS_NAME_ALIGNMENT-1) )
131    name_length = (name_length + OBJECTS_NAME_ALIGNMENT) &
132                  ~(OBJECTS_NAME_ALIGNMENT-1);
133
134  information->name_length = name_length;
135
136  _Chain_Initialize_empty( &information->Inactive );
137
138  /*
139   *  Initialize objects .. if there are any
140   */
141
142  if ( maximum ) {
143
144    /*
145     *  Reset the maximum value. It will be updated when the information is
146     *  extended.
147     */
148
149    information->maximum = 0;
150
151    /*
152     *  Always have the maximum size available so the current performance
153     *  figures are create are met.  If the user moves past the maximum
154     *  number then a performance hit is taken.
155     */
156
157    _Objects_Extend_information( information );
158
159  }
160
161  /*
162   *  Take care of multiprocessing
163   */
164
165#if defined(RTEMS_MULTIPROCESSING)
166  information->extract = extract;
167
168  if ( (supports_global == true) && _System_state_Is_multiprocessing ) {
169
170    information->global_table =
171      (Chain_Control *) _Workspace_Allocate_or_fatal_error(
172        (_Objects_Maximum_nodes + 1) * sizeof(Chain_Control)
173      );
174
175    for ( index=1; index <= _Objects_Maximum_nodes ; index++ )
176      _Chain_Initialize_empty( &information->global_table[ index ] );
177   }
178   else
179     information->global_table = NULL;
180#endif
181}
Note: See TracBrowser for help on using the repository browser.