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

4.104.114.84.9
Last change on this file since b568ccb was 317a5b5, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 2, 1999 at 7:43:52 PM

Split object.c into multiple files.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/score/address.h>
18#include <rtems/score/chain.h>
19#include <rtems/score/object.h>
20#if defined(RTEMS_MULTIPROCESSING)
21#include <rtems/score/objectmp.h>
22#endif
23#include <rtems/score/thread.h>
24#include <rtems/score/wkspace.h>
25#include <rtems/score/sysstate.h>
26#include <rtems/score/isr.h>
27
28/*PAGE
29 *
30 *  _Objects_Allocate_by_index
31 *
32 *  DESCRIPTION:
33 *
34 *  This function allocates the object control block
35 *  specified by the index from the inactive chain of
36 *  free object control blocks.
37 */
38
39Objects_Control *_Objects_Allocate_by_index(
40  Objects_Information *information,
41  unsigned32           index,
42  unsigned32           sizeof_control
43)
44{
45  Objects_Control *the_object;
46  void            *p;
47
48  if ( index && information->maximum >= index ) {
49    the_object = _Objects_Get_local_object( information, index );
50    if ( the_object )
51      return NULL;
52
53    /* XXX
54     *  This whole section of code needs to be addressed.
55     *    +  The 0 should be dealt with more properly so we can autoextend.
56     *    +  The pointer arithmetic is probably too expensive.
57     *    +  etc.
58     */
59   
60    p = _Addresses_Add_offset( information->object_blocks[ 0 ],
61        (information->allocation_size * information->name_length) ),
62
63    p = _Addresses_Add_offset( p, (sizeof_control * (index - 1)) );
64    the_object = (Objects_Control *)p;
65    _Chain_Extract( &the_object->Node );
66 
67    return the_object;   
68  }   
69
70  /*
71   *  Autoextend will have to be thought out as it applies
72   *  to user assigned indices.
73   */
74
75  return NULL;
76}
Note: See TracBrowser for help on using the repository browser.