source: rtems/cpukit/score/include/rtems/score/object.h @ 993f5ac

4.115
Last change on this file since 993f5ac was b427a92, checked in by Sebastian Huber <sebastian.huber@…>, on 04/09/14 at 08:09:24

rtems: Add scheduler identification

  • Property mode set to 100644
File size: 11.6 KB
Line 
1/**
2 * @file  rtems/score/object.h
3 *
4 * @brief Constants and Structures Associated with the Object Handler
5 *
6 * This include file contains all the constants and structures associated
7 * with the Object Handler.  This Handler provides mechanisms which
8 * can be used to initialize and manipulate all objects which have ids.
9 */
10
11/*
12 *  COPYRIGHT (c) 1989-2011.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#ifndef _RTEMS_SCORE_OBJECT_H
21#define _RTEMS_SCORE_OBJECT_H
22
23#include <rtems/score/basedefs.h>
24#include <rtems/score/chain.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @defgroup Score SuperCore
32 *
33 * @brief Provides services for all APIs.
34 */
35/**@{*/
36
37#if defined(RTEMS_POSIX_API)
38  /**
39   *  This macro is defined when an API is enabled that requires the
40   *  use of strings for object names.  Since the Classic API uses
41   *  32-bit unsigned integers and not strings, this allows us to
42   *  disable this in the smallest RTEMS configuratinos.
43   */
44  #define RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES
45#endif
46
47/**
48 * @defgroup ScoreCPU CPU Architecture Support
49 *
50 * @ingroup Score
51 *
52 * @brief Provides CPU architecture dependent services.
53 */
54/**@{*/
55
56/**
57 *  @defgroup ScoreObject Object Handler
58 *
59 *  @ingroup Score
60 */
61/**@{*/
62
63/**
64 *  The following type defines the control block used to manage
65 *  object names.
66 */
67typedef union {
68  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
69    /** This is a pointer to a string name. */
70    const char *name_p;
71  #endif
72  /** This is the actual 32-bit "raw" integer name. */
73  uint32_t    name_u32;
74} Objects_Name;
75
76#if defined(RTEMS_USE_16_BIT_OBJECT)
77/**
78 *  The following type defines the control block used to manage
79 *  object IDs.  The format is as follows (0=LSB):
80 *
81 *     Bits  0 ..  7    = index  (up to 254 objects of a type)
82 *     Bits  8 .. 10    = API    (up to 7 API classes)
83 *     Bits 11 .. 15    = class  (up to 31 object types per API)
84 */
85typedef uint16_t   Objects_Id;
86
87/**
88 * This type is used to store the maximum number of allowed objects
89 * of each type.
90 */
91typedef uint8_t    Objects_Maximum;
92
93#define OBJECTS_INDEX_START_BIT  0U
94#define OBJECTS_API_START_BIT    8U
95#define OBJECTS_CLASS_START_BIT 11U
96
97#define OBJECTS_INDEX_MASK      (Objects_Id)0x00ffU
98#define OBJECTS_API_MASK        (Objects_Id)0x0700U
99#define OBJECTS_CLASS_MASK      (Objects_Id)0xF800U
100
101#define OBJECTS_INDEX_VALID_BITS  (Objects_Id)0x00ffU
102#define OBJECTS_API_VALID_BITS    (Objects_Id)0x0007U
103/* OBJECTS_NODE_VALID_BITS should not be used with 16 bit Ids */
104#define OBJECTS_CLASS_VALID_BITS  (Objects_Id)0x001fU
105
106#define OBJECTS_UNLIMITED_OBJECTS 0x8000U
107
108#define OBJECTS_ID_INITIAL_INDEX  (0)
109#define OBJECTS_ID_FINAL_INDEX    (0xff)
110
111#else
112/**
113 *  The following type defines the control block used to manage
114 *  object IDs.  The format is as follows (0=LSB):
115 *
116 *     Bits  0 .. 15    = index  (up to 65535 objects of a type)
117 *     Bits 16 .. 23    = node   (up to 255 nodes)
118 *     Bits 24 .. 26    = API    (up to 7 API classes)
119 *     Bits 27 .. 31    = class  (up to 31 object types per API)
120 */
121typedef uint32_t   Objects_Id;
122
123/**
124 * This type is used to store the maximum number of allowed objects
125 * of each type.
126 */
127typedef uint16_t   Objects_Maximum;
128
129/**
130 *  This is the bit position of the starting bit of the index portion of
131 *  the object Id.
132 */
133#define OBJECTS_INDEX_START_BIT  0U
134/**
135 *  This is the bit position of the starting bit of the node portion of
136 *  the object Id.
137 */
138#define OBJECTS_NODE_START_BIT  16U
139
140/**
141 *  This is the bit position of the starting bit of the API portion of
142 *  the object Id.
143 */
144#define OBJECTS_API_START_BIT   24U
145
146/**
147 *  This is the bit position of the starting bit of the class portion of
148 *  the object Id.
149 */
150#define OBJECTS_CLASS_START_BIT 27U
151
152/**
153 *  This mask is used to extract the index portion of an object Id.
154 */
155#define OBJECTS_INDEX_MASK      (Objects_Id)0x0000ffffU
156
157/**
158 *  This mask is used to extract the node portion of an object Id.
159 */
160#define OBJECTS_NODE_MASK       (Objects_Id)0x00ff0000U
161
162/**
163 *  This mask is used to extract the API portion of an object Id.
164 */
165#define OBJECTS_API_MASK        (Objects_Id)0x07000000U
166
167/**
168 *  This mask is used to extract the class portion of an object Id.
169 */
170#define OBJECTS_CLASS_MASK      (Objects_Id)0xf8000000U
171
172/**
173 *  This mask represents the bits that is used to ensure no extra bits
174 *  are set after shifting to extract the index portion of an object Id.
175 */
176#define OBJECTS_INDEX_VALID_BITS  (Objects_Id)0x0000ffffU
177
178/**
179 *  This mask represents the bits that is used to ensure no extra bits
180 *  are set after shifting to extract the node portion of an object Id.
181 */
182#define OBJECTS_NODE_VALID_BITS   (Objects_Id)0x000000ffU
183
184/**
185 *  This mask represents the bits that is used to ensure no extra bits
186 *  are set after shifting to extract the API portion of an object Id.
187 */
188#define OBJECTS_API_VALID_BITS    (Objects_Id)0x00000007U
189
190/**
191 *  This mask represents the bits that is used to ensure no extra bits
192 *  are set after shifting to extract the class portion of an object Id.
193 */
194#define OBJECTS_CLASS_VALID_BITS  (Objects_Id)0x0000001fU
195
196/**
197 *  Mask to enable unlimited objects.  This is used in the configuration
198 *  table when specifying the number of configured objects.
199 */
200#define OBJECTS_UNLIMITED_OBJECTS 0x80000000U
201
202/**
203 *  This is the lowest value for the index portion of an object Id.
204 */
205#define OBJECTS_ID_INITIAL_INDEX  (0)
206
207/**
208 *  This is the highest value for the index portion of an object Id.
209 */
210#define OBJECTS_ID_FINAL_INDEX    (0xffffU)
211#endif
212
213/**
214 *  This enumerated type is used in the class field of the object ID.
215 */
216typedef enum {
217  OBJECTS_NO_API       = 0,
218  OBJECTS_INTERNAL_API = 1,
219  OBJECTS_CLASSIC_API  = 2,
220  OBJECTS_POSIX_API    = 3,
221  OBJECTS_FAKE_OBJECTS_API = 7
222} Objects_APIs;
223
224/** This macro is used to generically specify the last API index. */
225#define OBJECTS_APIS_LAST OBJECTS_POSIX_API
226
227/**
228 *  The following defines the Object Control Block used to manage
229 *  each object local to this node.
230 */
231typedef struct {
232  /** This is the chain node portion of an object. */
233  Chain_Node     Node;
234  /** This is the object's ID. */
235  Objects_Id     id;
236  /** This is the object's name. */
237  Objects_Name   name;
238} Objects_Control;
239
240#if defined( RTEMS_MULTIPROCESSING )
241/**
242 *  This defines the Global Object Control Block used to manage
243 *  objects resident on other nodes.  It is derived from Object.
244 */
245typedef struct {
246  /** This is an object control structure. */
247  Objects_Control Object;
248  /** This is the name of the object.  Using an unsigned thirty two
249   *  bit value is broken but works.  If any API is MP with variable
250   *  length names .. BOOM!!!!
251   */
252  uint32_t        name;
253}   Objects_MP_Control;
254#endif
255
256/**
257 *  No object can have this ID.
258 */
259#define OBJECTS_ID_NONE 0
260
261/**
262 *  The following defines the constant which may be used
263 *  with _Objects_Get to manipulate the calling task.
264 */
265#define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
266
267/**
268 *  The following constant is used to specify that a name to ID search
269 *  should search through all nodes.
270 */
271#define OBJECTS_SEARCH_ALL_NODES   0
272
273/**
274 *  The following constant is used to specify that a name to ID search
275 *  should search through all nodes except the current node.
276 */
277#define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE
278
279/**
280 *  The following constant is used to specify that a name to ID search
281 *  should search only on this node.
282 */
283#define OBJECTS_SEARCH_LOCAL_NODE  0x7FFFFFFF
284
285/**
286 *  The following constant is used to specify that a name to ID search
287 *  is being asked for the ID of the currently executing task.
288 */
289#define OBJECTS_WHO_AM_I           0
290
291/**
292 *  This macros calculates the lowest ID for the specified api, class,
293 *  and node.
294 */
295#define OBJECTS_ID_INITIAL(_api, _class, _node) \
296  _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX )
297
298/**
299 *  This macro specifies the highest object ID value
300 */
301#define OBJECTS_ID_FINAL           ((Objects_Id)~0)
302
303/**
304 *  This macro is used to build a thirty-two bit style name from
305 *  four characters.  The most significant byte will be the
306 *  character @a _C1.
307 *
308 *  @param[in] _C1 is the first character of the name
309 *  @param[in] _C2 is the second character of the name
310 *  @param[in] _C3 is the third character of the name
311 *  @param[in] _C4 is the fourth character of the name
312 */
313#define  _Objects_Build_name( _C1, _C2, _C3, _C4 ) \
314  ( (uint32_t)(_C1) << 24 | \
315    (uint32_t)(_C2) << 16 | \
316    (uint32_t)(_C3) << 8 | \
317    (uint32_t)(_C4) )
318
319/**
320 * This function returns the API portion of the ID.
321 *
322 * @param[in] id is the object Id to be processed.
323 *
324 * @return This method returns an object Id constructed from the arguments.
325 */
326RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API(
327  Objects_Id id
328)
329{
330  return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS);
331}
332
333/**
334 * This function returns the class portion of the ID.
335 *
336 * @param[in] id is the object Id to be processed
337 */
338RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class(
339  Objects_Id id
340)
341{
342  return (uint32_t)
343    ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS);
344}
345
346/**
347 * This function returns the node portion of the ID.
348 *
349 * @param[in] id is the object Id to be processed
350 *
351 * @return This method returns the node portion of an object ID.
352 */
353RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node(
354  Objects_Id id
355)
356{
357  /*
358   * If using 16-bit Ids, then there is no node field and it MUST
359   * be a single processor system.
360   */
361  #if defined(RTEMS_USE_16_BIT_OBJECT)
362    return 1;
363  #else
364    return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS;
365  #endif
366}
367
368/**
369 * This function returns the index portion of the ID.
370 *
371 * @param[in] id is the Id to be processed
372 *
373 * @return This method returns the class portion of the specified object ID.
374 */
375RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index(
376  Objects_Id id
377)
378{
379  return
380    (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) &
381                                          OBJECTS_INDEX_VALID_BITS);
382}
383
384/**
385 * This function builds an object's id from the processor node and index
386 * values specified.
387 *
388 * @param[in] the_api indicates the API associated with this Id.
389 * @param[in] the_class indicates the class of object.
390 *            It is specific to @a the_api.
391 * @param[in] node is the node where this object resides.
392 * @param[in] index is the instance number of this object.
393 *
394 * @return This method returns an object Id constructed from the arguments.
395 */
396RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id(
397  Objects_APIs     the_api,
398  uint32_t         the_class,
399  uint32_t         node,
400  uint32_t         index
401)
402{
403  return (( (Objects_Id) the_api )   << OBJECTS_API_START_BIT)   |
404         (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) |
405         #if !defined(RTEMS_USE_16_BIT_OBJECT)
406           (( (Objects_Id) node )    << OBJECTS_NODE_START_BIT)  |
407         #endif
408         (( (Objects_Id) index )     << OBJECTS_INDEX_START_BIT);
409}
410
411/**
412 * Returns if the object maximum specifies unlimited objects.
413 *
414 * @param[in] maximum The object maximum specification.
415 *
416 * @retval true Unlimited objects are available.
417 * @retval false The object count is fixed.
418 */
419RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum )
420{
421  return (maximum & OBJECTS_UNLIMITED_OBJECTS) != 0;
422}
423
424/*
425 * We cannot use an inline function for this since it may be evaluated at
426 * compile time.
427 */
428#define _Objects_Maximum_per_allocation( maximum ) \
429  ((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS))
430
431/**@}*/
432/**@}*/
433/**@}*/
434
435#ifdef __cplusplus
436}
437#endif
438
439#endif
440/* end of include file */
Note: See TracBrowser for help on using the repository browser.