source: rtems/cpukit/score/src/objectallocatebyindex.c @ e3f6d35

4.10
Last change on this file since e3f6d35 was b028e725, checked in by Joel Sherrill <joel.sherrill@…>, on 01/05/09 at 20:09:02

2009-01-05 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/object.h, score/src/objectallocatebyindex.c: Object index should be int. Fix bug when index is negative.
  • score/src/objectextendinformation.c: Do not allow maximum number of allocated objects to exceed maximum representable in index field of Object Id.
  • score/src/objectgetisr.c: Use same code that is in _Objects_Get to extract index field of Object Id.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/address.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/object.h>
23#if defined(RTEMS_MULTIPROCESSING)
24#include <rtems/score/objectmp.h>
25#endif
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#include <rtems/score/sysstate.h>
29#include <rtems/score/isr.h>
30
31/*PAGE
32 *
33 *  _Objects_Allocate_by_index
34 *
35 *  DESCRIPTION:
36 *
37 *  This function allocates the object control block
38 *  specified by the index from the inactive chain of
39 *  free object control blocks.
40 */
41
42Objects_Control *_Objects_Allocate_by_index(
43  Objects_Information *information,
44  int                  the_index,
45  uint16_t             sizeof_control
46)
47{
48  Objects_Control *the_object;
49
50  if ( the_index > 0 && information->maximum >= the_index ) {
51    the_object = information->local_table[ the_index ];
52    if ( the_object )
53      return NULL;
54
55    /* XXX
56     *  This whole section of code needs to be evaluated for unlimited objects.
57     *    +  The 0 should be dealt with more properly so we can autoextend.
58     *    +  The pointer arithmetic is probably too expensive but is likely
59     *       necessary especially on targets with 16 bit offset limits.
60     *    +  etc.
61     */
62
63    the_object = (Objects_Control *) _Addresses_Add_offset(
64      information->object_blocks[ 0 ],
65      (sizeof_control * (the_index - 1))
66    );
67    _Chain_Extract( &the_object->Node );
68
69    return the_object;
70  }
71
72  /*
73   *  Autoextend will have to be thought out as it applies
74   *  to user assigned indices.
75   */
76
77  return NULL;
78}
Note: See TracBrowser for help on using the repository browser.