source: rtems/cpukit/include/rtems/score/object.h @ 5090a71b

5
Last change on this file since 5090a71b was 2afb22b, checked in by Chris Johns <chrisj@…>, on 12/23/17 at 07:18:56

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

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