source: rtems/cpukit/include/rtems/score/object.h @ ae8be3f

5
Last change on this file since ae8be3f was ae8be3f, checked in by Andreas Dachsberger <andreas.dachsberger@…>, on 04/10/19 at 07:20:24

doxygen: score: adjust doc in object.h to doxygen guidelines

Update #3706.

  • Property mode set to 100644
File size: 8.7 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSScoreObject
5 *
6 * @brief Constants and Structures Associated with the Object Handler
7 *
8 * This include file contains all the constants and structures associated
9 * with the Object Handler.  This Handler provides mechanisms which
10 * can be used to initialize and manipulate all objects which have ids.
11 */
12
13/*
14 *  COPYRIGHT (c) 1989-2011.
15 *  On-Line Applications Research Corporation (OAR).
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.org/license/LICENSE.
20 */
21
22#ifndef _RTEMS_SCORE_OBJECT_H
23#define _RTEMS_SCORE_OBJECT_H
24
25#include <rtems/score/basedefs.h>
26#include <rtems/score/cpu.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**
33 * @defgroup RTEMSScore SuperCore
34 *
35 * @ingroup RTEMSInternal
36 *
37 * @brief Provides services for all APIs.
38 *
39 * @{
40 */
41
42/**
43 * @defgroup RTEMSScoreCPU CPU Architecture Support
44 *
45 * @ingroup RTEMSScore
46 *
47 * @brief Provides CPU architecture dependent services.
48 *
49 * @{
50 */
51
52/**
53 * @defgroup RTEMSScoreObject Object Handler
54 *
55 * @ingroup RTEMSScore
56 *
57 * @{
58 */
59
60/**
61 *  The following type defines the control block used to manage
62 *  object names.
63 */
64typedef union {
65  /** This is a pointer to a string name. */
66  const char *name_p;
67  /** This is the actual 32-bit "raw" integer name. */
68  uint32_t    name_u32;
69} Objects_Name;
70
71/**
72 *  The following type defines the control block used to manage
73 *  object IDs.  The format is as follows (0=LSB):
74 *
75 *     Bits  0 .. 15    = index  (up to 65535 objects of a type)
76 *     Bits 16 .. 23    = node   (up to 255 nodes)
77 *     Bits 24 .. 26    = API    (up to 7 API classes)
78 *     Bits 27 .. 31    = class  (up to 31 object types per API)
79 */
80typedef uint32_t   Objects_Id;
81
82/**
83 * This type is used to store the maximum number of allowed objects
84 * of each type.
85 */
86typedef uint16_t   Objects_Maximum;
87
88/**
89 *  This is the bit position of the starting bit of the index portion of
90 *  the object Id.
91 */
92#define OBJECTS_INDEX_START_BIT  0U
93/**
94 *  This is the bit position of the starting bit of the node portion of
95 *  the object Id.
96 */
97#define OBJECTS_NODE_START_BIT  16U
98
99/**
100 *  This is the bit position of the starting bit of the API portion of
101 *  the object Id.
102 */
103#define OBJECTS_API_START_BIT   24U
104
105/**
106 *  This is the bit position of the starting bit of the class portion of
107 *  the object Id.
108 */
109#define OBJECTS_CLASS_START_BIT 27U
110
111/**
112 *  This mask is used to extract the index portion of an object Id.
113 */
114#define OBJECTS_INDEX_MASK      (Objects_Id)0x0000ffffU
115
116/**
117 *  This mask is used to extract the node portion of an object Id.
118 */
119#define OBJECTS_NODE_MASK       (Objects_Id)0x00ff0000U
120
121/**
122 *  This mask is used to extract the API portion of an object Id.
123 */
124#define OBJECTS_API_MASK        (Objects_Id)0x07000000U
125
126/**
127 *  This mask is used to extract the class portion of an object Id.
128 */
129#define OBJECTS_CLASS_MASK      (Objects_Id)0xf8000000U
130
131/**
132 *  This mask represents the bits that is used to ensure no extra bits
133 *  are set after shifting to extract the index portion of an object Id.
134 */
135#define OBJECTS_INDEX_VALID_BITS  (Objects_Id)0x0000ffffU
136
137/**
138 *  This mask represents the bits that is used to ensure no extra bits
139 *  are set after shifting to extract the node portion of an object Id.
140 */
141#define OBJECTS_NODE_VALID_BITS   (Objects_Id)0x000000ffU
142
143/**
144 *  This mask represents the bits that is used to ensure no extra bits
145 *  are set after shifting to extract the API portion of an object Id.
146 */
147#define OBJECTS_API_VALID_BITS    (Objects_Id)0x00000007U
148
149/**
150 *  This mask represents the bits that is used to ensure no extra bits
151 *  are set after shifting to extract the class portion of an object Id.
152 */
153#define OBJECTS_CLASS_VALID_BITS  (Objects_Id)0x0000001fU
154
155/**
156 *  Mask to enable unlimited objects.  This is used in the configuration
157 *  table when specifying the number of configured objects.
158 */
159#define OBJECTS_UNLIMITED_OBJECTS 0x80000000U
160
161/**
162 *  This is the lowest value for the index portion of an object Id.
163 */
164#define OBJECTS_ID_INITIAL_INDEX  (0)
165
166/**
167 *  This is the highest value for the index portion of an object Id.
168 */
169#define OBJECTS_ID_FINAL_INDEX    (0xffffU)
170
171/**
172 *  This enumerated type is used in the class field of the object ID.
173 */
174typedef enum {
175  OBJECTS_NO_API       = 0,
176  OBJECTS_INTERNAL_API = 1,
177  OBJECTS_CLASSIC_API  = 2,
178  OBJECTS_POSIX_API    = 3,
179  OBJECTS_FAKE_OBJECTS_API = 7
180} Objects_APIs;
181
182/** This macro is used to generically specify the last API index. */
183#define OBJECTS_APIS_LAST OBJECTS_POSIX_API
184
185/**
186 *  No object can have this ID.
187 */
188#define OBJECTS_ID_NONE 0
189
190/**
191 *  The following defines the constant which may be used
192 *  to manipulate the calling task.
193 */
194#define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
195
196/**
197 *  The following constant is used to specify that a name to ID search
198 *  should search through all nodes.
199 */
200#define OBJECTS_SEARCH_ALL_NODES   0
201
202/**
203 *  The following constant is used to specify that a name to ID search
204 *  should search through all nodes except the current node.
205 */
206#define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE
207
208/**
209 *  The following constant is used to specify that a name to ID search
210 *  should search only on this node.
211 */
212#define OBJECTS_SEARCH_LOCAL_NODE  0x7FFFFFFF
213
214/**
215 *  The following constant is used to specify that a name to ID search
216 *  is being asked for the ID of the currently executing task.
217 */
218#define OBJECTS_WHO_AM_I           0
219
220/**
221 *  This macros calculates the lowest ID for the specified api, class,
222 *  and node.
223 */
224#define OBJECTS_ID_INITIAL(_api, _class, _node) \
225  _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX )
226
227/**
228 *  This macro specifies the highest object ID value
229 */
230#define OBJECTS_ID_FINAL           ((Objects_Id)~0)
231
232/**
233 *  This macro is used to build a thirty-two bit style name from
234 *  four characters.  The most significant byte will be the
235 *  character @a _C1.
236 *
237 *  @param[in] _C1 is the first character of the name
238 *  @param[in] _C2 is the second character of the name
239 *  @param[in] _C3 is the third character of the name
240 *  @param[in] _C4 is the fourth character of the name
241 */
242#define  _Objects_Build_name( _C1, _C2, _C3, _C4 ) \
243  ( (uint32_t)(_C1) << 24 | \
244    (uint32_t)(_C2) << 16 | \
245    (uint32_t)(_C3) << 8 | \
246    (uint32_t)(_C4) )
247
248/**
249 * @brief Returns the API portion of the ID.
250 *
251 * @param id The object Id to be processed.
252 *
253 * @return An object Id constructed from the arguments.
254 */
255RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API(
256  Objects_Id id
257)
258{
259  return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS);
260}
261
262/**
263 * @brief Returns the class portion of the ID.
264 *
265 * @param id The object Id to be processed.
266 *
267 * @return The class portion of the ID.
268 */
269RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class(
270  Objects_Id id
271)
272{
273  return (uint32_t)
274    ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS);
275}
276
277/**
278 * @brief Returns the node portion of the ID.
279 *
280 * @param id The object Id to be processed.
281 *
282 * @return Returns the node portion of an object ID.
283 */
284RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node(
285  Objects_Id id
286)
287{
288  return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS;
289}
290
291/**
292 * @brief Returns the index portion of the ID.
293 *
294 * @param id is the Id to be processed.
295 *
296 * @return Returns the index portion of the specified object ID.
297 */
298RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index(
299  Objects_Id id
300)
301{
302  return
303    (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) &
304                                          OBJECTS_INDEX_VALID_BITS);
305}
306
307/**
308 * @brief Builds an object ID from its components.
309 *
310 * @param the_api The object API.
311 * @param the_class The object API class.
312 * @param node The object node.
313 * @param index The object index.
314 *
315 * @return Returns the object ID constructed from the arguments.
316 */
317#define _Objects_Build_id( the_api, the_class, node, index ) \
318  ( (Objects_Id) ( (Objects_Id) the_api   << OBJECTS_API_START_BIT )   | \
319                 ( (Objects_Id) the_class << OBJECTS_CLASS_START_BIT ) | \
320                 ( (Objects_Id) node      << OBJECTS_NODE_START_BIT )  | \
321                 ( (Objects_Id) index     << OBJECTS_INDEX_START_BIT ) )
322
323/**
324 * Returns if the object maximum specifies unlimited objects.
325 *
326 * @param[in] maximum The object maximum specification.
327 *
328 * @retval true Unlimited objects are available.
329 * @retval false The object count is fixed.
330 */
331#define _Objects_Is_unlimited( maximum ) \
332  ( ( ( maximum ) & OBJECTS_UNLIMITED_OBJECTS ) != 0 )
333
334/*
335 * We cannot use an inline function for this since it may be evaluated at
336 * compile time.
337 */
338#define _Objects_Maximum_per_allocation( maximum ) \
339  ((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS))
340
341/** @} */
342/** @} */
343/** @} */
344
345#ifdef __cplusplus
346}
347#endif
348
349#endif
350/* end of include file */
Note: See TracBrowser for help on using the repository browser.