source: rtems/cpukit/score/src/objectinitializeinformation.c @ eabaf58

4.104.115
Last change on this file since eabaf58 was eabaf58, checked in by Joel Sherrill <joel.sherrill@…>, on 03/10/10 at 18:15:33

2010-03-10 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/interr.h, score/src/objectinitializeinformation.c: Add new fatal error for configuring unlimited and maximum of 0.
  • Property mode set to 100644
File size: 4.9 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  uint32_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  name_length = maximum_name_length;
133
134  if ( name_length & (OBJECTS_NAME_ALIGNMENT-1) )
135    name_length = (name_length + OBJECTS_NAME_ALIGNMENT) &
136                  ~(OBJECTS_NAME_ALIGNMENT-1);
137
138  information->name_length = name_length;
139
140  _Chain_Initialize_empty( &information->Inactive );
141
142  /*
143   *  Initialize objects .. if there are any
144   */
145  if ( maximum_per_allocation ) {
146    /*
147     *  Always have the maximum size available so the current performance
148     *  figures are create are met.  If the user moves past the maximum
149     *  number then a performance hit is taken.
150     */
151    _Objects_Extend_information( information );
152  }
153
154  /*
155   *  Take care of multiprocessing
156   */
157  #if defined(RTEMS_MULTIPROCESSING)
158    information->extract = extract;
159
160    if ( (supports_global == true) && _System_state_Is_multiprocessing ) {
161
162      information->global_table =
163        (Chain_Control *) _Workspace_Allocate_or_fatal_error(
164          (_Objects_Maximum_nodes + 1) * sizeof(Chain_Control)
165        );
166
167      for ( index=1; index <= _Objects_Maximum_nodes ; index++ )
168        _Chain_Initialize_empty( &information->global_table[ index ] );
169     }
170     else
171       information->global_table = NULL;
172  #endif
173}
Note: See TracBrowser for help on using the repository browser.