summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/rtemsobjectgetclassinfo.c
blob: ffcbd96cae7032b11cf57a8600c447ef9b764dab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
 *  @file
 *
 *  @brief Get Class Information
 *  @ingroup ClassicClassInfo
 */

/*
 *  COPYRIGHT (c) 1989-2008.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <rtems/rtems/object.h>
#include <rtems/score/objectimpl.h>

rtems_status_code rtems_object_get_class_information(
  int                                 the_api,
  int                                 the_class,
  rtems_object_api_class_information *info
)
{
  Objects_Information *obj_info;
  int                  unallocated;
  int                  i;

  /*
   * Validate parameters and look up information structure.
   */
  if ( !info )
    return RTEMS_INVALID_ADDRESS;

  obj_info = _Objects_Get_information( the_api, the_class );
  if ( !obj_info )
    return RTEMS_INVALID_NUMBER;

  /*
   * Return information about this object class to the user.
   */
  info->minimum_id  = obj_info->minimum_id;
  info->maximum_id  = obj_info->maximum_id;
  info->auto_extend = obj_info->auto_extend;
  info->maximum     = obj_info->maximum;

  for ( unallocated=0, i=1 ; i <= info->maximum ; i++ )
    if ( !obj_info->local_table[i] )
      unallocated++;

  info->unallocated = unallocated;

  return RTEMS_SUCCESSFUL;
}