source: rtems/cpukit/score/src/objectallocate.c @ 4fc370e

4.115
Last change on this file since 4fc370e was f2f63d1, checked in by Alex Ivanov <alexivanov97@…>, on 11/29/12 at 23:14:28

score misc: Score misc: Clean up Doxygen #7 (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

https://google-melange.appspot.com/gci/task/view/google/gci2012/7986214

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Allocate Object
5 *  @ingroup ScoreObject
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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/chain.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
33/* #define RTEMS_DEBUG_OBJECT_ALLOCATION */
34
35#if defined(RTEMS_DEBUG_OBJECT_ALLOCATION)
36#include <rtems/bspIo.h>
37#endif
38
39Objects_Control *_Objects_Allocate(
40  Objects_Information *information
41)
42{
43  Objects_Control *the_object;
44
45  /*
46   *  If the application is using the optional manager stubs and
47   *  still attempts to create the object, the information block
48   *  should be all zeroed out because it is in the BSS.  So let's
49   *  check that code for this manager is even present.
50   */
51  if ( information->size == 0 )
52    return NULL;
53
54  /*
55   *  OK.  The manager should be initialized and configured to have objects.
56   *  With any luck, it is safe to attempt to allocate an object.
57   */
58  the_object = (Objects_Control *) _Chain_Get( &information->Inactive );
59
60  if ( information->auto_extend ) {
61    /*
62     *  If the list is empty then we are out of objects and need to
63     *  extend information base.
64     */
65
66    if ( !the_object ) {
67      _Objects_Extend_information( information );
68      the_object =  (Objects_Control *) _Chain_Get( &information->Inactive );
69    }
70
71    if ( the_object ) {
72      uint32_t   block;
73
74      block = (uint32_t) _Objects_Get_index( the_object->id ) -
75              _Objects_Get_index( information->minimum_id );
76      block /= information->allocation_size;
77
78      information->inactive_per_block[ block ]--;
79      information->inactive--;
80    }
81  }
82
83#if defined(RTEMS_DEBUG_OBJECT_ALLOCATION)
84  if ( !the_object ) {
85    printk(
86      "OBJECT ALLOCATION FAILURE! API/Class %d/%d\n",
87      information->the_api,
88      information->the_class
89    );
90  }
91#endif
92
93  return the_object;
94}
Note: See TracBrowser for help on using the repository browser.