source: rtems/cpukit/score/src/objectget.c @ 39046f7

4.115
Last change on this file since 39046f7 was 39046f7, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 09:09:23

score: Merge sysstate API into one file

  • Property mode set to 100644
File size: 2.3 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.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/isr.h>
31
32Objects_Control *_Objects_Get(
33  Objects_Information *information,
34  Objects_Id           id,
35  Objects_Locations   *location
36)
37{
38  Objects_Control *the_object;
39  uint32_t         index;
40
41  /*
42   *  Extract the index portion of an Id in a way that produces a valid
43   *  index for objects within this class and an invalid value for objects
44   *  outside this class.
45   *
46   *  If the Id matches the api, class, and node but index portion is 0,
47   *  then the subtraction will underflow and the addition of 1 will
48   *  result in a 0 index.  The zeroth element in the local_table is
49   *  always NULL.
50   *
51   *  If the Id is valid but the object has not been created yet, then
52   *  the local_table entry will be NULL.
53   */
54  index = id - information->minimum_id + 1;
55
56  /*
57   *  If the index is less than maximum, then it is OK to use it to
58   *  index into the local_table array.
59   */
60  if ( index <= information->maximum ) {
61    _Thread_Disable_dispatch();
62    if ( (the_object = information->local_table[ index ]) != NULL ) {
63      *location = OBJECTS_LOCAL;
64      return the_object;
65    }
66
67    /*
68     *  Valid Id for this API, Class and Node but the object has not
69     *  been allocated yet.
70     */
71    _Thread_Enable_dispatch();
72    *location = OBJECTS_ERROR;
73    return NULL;
74  }
75
76  /*
77   *  Object Id is not within this API and Class on this node.  So
78   *  it may be global in a multiprocessing system.  But it is clearly
79   *  invalid on a single processor system.
80   */
81  *location = OBJECTS_ERROR;
82
83#if defined(RTEMS_MULTIPROCESSING)
84  _Objects_MP_Is_remote( information, id, location, &the_object );
85  return the_object;
86#else
87  return NULL;
88#endif
89}
Note: See TracBrowser for help on using the repository browser.