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

5
Last change on this file since 1506658c was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Initialize Object Information
5 * @ingroup ScoreObject
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2011.
10 *  On-Line Applications Research Corporation (OAR).
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.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/objectimpl.h>
22#include <rtems/score/chainimpl.h>
23#include <rtems/score/interr.h>
24#include <rtems/score/sysstate.h>
25#include <rtems/score/wkspace.h>
26
27void _Objects_Initialize_information(
28  Objects_Information *information,
29  Objects_APIs         the_api,
30  uint16_t             the_class,
31  uint32_t             maximum,
32  uint16_t             size,
33  bool                 is_string,
34  uint32_t             maximum_name_length
35#if defined(RTEMS_MULTIPROCESSING)
36  ,
37  bool                 supports_global,
38  Objects_Thread_queue_Extract_callout extract
39#endif
40)
41{
42  static Objects_Control *null_local_table = NULL;
43  uint32_t                minimum_index;
44  Objects_Maximum         maximum_per_allocation;
45  #if defined(RTEMS_MULTIPROCESSING)
46    uint32_t              index;
47  #endif
48
49  information->the_api            = the_api;
50  information->the_class          = the_class;
51  information->size               = size;
52  information->local_table        = 0;
53  information->inactive_per_block = 0;
54  information->object_blocks      = 0;
55  information->inactive           = 0;
56  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
57    information->is_string        = is_string;
58  #endif
59
60  /*
61   *  Set the maximum value to 0. It will be updated when objects are
62   *  added to the inactive set from _Objects_Extend_information()
63   */
64  information->maximum = 0;
65
66  /*
67   *  Register this Object Class in the Object Information Table.
68   */
69  _Objects_Information_table[ the_api ][ the_class ] = information;
70
71  /*
72   *  Are we operating in limited or unlimited (e.g. auto-extend) mode.
73   */
74  information->auto_extend = _Objects_Is_unlimited( maximum );
75  maximum_per_allocation = _Objects_Maximum_per_allocation( maximum );
76
77  /*
78   *  Unlimited and maximum of zero is illogical.
79   */
80  if ( information->auto_extend && maximum_per_allocation == 0) {
81    _Terminate(
82      INTERNAL_ERROR_CORE,
83      true,
84      INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0
85    );
86  }
87
88  /*
89   *  The allocation unit is the maximum value
90   */
91  information->allocation_size = maximum_per_allocation;
92
93  /*
94   *  Provide a null local table entry for the case of any empty table.
95   */
96  information->local_table = &null_local_table;
97
98  /*
99   *  Calculate minimum and maximum Id's
100   */
101  minimum_index = (maximum_per_allocation == 0) ? 0 : 1;
102  information->minimum_id =
103    _Objects_Build_id( the_api, the_class, _Objects_Local_node, minimum_index );
104
105  /*
106   *  Calculate the maximum name length
107   *
108   *  NOTE: Either 4 bytes for Classic API names or an arbitrary
109   *        number for POSIX names which are strings that may be
110   *        an odd number of bytes.
111   */
112
113  information->name_length = maximum_name_length;
114
115  _Chain_Initialize_empty( &information->Inactive );
116
117  /*
118   *  Initialize objects .. if there are any
119   */
120  if ( maximum_per_allocation ) {
121    /*
122     *  Always have the maximum size available so the current performance
123     *  figures are create are met.  If the user moves past the maximum
124     *  number then a performance hit is taken.
125     */
126    _Objects_Extend_information( information );
127  }
128
129  /*
130   *  Take care of multiprocessing
131   */
132  #if defined(RTEMS_MULTIPROCESSING)
133    information->extract = extract;
134
135    if ( (supports_global == true) && _System_state_Is_multiprocessing ) {
136
137      information->global_table =
138        (Chain_Control *) _Workspace_Allocate_or_fatal_error(
139          (_Objects_Maximum_nodes + 1) * sizeof(Chain_Control)
140        );
141
142      for ( index=1; index <= _Objects_Maximum_nodes ; index++ )
143        _Chain_Initialize_empty( &information->global_table[ index ] );
144     }
145     else
146       information->global_table = NULL;
147  #endif
148}
Note: See TracBrowser for help on using the repository browser.