1 | /* |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Object id to name |
---|
5 | * @ingroup Score |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2003. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/score/object.h> |
---|
23 | #include <rtems/score/thread.h> |
---|
24 | |
---|
25 | Objects_Name_or_id_lookup_errors _Objects_Id_to_name ( |
---|
26 | Objects_Id id, |
---|
27 | Objects_Name *name |
---|
28 | ) |
---|
29 | { |
---|
30 | uint32_t the_api; |
---|
31 | uint32_t the_class; |
---|
32 | Objects_Id tmpId; |
---|
33 | Objects_Information *information; |
---|
34 | Objects_Control *the_object = (Objects_Control *) 0; |
---|
35 | Objects_Locations ignored_location; |
---|
36 | |
---|
37 | /* |
---|
38 | * Caller is trusted for name != NULL. |
---|
39 | */ |
---|
40 | |
---|
41 | tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Executing->Object.id : id; |
---|
42 | |
---|
43 | the_api = _Objects_Get_API( tmpId ); |
---|
44 | if ( !_Objects_Is_api_valid( the_api ) ) |
---|
45 | return OBJECTS_INVALID_ID; |
---|
46 | |
---|
47 | if ( !_Objects_Information_table[ the_api ] ) |
---|
48 | return OBJECTS_INVALID_ID; |
---|
49 | |
---|
50 | the_class = _Objects_Get_class( tmpId ); |
---|
51 | |
---|
52 | information = _Objects_Information_table[ the_api ][ the_class ]; |
---|
53 | if ( !information ) |
---|
54 | return OBJECTS_INVALID_ID; |
---|
55 | |
---|
56 | #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) |
---|
57 | if ( information->is_string ) |
---|
58 | return OBJECTS_INVALID_ID; |
---|
59 | #endif |
---|
60 | |
---|
61 | the_object = _Objects_Get( information, tmpId, &ignored_location ); |
---|
62 | if ( !the_object ) |
---|
63 | return OBJECTS_INVALID_ID; |
---|
64 | |
---|
65 | *name = the_object->name; |
---|
66 | _Thread_Enable_dispatch(); |
---|
67 | return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL; |
---|
68 | } |
---|