1 | /** |
---|
2 | * @file rtems/score/object.h |
---|
3 | * |
---|
4 | * |
---|
5 | * This include file contains all the constants and structures associated |
---|
6 | * with the Object Handler. This Handler provides mechanisms which |
---|
7 | * can be used to initialize and manipulate all objects which have |
---|
8 | * ids. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * COPYRIGHT (c) 1989-2008. |
---|
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.com/license/LICENSE. |
---|
18 | * |
---|
19 | * $Id$ |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef _RTEMS_SCORE_OBJECT_H |
---|
23 | #define _RTEMS_SCORE_OBJECT_H |
---|
24 | |
---|
25 | #include <rtems/score/chain.h> |
---|
26 | #include <rtems/score/isr.h> |
---|
27 | |
---|
28 | #if defined(RTEMS_POSIX_API) |
---|
29 | #define RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES |
---|
30 | #endif |
---|
31 | |
---|
32 | #ifdef __cplusplus |
---|
33 | extern "C" { |
---|
34 | #endif |
---|
35 | |
---|
36 | /** |
---|
37 | * @defgroup Score SuperCore |
---|
38 | * |
---|
39 | * @brief Provides services for all APIs. |
---|
40 | */ |
---|
41 | |
---|
42 | /** |
---|
43 | * @defgroup ScoreCPU CPU Architecture Support |
---|
44 | * |
---|
45 | * @ingroup Score |
---|
46 | * |
---|
47 | * @brief Provides CPU architecture dependent services. |
---|
48 | */ |
---|
49 | |
---|
50 | /** |
---|
51 | * The following type defines the control block used to manage |
---|
52 | * object names. |
---|
53 | */ |
---|
54 | typedef union { |
---|
55 | #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) |
---|
56 | /** This is a pointer to a string name. */ |
---|
57 | const char *name_p; |
---|
58 | #endif |
---|
59 | /** This is the actual 32-bit "raw" integer name. */ |
---|
60 | uint32_t name_u32; |
---|
61 | } Objects_Name; |
---|
62 | |
---|
63 | /** |
---|
64 | * Space for object names is allocated in multiples of this. |
---|
65 | * |
---|
66 | * NOTE: Must be a power of 2. Matches the name manipulation routines. |
---|
67 | */ |
---|
68 | #define OBJECTS_NAME_ALIGNMENT sizeof( uint32_t ) |
---|
69 | |
---|
70 | /** |
---|
71 | * Functions which compare names are prototyped like this. |
---|
72 | */ |
---|
73 | typedef bool (*Objects_Name_comparators)( |
---|
74 | void * /* name_1 */, |
---|
75 | void * /* name_2 */, |
---|
76 | uint16_t /* length */ |
---|
77 | ); |
---|
78 | |
---|
79 | #if defined(RTEMS_USE_16_BIT_OBJECT) |
---|
80 | /** |
---|
81 | * The following type defines the control block used to manage |
---|
82 | * object IDs. The format is as follows (0=LSB): |
---|
83 | * |
---|
84 | * Bits 0 .. 7 = index (up to 254 objects of a type) |
---|
85 | * Bits 8 .. 10 = API (up to 7 API classes) |
---|
86 | * Bits 11 .. 15 = class (up to 31 object types per API) |
---|
87 | */ |
---|
88 | typedef uint16_t Objects_Id; |
---|
89 | |
---|
90 | /** |
---|
91 | * This type is used to store the maximum number of allowed objects |
---|
92 | * of each type. |
---|
93 | */ |
---|
94 | typedef uint8_t Objects_Maximum; |
---|
95 | |
---|
96 | #define OBJECTS_INDEX_START_BIT 0U |
---|
97 | #define OBJECTS_API_START_BIT 8U |
---|
98 | #define OBJECTS_CLASS_START_BIT 11U |
---|
99 | |
---|
100 | #define OBJECTS_INDEX_MASK (Objects_Id)0x00ffU |
---|
101 | #define OBJECTS_API_MASK (Objects_Id)0x0700U |
---|
102 | #define OBJECTS_CLASS_MASK (Objects_Id)0xF800U |
---|
103 | |
---|
104 | #define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x00ffU |
---|
105 | #define OBJECTS_API_VALID_BITS (Objects_Id)0x0007U |
---|
106 | /* OBJECTS_NODE_VALID_BITS should not be used with 16 bit Ids */ |
---|
107 | #define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x001fU |
---|
108 | |
---|
109 | #define OBJECTS_UNLIMITED_OBJECTS 0x8000U |
---|
110 | |
---|
111 | #define OBJECTS_ID_INITIAL_INDEX (0) |
---|
112 | #define OBJECTS_ID_FINAL_INDEX (0xff) |
---|
113 | |
---|
114 | #else |
---|
115 | /** |
---|
116 | * The following type defines the control block used to manage |
---|
117 | * object IDs. The format is as follows (0=LSB): |
---|
118 | * |
---|
119 | * Bits 0 .. 15 = index (up to 65535 objects of a type) |
---|
120 | * Bits 16 .. 23 = node (up to 255 nodes) |
---|
121 | * Bits 24 .. 26 = API (up to 7 API classes) |
---|
122 | * Bits 27 .. 31 = class (up to 31 object types per API) |
---|
123 | */ |
---|
124 | typedef uint32_t Objects_Id; |
---|
125 | |
---|
126 | /** |
---|
127 | * This type is used to store the maximum number of allowed objects |
---|
128 | * of each type. |
---|
129 | */ |
---|
130 | typedef uint16_t Objects_Maximum; |
---|
131 | |
---|
132 | /** |
---|
133 | * This is the bit position of the starting bit of the index portion of |
---|
134 | * the object Id. |
---|
135 | */ |
---|
136 | #define OBJECTS_INDEX_START_BIT 0U |
---|
137 | |
---|
138 | |
---|
139 | /** |
---|
140 | * This is the bit position of the starting bit of the node portion of |
---|
141 | * the object Id. |
---|
142 | */ |
---|
143 | #define OBJECTS_NODE_START_BIT 16U |
---|
144 | |
---|
145 | /** |
---|
146 | * This is the bit position of the starting bit of the API portion of |
---|
147 | * the object Id. |
---|
148 | */ |
---|
149 | #define OBJECTS_API_START_BIT 24U |
---|
150 | |
---|
151 | /** |
---|
152 | * This is the bit position of the starting bit of the class portion of |
---|
153 | * the object Id. |
---|
154 | */ |
---|
155 | #define OBJECTS_CLASS_START_BIT 27U |
---|
156 | |
---|
157 | /** |
---|
158 | * This mask is used to extract the index portion of an object Id. |
---|
159 | */ |
---|
160 | #define OBJECTS_INDEX_MASK (Objects_Id)0x0000ffffU |
---|
161 | |
---|
162 | /** |
---|
163 | * This mask is used to extract the node portion of an object Id. |
---|
164 | */ |
---|
165 | #define OBJECTS_NODE_MASK (Objects_Id)0x00ff0000U |
---|
166 | |
---|
167 | /** |
---|
168 | * This mask is used to extract the API portion of an object Id. |
---|
169 | */ |
---|
170 | #define OBJECTS_API_MASK (Objects_Id)0x07000000U |
---|
171 | |
---|
172 | /** |
---|
173 | * This mask is used to extract the class portion of an object Id. |
---|
174 | */ |
---|
175 | #define OBJECTS_CLASS_MASK (Objects_Id)0xf8000000U |
---|
176 | |
---|
177 | /** |
---|
178 | * This mask represents the bits that is used to ensure no extra bits |
---|
179 | * are set after shifting to extract the index portion of an object Id. |
---|
180 | */ |
---|
181 | #define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x0000ffffU |
---|
182 | |
---|
183 | /** |
---|
184 | * This mask represents the bits that is used to ensure no extra bits |
---|
185 | * are set after shifting to extract the node portion of an object Id. |
---|
186 | */ |
---|
187 | #define OBJECTS_NODE_VALID_BITS (Objects_Id)0x000000ffU |
---|
188 | |
---|
189 | /** |
---|
190 | * This mask represents the bits that is used to ensure no extra bits |
---|
191 | * are set after shifting to extract the API portion of an object Id. |
---|
192 | */ |
---|
193 | #define OBJECTS_API_VALID_BITS (Objects_Id)0x00000007U |
---|
194 | |
---|
195 | /** |
---|
196 | * This mask represents the bits that is used to ensure no extra bits |
---|
197 | * are set after shifting to extract the class portion of an object Id. |
---|
198 | */ |
---|
199 | #define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x0000001fU |
---|
200 | |
---|
201 | /** |
---|
202 | * Mask to enable unlimited objects. This is used in the configuration |
---|
203 | * table when specifying the number of configured objects. |
---|
204 | */ |
---|
205 | #define OBJECTS_UNLIMITED_OBJECTS 0x80000000U |
---|
206 | |
---|
207 | /** |
---|
208 | * This is the lowest value for the index portion of an object Id. |
---|
209 | */ |
---|
210 | #define OBJECTS_ID_INITIAL_INDEX (0) |
---|
211 | |
---|
212 | /** |
---|
213 | * This is the highest value for the index portion of an object Id. |
---|
214 | */ |
---|
215 | #define OBJECTS_ID_FINAL_INDEX (0xffffU) |
---|
216 | #endif |
---|
217 | |
---|
218 | /** |
---|
219 | * This enumerated type is used in the class field of the object ID. |
---|
220 | */ |
---|
221 | typedef enum { |
---|
222 | OBJECTS_NO_API = 0, |
---|
223 | OBJECTS_INTERNAL_API = 1, |
---|
224 | OBJECTS_CLASSIC_API = 2, |
---|
225 | OBJECTS_POSIX_API = 3 |
---|
226 | } Objects_APIs; |
---|
227 | |
---|
228 | /** This macro is used to generically specify the last API index. */ |
---|
229 | #define OBJECTS_APIS_LAST OBJECTS_POSIX_API |
---|
230 | |
---|
231 | /** |
---|
232 | * This enumerated type is used in the class field of the object ID |
---|
233 | * for RTEMS internal object classes. |
---|
234 | */ |
---|
235 | typedef enum { |
---|
236 | OBJECTS_INTERNAL_NO_CLASS = 0, |
---|
237 | OBJECTS_INTERNAL_THREADS = 1, |
---|
238 | OBJECTS_INTERNAL_MUTEXES = 2 |
---|
239 | } Objects_Internal_API; |
---|
240 | |
---|
241 | /** This macro is used to generically specify the last API index. */ |
---|
242 | #define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_MUTEXES |
---|
243 | |
---|
244 | /** |
---|
245 | * This enumerated type is used in the class field of the object ID |
---|
246 | * for the RTEMS Classic API. |
---|
247 | */ |
---|
248 | typedef enum { |
---|
249 | OBJECTS_CLASSIC_NO_CLASS = 0, |
---|
250 | OBJECTS_RTEMS_TASKS = 1, |
---|
251 | OBJECTS_RTEMS_TIMERS = 2, |
---|
252 | OBJECTS_RTEMS_SEMAPHORES = 3, |
---|
253 | OBJECTS_RTEMS_MESSAGE_QUEUES = 4, |
---|
254 | OBJECTS_RTEMS_PARTITIONS = 5, |
---|
255 | OBJECTS_RTEMS_REGIONS = 6, |
---|
256 | OBJECTS_RTEMS_PORTS = 7, |
---|
257 | OBJECTS_RTEMS_PERIODS = 8, |
---|
258 | OBJECTS_RTEMS_EXTENSIONS = 9, |
---|
259 | OBJECTS_RTEMS_BARRIERS = 10 |
---|
260 | } Objects_Classic_API; |
---|
261 | |
---|
262 | /** This macro is used to generically specify the last API index. */ |
---|
263 | #define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS |
---|
264 | |
---|
265 | /** |
---|
266 | * This enumerated type is used in the class field of the object ID |
---|
267 | * for the POSIX API. |
---|
268 | */ |
---|
269 | typedef enum { |
---|
270 | OBJECTS_POSIX_NO_CLASS = 0, |
---|
271 | OBJECTS_POSIX_THREADS = 1, |
---|
272 | OBJECTS_POSIX_KEYS = 2, |
---|
273 | OBJECTS_POSIX_INTERRUPTS = 3, |
---|
274 | OBJECTS_POSIX_MESSAGE_QUEUE_FDS = 4, |
---|
275 | OBJECTS_POSIX_MESSAGE_QUEUES = 5, |
---|
276 | OBJECTS_POSIX_MUTEXES = 6, |
---|
277 | OBJECTS_POSIX_SEMAPHORES = 7, |
---|
278 | OBJECTS_POSIX_CONDITION_VARIABLES = 8, |
---|
279 | OBJECTS_POSIX_TIMERS = 9, |
---|
280 | OBJECTS_POSIX_BARRIERS = 10, |
---|
281 | OBJECTS_POSIX_SPINLOCKS = 11, |
---|
282 | OBJECTS_POSIX_RWLOCKS = 12 |
---|
283 | } Objects_POSIX_API; |
---|
284 | |
---|
285 | /** This macro is used to generically specify the last API index. */ |
---|
286 | #define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_RWLOCKS |
---|
287 | |
---|
288 | /** |
---|
289 | * This enumerated type lists the locations which may be returned |
---|
290 | * by _Objects_Get. These codes indicate the success of locating |
---|
291 | * an object with the specified ID. |
---|
292 | */ |
---|
293 | typedef enum { |
---|
294 | #if defined(RTEMS_MULTIPROCESSING) |
---|
295 | OBJECTS_REMOTE = 2, /* object is remote */ |
---|
296 | #endif |
---|
297 | OBJECTS_LOCAL = 0, /* object is local */ |
---|
298 | OBJECTS_ERROR = 1 /* id was invalid */ |
---|
299 | } Objects_Locations; |
---|
300 | |
---|
301 | /** |
---|
302 | * The following type defines the callout used when a local task |
---|
303 | * is extracted from a remote thread queue (i.e. it's proxy must |
---|
304 | * extracted from the remote queue). |
---|
305 | */ |
---|
306 | typedef void ( *Objects_Thread_queue_Extract_callout )( void * ); |
---|
307 | |
---|
308 | /** |
---|
309 | * The following defines the Object Control Block used to manage |
---|
310 | * each object local to this node. |
---|
311 | */ |
---|
312 | typedef struct { |
---|
313 | /** This is the chain node portion of an object. */ |
---|
314 | Chain_Node Node; |
---|
315 | /** This is the object's ID. */ |
---|
316 | Objects_Id id; |
---|
317 | /** This is the object's name. */ |
---|
318 | Objects_Name name; |
---|
319 | } Objects_Control; |
---|
320 | |
---|
321 | /** |
---|
322 | * The following defines the structure for the information used to |
---|
323 | * manage each class of objects. |
---|
324 | */ |
---|
325 | typedef struct { |
---|
326 | /** This field indicates the API of this object class. */ |
---|
327 | Objects_APIs the_api; |
---|
328 | /** This is the class of this object set. */ |
---|
329 | uint16_t the_class; |
---|
330 | /** This is the minimum valid id of this object class. */ |
---|
331 | Objects_Id minimum_id; |
---|
332 | /** This is the maximum valid id of this object class. */ |
---|
333 | Objects_Id maximum_id; |
---|
334 | /** This is the maximum number of objects in this class. */ |
---|
335 | Objects_Maximum maximum; |
---|
336 | /** This is the true if unlimited objects in this class. */ |
---|
337 | bool auto_extend; |
---|
338 | /** This is the number of objects in a block. */ |
---|
339 | Objects_Maximum allocation_size; |
---|
340 | /** This is the size in bytes of each object instance. */ |
---|
341 | size_t size; |
---|
342 | /** This points to the table of local objects. */ |
---|
343 | Objects_Control **local_table; |
---|
344 | /** This is the chain of inactive control blocks. */ |
---|
345 | Chain_Control Inactive; |
---|
346 | /** This is the number of objects on the Inactive list. */ |
---|
347 | Objects_Maximum inactive; |
---|
348 | /** This is the number of inactive objects per block. */ |
---|
349 | uint32_t *inactive_per_block; |
---|
350 | /** This is a table to the chain of inactive object memory blocks. */ |
---|
351 | void **object_blocks; |
---|
352 | #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) |
---|
353 | /** This is true if names are strings. */ |
---|
354 | bool is_string; |
---|
355 | #endif |
---|
356 | /** This is the maximum length of names. */ |
---|
357 | uint16_t name_length; |
---|
358 | /** This is this object class' method called when extracting a thread. */ |
---|
359 | Objects_Thread_queue_Extract_callout extract; |
---|
360 | #if defined(RTEMS_MULTIPROCESSING) |
---|
361 | /** This is this object class' pointer to the global name table */ |
---|
362 | Chain_Control *global_table; |
---|
363 | #endif |
---|
364 | } Objects_Information; |
---|
365 | |
---|
366 | /** |
---|
367 | * The following is referenced to the node number of the local node. |
---|
368 | */ |
---|
369 | #if defined(RTEMS_MULTIPROCESSING) |
---|
370 | SCORE_EXTERN uint16_t _Objects_Local_node; |
---|
371 | #else |
---|
372 | #define _Objects_Local_node ((uint16_t)1) |
---|
373 | #endif |
---|
374 | |
---|
375 | /** |
---|
376 | * The following is referenced to the number of nodes in the system. |
---|
377 | */ |
---|
378 | #if defined(RTEMS_MULTIPROCESSING) |
---|
379 | SCORE_EXTERN uint16_t _Objects_Maximum_nodes; |
---|
380 | #else |
---|
381 | #define _Objects_Maximum_nodes 1 |
---|
382 | #endif |
---|
383 | |
---|
384 | /** |
---|
385 | * The following is the list of information blocks per API for each object |
---|
386 | * class. From the ID, we can go to one of these information blocks, |
---|
387 | * and obtain a pointer to the appropriate object control block. |
---|
388 | */ |
---|
389 | SCORE_EXTERN Objects_Information |
---|
390 | **_Objects_Information_table[OBJECTS_APIS_LAST + 1]; |
---|
391 | |
---|
392 | /** |
---|
393 | * No object can have this ID. |
---|
394 | */ |
---|
395 | #define OBJECTS_ID_NONE 0 |
---|
396 | |
---|
397 | /** |
---|
398 | * The following defines the constant which may be used |
---|
399 | * with _Objects_Get to manipulate the calling task. |
---|
400 | */ |
---|
401 | #define OBJECTS_ID_OF_SELF ((Objects_Id) 0) |
---|
402 | |
---|
403 | /** |
---|
404 | * The following constant is used to specify that a name to ID search |
---|
405 | * should search through all nodes. |
---|
406 | */ |
---|
407 | #define OBJECTS_SEARCH_ALL_NODES 0 |
---|
408 | |
---|
409 | /** |
---|
410 | * The following constant is used to specify that a name to ID search |
---|
411 | * should search through all nodes except the current node. |
---|
412 | */ |
---|
413 | #define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE |
---|
414 | |
---|
415 | /** |
---|
416 | * The following constant is used to specify that a name to ID search |
---|
417 | * should search only on this node. |
---|
418 | */ |
---|
419 | #define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF |
---|
420 | |
---|
421 | /** |
---|
422 | * The following constant is used to specify that a name to ID search |
---|
423 | * is being asked for the ID of the currently executing task. |
---|
424 | */ |
---|
425 | #define OBJECTS_WHO_AM_I 0 |
---|
426 | |
---|
427 | /** |
---|
428 | * This macros calculates the lowest ID for the specified api, class, |
---|
429 | * and node. |
---|
430 | */ |
---|
431 | #define OBJECTS_ID_INITIAL(_api, _class, _node) \ |
---|
432 | _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX ) |
---|
433 | |
---|
434 | /** |
---|
435 | * This macro specifies the highest object ID value |
---|
436 | */ |
---|
437 | #define OBJECTS_ID_FINAL ((Objects_Id)~0) |
---|
438 | |
---|
439 | /** |
---|
440 | * This function extends an object class information record. |
---|
441 | * |
---|
442 | * @param[in] information points to an object class information block. |
---|
443 | */ |
---|
444 | void _Objects_Extend_information( |
---|
445 | Objects_Information *information |
---|
446 | ); |
---|
447 | |
---|
448 | /** |
---|
449 | * This function shrink an object class information record. |
---|
450 | * |
---|
451 | * @param[in] information points to an object class information block. |
---|
452 | */ |
---|
453 | void _Objects_Shrink_information( |
---|
454 | Objects_Information *information |
---|
455 | ); |
---|
456 | |
---|
457 | /** |
---|
458 | * This function initializes an object class information record. |
---|
459 | * SUPPORTS_GLOBAL is true if the object class supports global |
---|
460 | * objects, and false otherwise. Maximum indicates the number |
---|
461 | * of objects required in this class and size indicates the size |
---|
462 | * in bytes of each control block for this object class. The |
---|
463 | * name length and string designator are also set. In addition, |
---|
464 | * the class may be a task, therefore this information is also included. |
---|
465 | * |
---|
466 | * @param[in] information points to an object class information block. |
---|
467 | * @param[in] the_api indicates the API associated with this information block. |
---|
468 | * @param[in] the_class indicates the class of object being managed |
---|
469 | * by this information block. It is specific to @a the_api. |
---|
470 | * @param[in] maximum is the maximum number of instances of this object |
---|
471 | * class which may be concurrently active. |
---|
472 | * @param[in] size is the size of the data structure for this class. |
---|
473 | * @param[in] is_string is true if this object uses string style names. |
---|
474 | * @param[in] maximum_name_length is the maximum length of object names. |
---|
475 | */ |
---|
476 | void _Objects_Initialize_information ( |
---|
477 | Objects_Information *information, |
---|
478 | Objects_APIs the_api, |
---|
479 | uint16_t the_class, |
---|
480 | uint32_t maximum, |
---|
481 | uint16_t size, |
---|
482 | bool is_string, |
---|
483 | uint32_t maximum_name_length |
---|
484 | #if defined(RTEMS_MULTIPROCESSING) |
---|
485 | , |
---|
486 | bool supports_global, |
---|
487 | Objects_Thread_queue_Extract_callout extract |
---|
488 | #endif |
---|
489 | ); |
---|
490 | |
---|
491 | /** |
---|
492 | * This function returns the highest numeric value of a valid |
---|
493 | * API for the specified @a api. |
---|
494 | * |
---|
495 | * @param[in] api is the API of interest |
---|
496 | * |
---|
497 | * @return A positive integer on success and 0 otherwise. |
---|
498 | */ |
---|
499 | unsigned int _Objects_API_maximum_class( |
---|
500 | uint32_t api |
---|
501 | ); |
---|
502 | |
---|
503 | /** |
---|
504 | * This function allocates a object control block from |
---|
505 | * the inactive chain of free object control blocks. |
---|
506 | * |
---|
507 | * @param[in] information points to an object class information block. |
---|
508 | */ |
---|
509 | Objects_Control *_Objects_Allocate( |
---|
510 | Objects_Information *information |
---|
511 | ); |
---|
512 | |
---|
513 | /** |
---|
514 | * |
---|
515 | * This function frees a object control block to the |
---|
516 | * inactive chain of free object control blocks. |
---|
517 | * |
---|
518 | * @param[in] information points to an object class information block. |
---|
519 | * @param[in] the_object points to the object to deallocate. |
---|
520 | */ |
---|
521 | void _Objects_Free( |
---|
522 | Objects_Information *information, |
---|
523 | Objects_Control *the_object |
---|
524 | ); |
---|
525 | |
---|
526 | /** |
---|
527 | * This macro is used to build a thirty-two bit style name from |
---|
528 | * four characters. The most significant byte will be the |
---|
529 | * character @a _C1. |
---|
530 | * |
---|
531 | * @param[in] _C1 is the first character of the name |
---|
532 | * @param[in] _C2 is the second character of the name |
---|
533 | * @param[in] _C3 is the third character of the name |
---|
534 | * @param[in] _C4 is the fourth character of the name |
---|
535 | */ |
---|
536 | #define _Objects_Build_name( _C1, _C2, _C3, _C4 ) \ |
---|
537 | ( (uint32_t)(_C1) << 24 | \ |
---|
538 | (uint32_t)(_C2) << 16 | \ |
---|
539 | (uint32_t)(_C3) << 8 | \ |
---|
540 | (uint32_t)(_C4) ) |
---|
541 | |
---|
542 | /** |
---|
543 | * This function implements the common portion of the object |
---|
544 | * identification directives. This directive returns the object |
---|
545 | * id associated with name. If more than one object of this class |
---|
546 | * is named name, then the object to which the id belongs is |
---|
547 | * arbitrary. Node indicates the extent of the search for the |
---|
548 | * id of the object named name. If the object class supports global |
---|
549 | * objects, then the search can be limited to a particular node |
---|
550 | * or allowed to encompass all nodes. |
---|
551 | */ |
---|
552 | typedef enum { |
---|
553 | OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL, |
---|
554 | OBJECTS_INVALID_NAME, |
---|
555 | OBJECTS_INVALID_ADDRESS, |
---|
556 | OBJECTS_INVALID_ID, |
---|
557 | OBJECTS_INVALID_NODE |
---|
558 | } Objects_Name_or_id_lookup_errors; |
---|
559 | |
---|
560 | /** |
---|
561 | * This macro defines the first entry in the |
---|
562 | * @ref Objects_Name_or_id_lookup_errors enumerated list. |
---|
563 | */ |
---|
564 | #define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL |
---|
565 | |
---|
566 | /** |
---|
567 | * This macro defines the last entry in the |
---|
568 | * @ref Objects_Name_or_id_lookup_errors enumerated list. |
---|
569 | */ |
---|
570 | #define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE |
---|
571 | |
---|
572 | /** |
---|
573 | * This method converts an object name to an Id. It performs a look up |
---|
574 | * using the object information block for this object class. |
---|
575 | * |
---|
576 | * @param[in] information points to an object class information block. |
---|
577 | * @param[in] name is the name of the object to find. |
---|
578 | * @param[in] node is the set of nodes to search. |
---|
579 | * @param[in] id will contain the Id if the search is successful. |
---|
580 | * |
---|
581 | * @return This method returns one of the values from the |
---|
582 | * @ref Objects_Name_or_id_lookup_errors enumeration to indicate |
---|
583 | * successful or failure. On success @a id will contain the Id of |
---|
584 | * the requested object. |
---|
585 | */ |
---|
586 | Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( |
---|
587 | Objects_Information *information, |
---|
588 | uint32_t name, |
---|
589 | uint32_t node, |
---|
590 | Objects_Id *id |
---|
591 | ); |
---|
592 | |
---|
593 | #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) |
---|
594 | /** |
---|
595 | * This method converts an object name to an Id. It performs a look up |
---|
596 | * using the object information block for this object class. |
---|
597 | * |
---|
598 | * @param[in] information points to an object class information block. |
---|
599 | * @param[in] name is the name of the object to find. |
---|
600 | * @param[in] id will contain the Id if the search is successful. |
---|
601 | * |
---|
602 | * @return This method returns one of the values from the |
---|
603 | * @ref Objects_Name_or_id_lookup_errors enumeration to indicate |
---|
604 | * successful or failure. On success @a id will contain the Id of |
---|
605 | * the requested object. |
---|
606 | */ |
---|
607 | Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string( |
---|
608 | Objects_Information *information, |
---|
609 | const char *name, |
---|
610 | Objects_Id *id |
---|
611 | ); |
---|
612 | #endif |
---|
613 | |
---|
614 | /** |
---|
615 | * This function implements the common portion of the object Id |
---|
616 | * to name directives. This function returns the name |
---|
617 | * associated with object id. |
---|
618 | * |
---|
619 | * @param[in] id is the Id of the object whose name we are locating. |
---|
620 | * @param[in] name will contain the name of the object, if found. |
---|
621 | * |
---|
622 | * @return This method returns one of the values from the |
---|
623 | * @ref Objects_Name_or_id_lookup_errors enumeration to indicate |
---|
624 | * successful or failure. On success @a name will contain the name of |
---|
625 | * the requested object. |
---|
626 | * |
---|
627 | * @note This function currently does not support string names. |
---|
628 | */ |
---|
629 | Objects_Name_or_id_lookup_errors _Objects_Id_to_name ( |
---|
630 | Objects_Id id, |
---|
631 | Objects_Name *name |
---|
632 | ); |
---|
633 | |
---|
634 | /** |
---|
635 | * This function maps object ids to object control blocks. |
---|
636 | * If id corresponds to a local object, then it returns |
---|
637 | * the_object control pointer which maps to id and location |
---|
638 | * is set to OBJECTS_LOCAL. If the object class supports global |
---|
639 | * objects and the object id is global and resides on a remote |
---|
640 | * node, then location is set to OBJECTS_REMOTE, and the_object |
---|
641 | * is undefined. Otherwise, location is set to OBJECTS_ERROR |
---|
642 | * and the_object is undefined. |
---|
643 | * |
---|
644 | * @param[in] information points to an object class information block. |
---|
645 | * @param[in] id is the Id of the object whose name we are locating. |
---|
646 | * @param[in] location will contain an indication of success or failure. |
---|
647 | * |
---|
648 | * @return This method returns one of the values from the |
---|
649 | * @ref Objects_Name_or_id_lookup_errors enumeration to indicate |
---|
650 | * successful or failure. On success @a id will contain the Id of |
---|
651 | * the requested object. |
---|
652 | * |
---|
653 | * @note _Objects_Get returns with dispatching disabled for |
---|
654 | * local and remote objects. _Objects_Get_isr_disable returns with |
---|
655 | * dispatching disabled for remote objects and interrupts for local |
---|
656 | * objects. |
---|
657 | */ |
---|
658 | Objects_Control *_Objects_Get ( |
---|
659 | Objects_Information *information, |
---|
660 | Objects_Id id, |
---|
661 | Objects_Locations *location |
---|
662 | ); |
---|
663 | |
---|
664 | /** |
---|
665 | * This function maps object ids to object control blocks. |
---|
666 | * If id corresponds to a local object, then it returns |
---|
667 | * the_object control pointer which maps to id and location |
---|
668 | * is set to OBJECTS_LOCAL. If the object class supports global |
---|
669 | * objects and the object id is global and resides on a remote |
---|
670 | * node, then location is set to OBJECTS_REMOTE, and the_object |
---|
671 | * is undefined. Otherwise, location is set to OBJECTS_ERROR |
---|
672 | * and the_object is undefined. |
---|
673 | * |
---|
674 | * @param[in] information points to an object class information block. |
---|
675 | * @param[in] id is the Id of the object whose name we are locating. |
---|
676 | * @param[in] location will contain an indication of success or failure. |
---|
677 | * @param[in] level is the interrupt level being turned. |
---|
678 | * |
---|
679 | * @return This method returns one of the values from the |
---|
680 | * @ref Objects_Name_or_id_lookup_errors enumeration to indicate |
---|
681 | * successful or failure. On success @a name will contain the name of |
---|
682 | * the requested object. |
---|
683 | * |
---|
684 | * @note _Objects_Get returns with dispatching disabled for |
---|
685 | * local and remote objects. _Objects_Get_isr_disable returns with |
---|
686 | * dispatchng disabled for remote objects and interrupts for local |
---|
687 | * objects. |
---|
688 | */ |
---|
689 | Objects_Control *_Objects_Get_isr_disable( |
---|
690 | Objects_Information *information, |
---|
691 | Objects_Id id, |
---|
692 | Objects_Locations *location, |
---|
693 | ISR_Level *level |
---|
694 | ); |
---|
695 | |
---|
696 | /** |
---|
697 | * This function maps object ids to object control blocks. |
---|
698 | * If id corresponds to a local object, then it returns |
---|
699 | * the_object control pointer which maps to id and location |
---|
700 | * is set to OBJECTS_LOCAL. If the object class supports global |
---|
701 | * objects and the object id is global and resides on a remote |
---|
702 | * node, then location is set to OBJECTS_REMOTE, and the_object |
---|
703 | * is undefined. Otherwise, location is set to OBJECTS_ERROR |
---|
704 | * and the_object is undefined. |
---|
705 | * |
---|
706 | * @param[in] information points to an object class information block. |
---|
707 | * @param[in] id is the Id of the object whose name we are locating. |
---|
708 | * @param[in] location will contain an indication of success or failure. |
---|
709 | * |
---|
710 | * @return This method returns one of the values from the |
---|
711 | * @ref Objects_Name_or_id_lookup_errors enumeration to indicate |
---|
712 | * successful or failure. On success @a id will contain the Id of |
---|
713 | * the requested object. |
---|
714 | * |
---|
715 | * @note _Objects_Get returns with dispatching disabled for |
---|
716 | * local and remote objects. _Objects_Get_isr_disable returns with |
---|
717 | * dispatching disabled for remote objects and interrupts for local |
---|
718 | * objects. |
---|
719 | */ |
---|
720 | Objects_Control *_Objects_Get_no_protection( |
---|
721 | Objects_Information *information, |
---|
722 | Objects_Id id, |
---|
723 | Objects_Locations *location |
---|
724 | ); |
---|
725 | |
---|
726 | /** |
---|
727 | * Like @ref _Objects_Get, but is used to find "next" open object. |
---|
728 | * |
---|
729 | * @param[in] information points to an object class information block. |
---|
730 | * @param[in] id is the Id of the object whose name we are locating. |
---|
731 | * @param[in] location_p will contain an indication of success or failure. |
---|
732 | * @param[in] next_id_p is the Id of the next object we will look at. |
---|
733 | * |
---|
734 | * @return This method returns the pointer to the object located or |
---|
735 | * NULL on error. |
---|
736 | */ |
---|
737 | Objects_Control *_Objects_Get_next( |
---|
738 | Objects_Information *information, |
---|
739 | Objects_Id id, |
---|
740 | Objects_Locations *location_p, |
---|
741 | Objects_Id *next_id_p |
---|
742 | ); |
---|
743 | |
---|
744 | /** |
---|
745 | * This function return the information structure given |
---|
746 | * an the API and Class. This can be done independent of |
---|
747 | * the existence of any objects created by the API. |
---|
748 | * |
---|
749 | * @param[in] the_api indicates the API for the information we want |
---|
750 | * @param[in] the_class indicates the Class for the information we want |
---|
751 | * |
---|
752 | * @return This method returns a pointer to the Object Information Table |
---|
753 | * for the class of objects which corresponds to this object ID. |
---|
754 | */ |
---|
755 | Objects_Information *_Objects_Get_information( |
---|
756 | Objects_APIs the_api, |
---|
757 | uint16_t the_class |
---|
758 | ); |
---|
759 | |
---|
760 | /** |
---|
761 | * This function return the information structure given |
---|
762 | * an id of an object. |
---|
763 | * |
---|
764 | * @param[in] id is an object ID |
---|
765 | * |
---|
766 | * @return This method returns a pointer to the Object Information Table |
---|
767 | * for the class of objects which corresponds to this object ID. |
---|
768 | */ |
---|
769 | Objects_Information *_Objects_Get_information_id( |
---|
770 | Objects_Id id |
---|
771 | ); |
---|
772 | |
---|
773 | /** |
---|
774 | * This method objects the name of an object and returns its name |
---|
775 | * in the form of a C string. It attempts to be careful about |
---|
776 | * overflowing the user's string and about returning unprintable characters. |
---|
777 | * |
---|
778 | * @param[in] id is the object to obtain the name of |
---|
779 | * @param[in] length indicates the length of the caller's buffer |
---|
780 | * @param[in] name points a string which will be filled in. |
---|
781 | * |
---|
782 | * @return This method returns @a name or NULL on error. @a *name will |
---|
783 | * contain the name if successful. |
---|
784 | */ |
---|
785 | char *_Objects_Get_name_as_string( |
---|
786 | Objects_Id id, |
---|
787 | size_t length, |
---|
788 | char *name |
---|
789 | ); |
---|
790 | |
---|
791 | /** |
---|
792 | * This method sets the object name to either a copy of a string |
---|
793 | * or up to the first four characters of the string based upon |
---|
794 | * whether this object class uses strings for names. |
---|
795 | * |
---|
796 | * @param[in] information points to the object information structure |
---|
797 | * @param[in] the_object is the object to operate upon |
---|
798 | * @param[in] name is a pointer to the name to use |
---|
799 | * |
---|
800 | * @return If successful, true is returned. Otherwise false is returned. |
---|
801 | */ |
---|
802 | bool _Objects_Set_name( |
---|
803 | Objects_Information *information, |
---|
804 | Objects_Control *the_object, |
---|
805 | const char *name |
---|
806 | ); |
---|
807 | |
---|
808 | /** |
---|
809 | * This function removes the_object from the namespace. |
---|
810 | * |
---|
811 | * @param[in] information points to an Object Information Table |
---|
812 | * @param[in] the_object is a pointer to an object |
---|
813 | */ |
---|
814 | void _Objects_Namespace_remove( |
---|
815 | Objects_Information *information, |
---|
816 | Objects_Control *the_object |
---|
817 | ); |
---|
818 | |
---|
819 | /** |
---|
820 | * This function removes the_object control pointer and object name |
---|
821 | * in the Local Pointer and Local Name Tables. |
---|
822 | * |
---|
823 | * @param[in] information points to an Object Information Table |
---|
824 | * @param[in] the_object is a pointer to an object |
---|
825 | */ |
---|
826 | void _Objects_Close( |
---|
827 | Objects_Information *information, |
---|
828 | Objects_Control *the_object |
---|
829 | ); |
---|
830 | |
---|
831 | /* |
---|
832 | * Pieces of object.inl are promoted out to the user |
---|
833 | */ |
---|
834 | |
---|
835 | #include <rtems/score/object.inl> |
---|
836 | #if defined(RTEMS_MULTIPROCESSING) |
---|
837 | #include <rtems/score/objectmp.h> |
---|
838 | #endif |
---|
839 | |
---|
840 | #ifdef __cplusplus |
---|
841 | } |
---|
842 | #endif |
---|
843 | |
---|
844 | #endif |
---|
845 | /* end of include file */ |
---|