source: rtems/cpukit/score/inline/rtems/score/object.inl @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*  object.inl
2 *
3 *  This include file contains the static inline implementation of all
4 *  of the inlined routines in the Object Handler.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#ifndef __OBJECTS_inl
17#define __OBJECTS_inl
18
19/*PAGE
20 *
21 *  _Objects_Build_id
22 *
23 *  DESCRIPTION:
24 *
25 *  This function builds an object's id from the processor node and index
26 *  values specified.
27 */
28
29RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id(
30  Objects_Classes  the_class,
31  unsigned32       node,
32  unsigned32       index
33)
34{
35  return ( (the_class << OBJECTS_CLASS_START_BIT) |
36           (node << OBJECTS_NODE_START_BIT)       |
37           (index << OBJECTS_INDEX_START_BIT) );
38}
39
40/*PAGE
41 *
42 *  _Objects_Get_class
43 *
44 *  DESCRIPTION:
45 *
46 *  This function returns the class portion of the ID.
47 */
48 
49RTEMS_INLINE_ROUTINE Objects_Classes _Objects_Get_class(
50  Objects_Id id
51)
52{
53  return (Objects_Classes)
54    ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS);
55}
56 
57
58/*PAGE
59 *
60 *  _Objects_Get_node
61 *
62 *  DESCRIPTION:
63 *
64 *  This function returns the node portion of the ID.
65 */
66
67RTEMS_INLINE_ROUTINE unsigned32 _Objects_Get_node(
68  Objects_Id id
69)
70{
71  return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS;
72}
73
74/*PAGE
75 *
76 *  _Objects_Get_index
77 *
78 *  DESCRIPTION:
79 *
80 *  This function returns the index portion of the ID.
81 */
82
83RTEMS_INLINE_ROUTINE unsigned32 _Objects_Get_index(
84  Objects_Id id
85)
86{
87  return (id >> OBJECTS_INDEX_START_BIT) & OBJECTS_INDEX_VALID_BITS;
88}
89
90/*PAGE
91 *
92 *  _Objects_Is_class_valid
93 *
94 *  DESCRIPTION:
95 *
96 *  This function returns TRUE if the class is valid.
97 */
98 
99RTEMS_INLINE_ROUTINE boolean _Objects_Is_class_valid(
100  Objects_Classes the_class
101)
102{
103  return the_class && the_class <= OBJECTS_CLASSES_LAST;
104}
105
106/*PAGE
107 *
108 *  _Objects_Is_local_node
109 *
110 *  DESCRIPTION:
111 *
112 *  This function returns TRUE if the node is of the local object, and
113 *  FALSE otherwise.
114 */
115
116RTEMS_INLINE_ROUTINE boolean _Objects_Is_local_node(
117  unsigned32 node
118)
119{
120  return ( node == _Objects_Local_node );
121}
122
123/*PAGE
124 *
125 *  _Objects_Is_local_id
126 *
127 *  DESCRIPTION:
128 *
129 *  This function returns TRUE if the id is of a local object, and
130 *  FALSE otherwise.
131 */
132
133RTEMS_INLINE_ROUTINE boolean _Objects_Is_local_id(
134  Objects_Id id
135)
136{
137  return _Objects_Is_local_node( _Objects_Get_node(id) );
138}
139
140/*PAGE
141 *
142 *  _Objects_Are_ids_equal
143 *
144 *  DESCRIPTION:
145 *
146 *  This function returns TRUE if left and right are equal,
147 *  and FALSE otherwise.
148 */
149
150RTEMS_INLINE_ROUTINE boolean _Objects_Are_ids_equal(
151  Objects_Id left,
152  Objects_Id right
153)
154{
155  return ( left == right );
156}
157
158/*PAGE
159 *
160 *  _Objects_Get_local_object
161 *
162 *  DESCRIPTION:
163 *
164 *  This function returns a pointer to the local_table object
165 *  referenced by the index.
166 */
167
168RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_local_object(
169  Objects_Information *information,
170  unsigned32           index
171)
172{
173  if ( index > information->maximum )
174    return NULL;
175  return ( information->local_table[ index ] );
176}
177
178/*PAGE
179 *
180 *  _Objects_Set_local_object
181 *
182 *  DESCRIPTION:
183 *
184 *  This function sets the pointer to the local_table object
185 *  referenced by the index.
186 */
187
188RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
189  Objects_Information *information,
190  unsigned32           index,
191  Objects_Control     *the_object
192)
193{
194  if ( index <= information->maximum )
195    information->local_table[ index ] = the_object;
196}
197
198
199/*PAGE
200 *
201 *  _Objects_Get_information
202 *
203 *  DESCRIPTION:
204 *
205 *  This function return the information structure given
206 *  an id of an object.
207 */
208 
209RTEMS_INLINE_ROUTINE Objects_Information *_Objects_Get_information(
210  Objects_Id  id
211)
212{
213  Objects_Classes  the_class;
214
215  the_class = _Objects_Get_class( id );
216
217  if ( !_Objects_Is_class_valid( the_class ) )
218    return NULL;
219
220  return _Objects_Information_table[ the_class ];
221}
222
223/*PAGE
224 *
225 *  _Objects_Open
226 *
227 *  DESCRIPTION:
228 *
229 *  This function places the_object control pointer and object name
230 *  in the Local Pointer and Local Name Tables, respectively.
231 */
232
233RTEMS_INLINE_ROUTINE void _Objects_Open(
234  Objects_Information *information,
235  Objects_Control     *the_object,
236  Objects_Name         name
237)
238{
239  unsigned32  index;
240
241  index = _Objects_Get_index( the_object->id );
242  _Objects_Set_local_object( information, index, the_object );
243
244  if ( information->is_string )
245    _Objects_Copy_name_string( name, the_object->name );
246  else
247    _Objects_Copy_name_raw( name, the_object->name, information->name_length );
248}
249
250/*PAGE
251 *
252 *  _Objects_Close
253 *
254 *  DESCRIPTION:
255 *
256 *  This function removes the_object control pointer and object name
257 *  in the Local Pointer and Local Name Tables.
258 */
259
260RTEMS_INLINE_ROUTINE void _Objects_Close(
261  Objects_Information  *information,
262  Objects_Control      *the_object
263)
264{
265  unsigned32 index;
266
267  index = _Objects_Get_index( the_object->id );
268  _Objects_Set_local_object( information, index, NULL );
269  _Objects_Clear_name( the_object->name, information->name_length );
270}
271
272#endif
273/* end of include file */
Note: See TracBrowser for help on using the repository browser.