source: rtems/cpukit/score/inline/rtems/score/object.inl @ 0d15414e

4.104.115
Last change on this file since 0d15414e was 0d15414e, checked in by Chris Johns <chrisj@…>, on 08/05/09 at 00:00:54

009-08-05 Chris Johns <chrisj@…>

  • libmisc/dummy/dummy-networking.c: New.
  • libmisc/dummy/dummy.c, libmisc/Makefile.am: Move trhe networking configuration into a separate file so configuration varations do not cause conflicts.
  • score/inline/rtems/score/object.inl, score/include/rtems/score/object.h: Remove warnings.
  • score/inline/rtems/score/object.inl: Add _Chain_First, _Chain_Last, _Chain_Mext, and _Chain_Previous.
  • sapi/inline/rtems/chain.inl: Add rtems_chain_first, rtems_chain_last, rtems_chain_mext, and rtems_chain_previous.
  • libblock/include/rtems/diskdevs.h: Remove the bdbuf pool id and block_size_log2. Add media_block_size.
  • libblock/src/diskdevs.c: Remove size restrictions on block size. Add media block size initialisation. Remove comment to clean up the bdbuf cache.
  • libblock/src/blkdev.c: Remove references to block_size_log2. Allow any block size.
  • libblock/include/rtems/bdbuf.h, libblock/src/bdbuf.c: Remove all references to pools and make the cache handle demand driver variable buffer size allocation. Added worker threads support the swapout task.
  • sapi/include/confdefs.h: Updated the bdbuf configutation.
  • Property mode set to 100644
File size: 9.1 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  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 bool _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  uint32_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 sets the pointer to the local_table object
248 *  referenced by the index to a NULL so the object Id is invalid
249 *  after this call.
250 *
251 *  @param[in] information points to an Object Information Table
252 *  @param[in] the_object is the local object pointer
253 *
254 *  @note This routine is ONLY to be called in places where the
255 *        index portion of the Id is known to be good.  This is
256 *        OK since it is normally called from object create/init
257 *        or delete/destroy operations.
258 */
259
260RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(
261  Objects_Information  *information,
262  Objects_Control      *the_object
263)
264{
265  _Objects_Set_local_object(
266    information,
267    _Objects_Get_index( the_object->id ),
268    NULL
269  );
270}
271
272/**
273 *  This function places the_object control pointer and object name
274 *  in the Local Pointer and Local Name Tables, respectively.
275 *
276 *  @param[in] information points to an Object Information Table
277 *  @param[in] the_object is a pointer to an object
278 *  @param[in] name is the name of the object to make accessible
279 */
280RTEMS_INLINE_ROUTINE void _Objects_Open(
281  Objects_Information *information,
282  Objects_Control     *the_object,
283  Objects_Name         name
284)
285{
286  _Objects_Set_local_object(
287    information,
288    _Objects_Get_index( the_object->id ),
289    the_object
290  );
291
292  the_object->name = name;
293}
294
295/**
296 *  This function places the_object control pointer and object name
297 *  in the Local Pointer and Local Name Tables, respectively.
298 *
299 *  @param[in] information points to an Object Information Table
300 *  @param[in] the_object is a pointer to an object
301 *  @param[in] name is the name of the object to make accessible
302 */
303RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
304  Objects_Information *information,
305  Objects_Control     *the_object,
306  uint32_t             name
307)
308{
309  _Objects_Set_local_object(
310    information,
311    _Objects_Get_index( the_object->id ),
312    the_object
313  );
314
315  /* ASSERT: information->is_string == false */
316  the_object->name.name_u32 = name;
317}
318
319/**
320 *  This function places the_object control pointer and object name
321 *  in the Local Pointer and Local Name Tables, respectively.
322 *
323 *  @param[in] information points to an Object Information Table
324 *  @param[in] the_object is a pointer to an object
325 *  @param[in] name is the name of the object to make accessible
326 */
327RTEMS_INLINE_ROUTINE void _Objects_Open_string(
328  Objects_Information *information,
329  Objects_Control     *the_object,
330  const char          *name
331)
332{
333  _Objects_Set_local_object(
334    information,
335    _Objects_Get_index( the_object->id ),
336    the_object
337  );
338
339  /* ASSERT: information->is_string */
340  the_object->name.name_p = name;
341}
342
343#endif
344/* end of include file */
Note: See TracBrowser for help on using the repository browser.