source: rtems/cpukit/score/inline/rtems/score/object.inl @ 6c06288

4.104.114.95
Last change on this file since 6c06288 was 6c06288, checked in by Joel Sherrill <joel.sherrill@…>, on 01/29/08 at 21:52:21

2008-01-29 Joel Sherrill <joel.sherrill@…>

  • itron/src/exd_tsk.c, itron/src/task.c, libmisc/capture/capture.c, libmisc/monitor/mon-config.c, libmisc/monitor/mon-driver.c, libmisc/monitor/mon-itask.c, libmisc/monitor/mon-monitor.c, libmisc/monitor/mon-mpci.c, libmisc/monitor/mon-object.c, libmisc/monitor/mon-symbols.c, posix/src/cancelrun.c, posix/src/pthreadexit.c, rtems/Makefile.am, rtems/preinstall.am, rtems/include/rtems.h, rtems/include/rtems/rtems/support.h, rtems/inline/rtems/rtems/tasks.inl, rtems/src/eventmp.c, rtems/src/msgmp.c, rtems/src/partmp.c, rtems/src/regionmp.c, rtems/src/rtemsobjectgetname.c, rtems/src/semmp.c, rtems/src/signalmp.c, rtems/src/taskdelete.c, rtems/src/taskmp.c, rtems/src/timerserver.c, score/Makefile.am, score/include/rtems/score/object.h, score/inline/rtems/score/object.inl, score/src/Unlimited.txt, score/src/objectgetnameasstring.c, score/src/threadqextractwithproxy.c: Add new Object Services collection. This changed the name of a few previously public but undocumented services and added a some new services.
  • rtems/include/rtems/rtems/object.h, rtems/src/rtemsbuildid.c, rtems/src/rtemsbuildname.c, rtems/src/rtemsobjectapimaximumclass.c, rtems/src/rtemsobjectapiminimumclass.c, rtems/src/rtemsobjectgetapiclassname.c, rtems/src/rtemsobjectgetapiname.c, rtems/src/rtemsobjectgetclassicname.c, rtems/src/rtemsobjectgetclassinfo.c, rtems/src/rtemsobjectidapimaximum.c, rtems/src/rtemsobjectidapiminimum.c, rtems/src/rtemsobjectidgetapi.c, rtems/src/rtemsobjectidgetclass.c, rtems/src/rtemsobjectidgetindex.c, rtems/src/rtemsobjectidgetnode.c, rtems/src/rtemsobjectsetname.c, score/src/objectapimaximumclass.c, score/src/objectgetinfo.c, score/src/objectgetinfoid.c, score/src/objectsetname.c: New files.
  • rtems/src/rtemsidtoname.c: Removed.
  • Property mode set to 100644
