source: rtems/cpukit/score/src/objectallocate.c @ 21275b58

5
Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/18 at 18:14:51

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[f2f63d1]1/**
2 *  @file
[317a5b5]3 *
[f2f63d1]4 *  @brief Allocate Object
5 *  @ingroup ScoreObject
6 */
7
8/*
[08311cc3]9 *  COPYRIGHT (c) 1989-1999.
[317a5b5]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
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[317a5b5]15 */
16
[a8eed23]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[a2e3f33]21#include <rtems/score/objectimpl.h>
[23fec9f0]22#include <rtems/score/assert.h>
[6e93dc4a]23#include <rtems/score/chainimpl.h>
[23fec9f0]24#include <rtems/score/sysstate.h>
[317a5b5]25
[23fec9f0]26static Objects_Control *_Objects_Get_inactive(
27  Objects_Information *information
28)
29{
30  return (Objects_Control *) _Chain_Get_unprotected( &information->Inactive );
31}
32
33Objects_Control *_Objects_Allocate_unprotected(
[317a5b5]34  Objects_Information *information
35)
36{
[404903b]37  Objects_Control *the_object;
38
[23fec9f0]39  _Assert(
[6c2b8a4b]40    _Objects_Allocator_is_owner()
[23fec9f0]41      || !_System_state_Is_up( _System_state_Get() )
42  );
43
[404903b]44  /*
45   *  If the application is using the optional manager stubs and
46   *  still attempts to create the object, the information block
47   *  should be all zeroed out because it is in the BSS.  So let's
48   *  check that code for this manager is even present.
49   */
[0da9d80]50  if ( information->object_size == 0 )
[404903b]51    return NULL;
52
53  /*
54   *  OK.  The manager should be initialized and configured to have objects.
55   *  With any luck, it is safe to attempt to allocate an object.
56   */
[23fec9f0]57  the_object = _Objects_Get_inactive( information );
[317a5b5]58
[8b0e752f]59  if ( _Objects_Is_auto_extend( information ) ) {
[317a5b5]60    /*
61     *  If the list is empty then we are out of objects and need to
62     *  extend information base.
63     */
[05279b84]64
[3899bc1a]65    if ( the_object == NULL ) {
[317a5b5]66      _Objects_Extend_information( information );
[23fec9f0]67      the_object = _Objects_Get_inactive( information );
[317a5b5]68    }
[05279b84]69
[3899bc1a]70    if ( the_object != NULL ) {
[21275b58]71      Objects_Maximum objects_per_block;
[3899bc1a]72      Objects_Maximum block;
[05279b84]73
[21275b58]74      objects_per_block = information->objects_per_block;
[3899bc1a]75      block = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
[05279b84]76
[21275b58]77      if ( block > objects_per_block ) {
78        block /= objects_per_block;
79
80        information->inactive_per_block[ block ]--;
81        information->inactive--;
82      }
[317a5b5]83    }
84  }
[05279b84]85
[317a5b5]86  return the_object;
87}
[23fec9f0]88
89Objects_Control *_Objects_Allocate( Objects_Information *information )
90{
91  _RTEMS_Lock_allocator();
92
93  return _Objects_Allocate_unprotected( information );
94}
Note: See TracBrowser for help on using the repository browser.