source: rtems/cpukit/include/rtems/score/object.h @ 21275b58

Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

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