source: rtems/cpukit/score/inline/rtems/score/object.inl @ 4fc370e

4.115
Last change on this file since 4fc370e was 4fc370e, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 10:08:23

score: Move thread dispatch content to new file

Move thread dispatch declarations and inline functions to new header
<rtems/score/threaddispatch.h> to make it independent of the
Thread_Control structure. This avoids a cyclic dependency in case
thread dispatch functions are used for the object implementation.

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