source: rtems/cpukit/score/inline/rtems/score/object.inl @ 5f1300a

4.115
Last change on this file since 5f1300a was 5f1300a, checked in by Sebastian Huber <sebastian.huber@…>, on 08/09/10 at 09:16:08

2010-08-09 Sebastian Huber <sebastian.huber@…>

  • score/inline/rtems/score/object.inl: Use attribute unused in _Objects_Is_local_id().
  • Property mode set to 100644
File size: 9.4 KB
Line 
1/**
2 * @file rtems/score/object.inl
3 */
4
5/*
6 *
7 *  This include file contains the static inline implementation of all
8 *  of the inlined routines in the Object Handler.
9 *
10 *  COPYRIGHT (c) 1989-2008.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#ifndef _RTEMS_SCORE_OBJECT_H
21# error "Never use <rtems/score/object.inl> directly; include <rtems/score/object.h> instead."
22#endif
23
24#ifndef _RTEMS_SCORE_OBJECT_INL
25#define _RTEMS_SCORE_OBJECT_INL
26
27/**
28 *  This function builds an object's id from the processor node and index
29 *  values specified.
30 *
31 *  @param[in] the_api indicates the API associated with this Id.
32 *  @param[in] the_class indicates the class of object.
33 *             It is specific to @a the_api.
34 *  @param[in] node is the node where this object resides.
35 *  @param[in] index is the instance number of this object.
36 *
37 *  @return This method returns an object Id constructed from the arguments.
38 */
39RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id(
40  Objects_APIs     the_api,
41  uint32_t         the_class,
42  uint32_t         node,
43  uint32_t         index
44)
45{
46  return (( (Objects_Id) the_api )   << OBJECTS_API_START_BIT)   |
47         (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) |
48         #if !defined(RTEMS_USE_16_BIT_OBJECT)
49           (( (Objects_Id) node )    << OBJECTS_NODE_START_BIT)  |
50         #endif
51         (( (Objects_Id) index )     << OBJECTS_INDEX_START_BIT);
52}
53
54/**
55 *  This function returns the API portion of the ID.
56 *
57 *  @param[in] id is the object Id to be processed.
58 *
59 *  @return This method returns an object Id constructed from the arguments.
60 */
61RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API(
62  Objects_Id id
63)
64{
65  return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS);
66}
67
68/**
69 *  This function returns the class portion of the ID.
70 *
71 *  @param[in] id is the object Id to be processed
72 */
73RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class(
74  Objects_Id id
75)
76{
77  return (uint32_t)
78    ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS);
79}
80 
81/**
82 *  This function returns the node portion of the ID.
83 *
84 *  @param[in] id is the object Id to be processed
85 *
86 *  @return This method returns the node portion of an object ID.
87 */
88RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node(
89  Objects_Id id
90)
91{
92  /*
93   * If using 16-bit Ids, then there is no node field and it MUST
94   * be a single processor system.
95   */
96  #if defined(RTEMS_USE_16_BIT_OBJECT)
97    return 1;
98  #else
99    return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS;
100  #endif
101}
102
103/**
104 *  This function returns the index portion of the ID.
105 *
106 *  @param[in] id is the Id to be processed
107 *
108 *  @return This method returns the class portion of the specified object ID.
109 */
110RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index(
111  Objects_Id id
112)
113{
114  return
115    (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) &
116                                          OBJECTS_INDEX_VALID_BITS);
117}
118
119/**
120 *  This function returns true if the api is valid.
121 *
122 *  @param[in] the_api is the api portion of an object ID.
123 *
124 *  @return This method returns true if the specified api value is valid
125 *          and false otherwise.
126 */
127RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid(
128  uint32_t   the_api
129)
130{
131  if ( !the_api || the_api > OBJECTS_APIS_LAST )
132   return false;
133  return true;
134}
135   
136/**
137 *  This function returns true if the node is of the local object, and
138 *  false otherwise.
139 *
140 *  @param[in] node is the node number and corresponds to the node number
141 *         portion of an object ID.
142 *
143 *  @return This method returns true if the specified node is the local node
144 *          and false otherwise.
145 */
146RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node(
147  uint32_t   node
148)
149{
150  return ( node == _Objects_Local_node );
151}
152
153/**
154 *  This function returns true if the id is of a local object, and
155 *  false otherwise.
156 *
157 *  @param[in] id is an object ID
158 *
159 *  @return This method returns true if the specified object Id is local
160 *          and false otherwise.
161 *
162 *  @note On a single processor configuration, this always returns true.
163 */
164RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(
165#if defined(RTEMS_MULTIPROCESSING)
166  Objects_Id id
167#else
168  Objects_Id id __attribute__((unused))
169#endif
170)
171{
172#if defined(RTEMS_MULTIPROCESSING)
173  return _Objects_Is_local_node( _Objects_Get_node(id) );
174#else
175  return true;
176#endif
177}
178
179/**
180 *  This function returns true if left and right are equal,
181 *  and false otherwise.
182 *
183 *  @param[in] left is the Id on the left hand side of the comparison
184 *  @param[in] right is the Id on the right hand side of the comparison
185 *
186 *  @return This method returns true if the specified object IDs are equal
187 *          and false otherwise.
188 */
189RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(
190  Objects_Id left,
191  Objects_Id right
192)
193{
194  return ( left == right );
195}
196
197/**
198 *  This function returns a pointer to the local_table object
199 *  referenced by the index.
200 *
201 *  @param[in] information points to an Object Information Table
202 *  @param[in] index is the index of the object the caller wants to access
203 *
204 *  @return This method returns a pointer to a local object or NULL if the
205 *          index is invalid and RTEMS_DEBUG is enabled.
206 */
207RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_local_object(
208  Objects_Information *information,
209  uint16_t             index
210)
211{
212  /*
213   *  This routine is ONLY to be called from places in the code
214   *  where the Id is known to be good.  Therefore, this should NOT
215   *  occur in normal situations.
216   */
217  #if defined(RTEMS_DEBUG)
218    if ( index > information->maximum )
219      return NULL;
220  #endif
221  return information->local_table[ index ];
222}
223
224/**
225 *  This function sets the pointer to the local_table object
226 *  referenced by the index.
227 *
228 *  @param[in] information points to an Object Information Table
229 *  @param[in] index is the index of the object the caller wants to access
230 *  @param[in] the_object is the local object pointer
231 *
232 *  @note This routine is ONLY to be called in places where the
233 *        index portion of the Id is known to be good.  This is
234 *        OK since it is normally called from object create/init
235 *        or delete/destroy operations.
236 */
237
238RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
239  Objects_Information *information,
240  uint32_t             index,
241  Objects_Control     *the_object
242)
243{
244  /*
245   *  This routine is ONLY to be called from places in the code
246   *  where the Id is known to be good.  Therefore, this should NOT
247   *  occur in normal situations.
248   */
249  #if defined(RTEMS_DEBUG)
250    if ( index > information->maximum )
251      return;
252  #endif
253
254  information->local_table[ index ] = the_object;
255}
256
257/**
258 *  This function sets the pointer to the local_table object
259 *  referenced by the index to a NULL so the object Id is invalid
260 *  after this call.
261 *
262 *  @param[in] information points to an Object Information Table
263 *  @param[in] the_object is the local object pointer
264 *
265 *  @note This routine is ONLY to be called in places where the
266 *        index portion of the Id is known to be good.  This is
267 *        OK since it is normally called from object create/init
268 *        or delete/destroy operations.
269 */
270
271RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(
272  Objects_Information  *information,
273  Objects_Control      *the_object
274)
275{
276  _Objects_Set_local_object(
277    information,
278    _Objects_Get_index( the_object->id ),
279    NULL
280  );
281}
282
283/**
284 *  This function places the_object control pointer and object name
285 *  in the Local Pointer and Local Name Tables, respectively.
286 *
287 *  @param[in] information points to an Object Information Table
288 *  @param[in] the_object is a pointer to an object
289 *  @param[in] name is the name of the object to make accessible
290 */
291RTEMS_INLINE_ROUTINE void _Objects_Open(
292  Objects_Information *information,
293  Objects_Control     *the_object,
294  Objects_Name         name
295)
296{
297  _Objects_Set_local_object(
298    information,
299    _Objects_Get_index( the_object->id ),
300    the_object
301  );
302
303  the_object->name = name;
304}
305
306/**
307 *  This function places the_object control pointer and object name
308 *  in the Local Pointer and Local Name Tables, respectively.
309 *
310 *  @param[in] information points to an Object Information Table
311 *  @param[in] the_object is a pointer to an object
312 *  @param[in] name is the name of the object to make accessible
313 */
314RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
315  Objects_Information *information,
316  Objects_Control     *the_object,
317  uint32_t             name
318)
319{
320  _Objects_Set_local_object(
321    information,
322    _Objects_Get_index( the_object->id ),
323    the_object
324  );
325
326  /* ASSERT: information->is_string == false */
327  the_object->name.name_u32 = name;
328}
329
330/**
331 *  This function places the_object control pointer and object name
332 *  in the Local Pointer and Local Name Tables, respectively.
333 *
334 *  @param[in] information points to an Object Information Table
335 *  @param[in] the_object is a pointer to an object
336 *  @param[in] name is the name of the object to make accessible
337 */
338RTEMS_INLINE_ROUTINE void _Objects_Open_string(
339  Objects_Information *information,
340  Objects_Control     *the_object,
341  const char          *name
342)
343{
344  _Objects_Set_local_object(
345    information,
346    _Objects_Get_index( the_object->id ),
347    the_object
348  );
349
350  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
351    /* ASSERT: information->is_string */
352    the_object->name.name_p = name;
353  #endif
354}
355
356#endif
357/* end of include file */
Note: See TracBrowser for help on using the repository browser.