source: rtems/cpukit/score/src/objectinitializeinformation.c @ 6e93dc4a

4.115
Last change on this file since 6e93dc4a was 6e93dc4a, checked in by Sebastian Huber <sebastian.huber@…>, on 07/22/13 at 08:49:19

score: Create chain implementation header

Move implementation specific parts of chain.h and chain.inl into new
header file chainimpl.h. The chain.h contains now only the application
visible API.

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