source: rtems/cpukit/score/src/objectget.c @ e6f7f81

4.115
Last change on this file since e6f7f81 was 5a58b1e, checked in by Daniel Georgiev <daniel.georgiev95@…>, on 12/01/12 at 14:53:45

score misc: Score misc: Clean up Doxygen #11 (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

http://www.google-melange.com/gci/task/view/google/gci2012/8013204

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