1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Get Class Name |
---|
5 | * @ingroup ClassicClassInfo |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2008. |
---|
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.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifdef HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/rtems/object.h> |
---|
22 | #include <rtems/score/objectimpl.h> |
---|
23 | |
---|
24 | #include <rtems/assoc.h> |
---|
25 | |
---|
26 | static const rtems_assoc_t rtems_object_api_internal_assoc[] = { |
---|
27 | { "Thread", OBJECTS_INTERNAL_THREADS, 0}, |
---|
28 | { "Mutex", OBJECTS_INTERNAL_MUTEXES, 0}, |
---|
29 | { NULL, 0, 0} |
---|
30 | }; |
---|
31 | |
---|
32 | static const rtems_assoc_t rtems_object_api_classic_assoc[] = { |
---|
33 | { "Task", OBJECTS_RTEMS_TASKS, 0}, |
---|
34 | { "Timer", OBJECTS_RTEMS_TIMERS, 0}, |
---|
35 | { "Semaphore", OBJECTS_RTEMS_SEMAPHORES, 0}, |
---|
36 | { "Message Queue", OBJECTS_RTEMS_MESSAGE_QUEUES, 0}, |
---|
37 | { "Partition", OBJECTS_RTEMS_PARTITIONS, 0}, |
---|
38 | { "Region", OBJECTS_RTEMS_REGIONS, 0}, |
---|
39 | { "Port", OBJECTS_RTEMS_PORTS, 0}, |
---|
40 | { "Period", OBJECTS_RTEMS_PERIODS, 0}, |
---|
41 | { "Extension", OBJECTS_RTEMS_EXTENSIONS, 0}, |
---|
42 | { "Barrier", OBJECTS_RTEMS_BARRIERS, 0}, |
---|
43 | { NULL, 0, 0} |
---|
44 | }; |
---|
45 | |
---|
46 | #ifdef RTEMS_POSIX_API |
---|
47 | static const rtems_assoc_t rtems_object_api_posix_assoc[] = { |
---|
48 | { "Thread", OBJECTS_POSIX_THREADS, 0}, |
---|
49 | { "Key", OBJECTS_POSIX_KEYS, 0}, |
---|
50 | { "Interrupt", OBJECTS_POSIX_INTERRUPTS, 0}, |
---|
51 | { "Message Queue", OBJECTS_POSIX_MESSAGE_QUEUES, 0}, |
---|
52 | { "Mutex", OBJECTS_POSIX_MUTEXES, 0}, |
---|
53 | { "Semaphore", OBJECTS_POSIX_SEMAPHORES, 0}, |
---|
54 | { "Condition Variable", OBJECTS_POSIX_CONDITION_VARIABLES, 0}, |
---|
55 | { "Timer", OBJECTS_POSIX_TIMERS, 0}, |
---|
56 | { "Barrier", OBJECTS_POSIX_BARRIERS, 0}, |
---|
57 | { "Spinlock", OBJECTS_POSIX_SPINLOCKS, 0}, |
---|
58 | { "RWLock", OBJECTS_POSIX_RWLOCKS, 0}, |
---|
59 | { NULL, 0, 0} |
---|
60 | }; |
---|
61 | #endif |
---|
62 | |
---|
63 | const char *rtems_object_get_api_class_name( |
---|
64 | int the_api, |
---|
65 | int the_class |
---|
66 | ) |
---|
67 | { |
---|
68 | const rtems_assoc_t *api_assoc; |
---|
69 | const rtems_assoc_t *class_assoc; |
---|
70 | |
---|
71 | if ( the_api == OBJECTS_INTERNAL_API ) |
---|
72 | api_assoc = rtems_object_api_internal_assoc; |
---|
73 | else if ( the_api == OBJECTS_CLASSIC_API ) |
---|
74 | api_assoc = rtems_object_api_classic_assoc; |
---|
75 | #ifdef RTEMS_POSIX_API |
---|
76 | else if ( the_api == OBJECTS_POSIX_API ) |
---|
77 | api_assoc = rtems_object_api_posix_assoc; |
---|
78 | #endif |
---|
79 | else |
---|
80 | return "BAD API"; |
---|
81 | class_assoc = rtems_assoc_ptr_by_local( api_assoc, the_class ); |
---|
82 | if ( class_assoc ) |
---|
83 | return class_assoc->name; |
---|
84 | return "BAD CLASS"; |
---|
85 | } |
---|