source: rtems/cpukit/score/src/objectget.c @ 25f5730f

4.11
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  @file
3 *
4 *  @brief Get Object
5 *  @ingroup Score
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/objectimpl.h>
22
23Objects_Control *_Objects_Get(
24  Objects_Information *information,
25  Objects_Id           id,
26  Objects_Locations   *location
27)
28{
29  Objects_Control *the_object;
30  uint32_t         index;
31
32  /*
33   *  Extract the index portion of an Id in a way that produces a valid
34   *  index for objects within this class and an invalid value for objects
35   *  outside this class.
36   *
37   *  If the Id matches the api, class, and node but index portion is 0,
38   *  then the subtraction will underflow and the addition of 1 will
39   *  result in a 0 index.  The zeroth element in the local_table is
40   *  always NULL.
41   *
42   *  If the Id is valid but the object has not been created yet, then
43   *  the local_table entry will be NULL.
44   */
45  index = id - information->minimum_id + 1;
46
47  /*
48   *  If the index is less than maximum, then it is OK to use it to
49   *  index into the local_table array.
50   */
51  if ( index <= information->maximum ) {
52    _Thread_Disable_dispatch();
53    if ( (the_object = information->local_table[ index ]) != NULL ) {
54      *location = OBJECTS_LOCAL;
55      return the_object;
56    }
57
58    /*
59     *  Valid Id for this API, Class and Node but the object has not
60     *  been allocated yet.
61     */
62    _Thread_Enable_dispatch();
63    *location = OBJECTS_ERROR;
64    return NULL;
65  }
66
67  /*
68   *  Object Id is not within this API and Class on this node.  So
69   *  it may be global in a multiprocessing system.  But it is clearly
70   *  invalid on a single processor system.
71   */
72  *location = OBJECTS_ERROR;
73
74#if defined(RTEMS_MULTIPROCESSING)
75  _Objects_MP_Is_remote( information, id, location, &the_object );
76  return the_object;
77#else
78  return NULL;
79#endif
80}
Note: See TracBrowser for help on using the repository browser.