source: rtems/cpukit/score/src/objectinitializeinformation.c @ 2af90ff

4.115
Last change on this file since 2af90ff was 2af90ff, checked in by Joel Sherrill <joel.sherrill@…>, on 02/11/11 at 20:38:16

2011-02-11 Joel Sherrill <joel.sherrilL@…>

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