File size: 9.3 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_INL
21#define _RTEMS_SCORE_OBJECT_INL
22
23/**
24 *  This function builds an object's id from the processor node and index
25 *  values specified.
26 *
27 *  @param[in] the_api indicates the API associated with this Id.
28 *  @param[in] the_class indicates the class of object.
29 *             It is specific to @a the_api.
30 *  @param[in] node is the node where this object resides.
31 *  @param[in] index is the instance number of this object.
32 *
33 *  @return This method returns an object Id constructed from the arguments.
34 */
35RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id(
36  Objects_APIs     the_api,
37  uint32_t         the_class,
38  uint32_t         node,
39  uint32_t         index
40)
41{
42  return (( (Objects_Id) the_api )   << OBJECTS_API_START_BIT)   |
43         (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) |
44         (( (Objects_Id) node )      << OBJECTS_NODE_START_BIT)  |
45         (( (Objects_Id) index )     << OBJECTS_INDEX_START_BIT);
46}
47
48/**
49 *  This function returns the API portion of the ID.
50 *
51 *  @param[in] id is the object Id to be processed.
52 *
53 *  @return This method returns an object Id constructed from the arguments.
54 */
55RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API(
56  Objects_Id id
57)
58{
59  return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS);
60}
61
62/**
63 *  This function returns the class portion of the ID.
64 *
65 *  @param[in] id is the object Id to be processed
66 */
67RTEMS_INLINE_ROUTINE uint32_t   _Objects_Get_class(
68  Objects_Id id
69)
70{
71  return (uint32_t  )
72    ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS);
73}
74 
75/**
76 *  This function returns the node portion of the ID.
77 *
78 *  @param[in] id is the object Id to be processed
79 *
80 *  @return This method returns the node portion of an object ID.
81 */
82RTEMS_INLINE_ROUTINE uint32_t   _Objects_Get_node(
83  Objects_Id id
84)
85{
86  return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS;
87}
88
89/**
90 *  This function returns the index portion of the ID.
91 *
92 *  @param[in] id is the Id to be processed
93 *
94 *  @return This method returns the class portion of the specified object ID.
95 */
96RTEMS_INLINE_ROUTINE uint32_t   _Objects_Get_index(
97  Objects_Id id
98)
99{
100  return (id >> OBJECTS_INDEX_START_BIT) & OBJECTS_INDEX_VALID_BITS;
101}
102
103/**
104 *  This function returns TRUE if the api is valid.
105 *
106 *  @param[in] the_api is the api portion of an object ID.
107 *
108 *  @return This method returns TRUE if the specified api value is valid
109 *          and FALSE otherwise.
110 */
111RTEMS_INLINE_ROUTINE boolean _Objects_Is_api_valid(
112  uint32_t   the_api
113)
114{
115  if ( !the_api || the_api > OBJECTS_APIS_LAST )
116   return FALSE;
117  return TRUE;
118}
119   
120/**
121 *  This function returns TRUE if the class is valid.
122 *
123 *  @param[in] the_class is the class portion of an object ID.
124 *
125 *  @return This method returns TRUE if the specified class value is valid
126 *          and FALSE otherwise.
127 */
128RTEMS_INLINE_ROUTINE boolean _Objects_Is_class_valid(
129  uint32_t   the_class
130)
131{
132  /* XXX how do we determine this now? */
133  return TRUE; /* the_class && the_class <= OBJECTS_CLASSES_LAST; */
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 boolean _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 boolean _Objects_Is_local_id(
165  Objects_Id id
166)
167{
168#if defined(RTEMS_MULTIPROCESSING)
169  return _Objects_Is_local_node( _Objects_Get_node(id) );
170#else
171  return TRUE;
172#endif
173}
174
175/**
176 *  This function returns TRUE if left and right are equal,
177 *  and FALSE otherwise.
178 *
179 *  @param[in] left is the Id on the left hand side of the comparison
180 *  @param[in] right is the Id on the right hand side of the comparison
181 *
182 *  @return This method returns TRUE if the specified object IDs are equal
183 *          and FALSE otherwise.
184 */
185RTEMS_INLINE_ROUTINE boolean _Objects_Are_ids_equal(
186  Objects_Id left,
187  Objects_Id right
188)
189{
190  return ( left == right );
191}
192
193/**
194 *  This function returns a pointer to the local_table object
195 *  referenced by the index.
196 *
197 *  @param[in] information points to an Object Information Table
198 *  @param[in] index is the index of the object the caller wants to access
199 *
200 *  @return This method returns a pointer to a local object or NULL if the
201 *          index is invalid.
202 */
203RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_local_object(
204  Objects_Information *information,
205  uint16_t             index
206)
207{
208  if ( index > information->maximum )
209    return NULL;
210  return information->local_table[ index ];
211}
212
213/**
214 *  This function sets the pointer to the local_table object
215 *  referenced by the index.
216 *
217 *  @param[in] information points to an Object Information Table
218 *  @param[in] index is the index of the object the caller wants to access
219 *  @param[in] the_object is the local object pointer
220 *
221 *  @note This routine is ONLY to be called in places where the
222 *        index portion of the Id is known to be good.  This is
223 *        OK since it is normally called from object create/init
224 *        or delete/destroy operations.
225 */
226
227RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
228  Objects_Information *information,
229  uint16_t             index,
230  Objects_Control     *the_object
231)
232{
233  /*
234   *  This routine is ONLY to be called from places in the code
235   *  where the Id is known to be good.  Therefore, this should NOT
236   *  occur in normal situations.
237   */
238  #if defined(RTEMS_DEBUG)
239    if ( index > information->maximum )
240      return;
241  #endif
242
243  information->local_table[ index ] = the_object;
244}
245
246/**
247 *  This function places the_object control pointer and object name
248 *  in the Local Pointer and Local Name Tables, respectively.
249 *
250 *  @param[in] information points to an Object Information Table
251 *  @param[in] the_object is a pointer to an object
252 *  @param[in] name is the name of the object to make accessible
253 */
254RTEMS_INLINE_ROUTINE void _Objects_Open(
255  Objects_Information *information,
256  Objects_Control     *the_object,
257  Objects_Name         name
258)
259{
260  uint32_t    index;
261
262  index = _Objects_Get_index( the_object->id );
263  _Objects_Set_local_object( information, index, the_object );
264
265  the_object->name = name;
266}
267
268/**
269 *  This function places the_object control pointer and object name
270 *  in the Local Pointer and Local Name Tables, respectively.
271 *
272 *  @param[in] information points to an Object Information Table
273 *  @param[in] the_object is a pointer to an object
274 *  @param[in] name is the name of the object to make accessible
275 */
276RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
277  Objects_Information *information,
278  Objects_Control     *the_object,
279  uint32_t             name
280)
281{
282  uint32_t    index;
283
284  index = _Objects_Get_index( the_object->id );
285  _Objects_Set_local_object( information, index, the_object );
286
287  /* ASSERT: information->is_string == FALSE */
288  the_object->name.name_u32 = name;
289}
290
291/**
292 *  This function places the_object control pointer and object name
293 *  in the Local Pointer and Local Name Tables, respectively.
294 *
295 *  @param[in] information points to an Object Information Table
296 *  @param[in] the_object is a pointer to an object
297 *  @param[in] name is the name of the object to make accessible
298 */
299RTEMS_INLINE_ROUTINE void _Objects_Open_string(
300  Objects_Information *information,
301  Objects_Control     *the_object,
302  const char          *name
303)
304{
305  uint32_t    index;
306
307  index = _Objects_Get_index( the_object->id );
308  _Objects_Set_local_object( information, index, the_object );
309
310  /* information->is_string */
311  the_object->name.name_p = name;
312}
313
314/**
315 *  This function removes the_object control pointer and object name
316 *  in the Local Pointer and Local Name Tables.
317 *
318 *  @param[in] information points to an Object Information Table
319 *  @param[in] the_object is a pointer to an object
320 */
321RTEMS_INLINE_ROUTINE void _Objects_Close(
322  Objects_Information  *information,
323  Objects_Control      *the_object
324)
325{
326  _Objects_Set_local_object(
327    information,
328    _Objects_Get_index( the_object->id ),
329    NULL
330  );
331
332  the_object->name.name_u32 = 0;
333  the_object->name.name_p   = NULL;
334}
335
336/**
337 *  This function removes the_object from the namespace.
338 *
339 *  @param[in] information points to an Object Information Table
340 *  @param[in] the_object is a pointer to an object
341 */
342RTEMS_INLINE_ROUTINE void _Objects_Namespace_remove(
343  Objects_Information  *information,
344  Objects_Control      *the_object
345)
346{
347  /*
348   * Clear out either format.
349   */
350  the_object->name.name_p   = NULL;
351  the_object->name.name_u32 = 0;
352}
353
354#endif
355/* end of include file */
Note: See TracBrowser for help on using the repository browser.