1 | /** |
---|
2 | * @file rtems/assoc.h |
---|
3 | * |
---|
4 | * @brief RTEMS Associativity Routines |
---|
5 | * |
---|
6 | * RTEMS associativity routines. Mainly used to convert a value from |
---|
7 | * one space to another (eg: our errno's to host errno's and vice-versa) |
---|
8 | */ |
---|
9 | |
---|
10 | |
---|
11 | #ifndef _RTEMS_RTEMS_ASSOC_H |
---|
12 | #define _RTEMS_RTEMS_ASSOC_H |
---|
13 | |
---|
14 | /** |
---|
15 | * @defgroup Associativity Associativity Routines |
---|
16 | */ |
---|
17 | /**@{*/ |
---|
18 | |
---|
19 | #include <stdint.h> /* uint32_t */ |
---|
20 | |
---|
21 | #ifdef __cplusplus |
---|
22 | extern "C" { |
---|
23 | #endif |
---|
24 | |
---|
25 | typedef struct { |
---|
26 | const char *name; |
---|
27 | uint32_t local_value; |
---|
28 | uint32_t remote_value; |
---|
29 | } rtems_assoc_t; |
---|
30 | |
---|
31 | /* |
---|
32 | * Flag/marker for optional default value in each table |
---|
33 | */ |
---|
34 | |
---|
35 | #define RTEMS_ASSOC_DEFAULT_NAME "(default)" |
---|
36 | |
---|
37 | /** |
---|
38 | * @brief RTEMS Associate Pointer by Name |
---|
39 | */ |
---|
40 | const rtems_assoc_t *rtems_assoc_ptr_by_name( |
---|
41 | const rtems_assoc_t *, |
---|
42 | const char * |
---|
43 | ); |
---|
44 | |
---|
45 | /** |
---|
46 | * @brief RTEMS Associate Pointer by Remote |
---|
47 | */ |
---|
48 | const rtems_assoc_t *rtems_assoc_ptr_by_remote( |
---|
49 | const rtems_assoc_t *, |
---|
50 | uint32_t |
---|
51 | ); |
---|
52 | |
---|
53 | uint32_t rtems_assoc_remote_by_local( |
---|
54 | const rtems_assoc_t *, |
---|
55 | uint32_t |
---|
56 | ); |
---|
57 | |
---|
58 | /** |
---|
59 | * @brief RTEMS Associate Local by Remote |
---|
60 | */ |
---|
61 | uint32_t rtems_assoc_local_by_remote( |
---|
62 | const rtems_assoc_t *, |
---|
63 | uint32_t |
---|
64 | ); |
---|
65 | |
---|
66 | /** |
---|
67 | * @brief RTEMS Associate Remote by Name |
---|
68 | */ |
---|
69 | uint32_t rtems_assoc_remote_by_name( |
---|
70 | const rtems_assoc_t *, |
---|
71 | const char * |
---|
72 | ); |
---|
73 | |
---|
74 | /** |
---|
75 | * @brief RTEMS Associate Local by Name |
---|
76 | */ |
---|
77 | uint32_t rtems_assoc_local_by_name( |
---|
78 | const rtems_assoc_t *, |
---|
79 | const char * |
---|
80 | ); |
---|
81 | |
---|
82 | /** |
---|
83 | * @brief RTEMS Associate Name by Local |
---|
84 | */ |
---|
85 | const char *rtems_assoc_name_by_local( |
---|
86 | const rtems_assoc_t *, |
---|
87 | uint32_t |
---|
88 | ); |
---|
89 | |
---|
90 | /** |
---|
91 | * @brief RTEMS Associate Name by Remote |
---|
92 | */ |
---|
93 | const char *rtems_assoc_name_by_remote( |
---|
94 | const rtems_assoc_t *, |
---|
95 | uint32_t |
---|
96 | ); |
---|
97 | |
---|
98 | /** |
---|
99 | * @brief RTEMS Assoc Routines |
---|
100 | */ |
---|
101 | uint32_t rtems_assoc_remote_by_local_bitfield( |
---|
102 | const rtems_assoc_t *, |
---|
103 | uint32_t |
---|
104 | ); |
---|
105 | |
---|
106 | /** |
---|
107 | * @brief RTEMS Associate Name by Local Bitfield |
---|
108 | */ |
---|
109 | char *rtems_assoc_name_by_local_bitfield( |
---|
110 | const rtems_assoc_t *, |
---|
111 | uint32_t , |
---|
112 | char * |
---|
113 | ); |
---|
114 | |
---|
115 | /** |
---|
116 | * @brief RTEMS Associate Name by Remote Bitfield |
---|
117 | */ |
---|
118 | char *rtems_assoc_name_by_remote_bitfield( |
---|
119 | const rtems_assoc_t *, |
---|
120 | uint32_t , |
---|
121 | char * |
---|
122 | ); |
---|
123 | |
---|
124 | uint32_t rtems_assoc_local_by_remote_bitfield( |
---|
125 | const rtems_assoc_t *, |
---|
126 | uint32_t |
---|
127 | ); |
---|
128 | |
---|
129 | /** |
---|
130 | * @brief RTEMS Associate Pointer by Local |
---|
131 | */ |
---|
132 | const rtems_assoc_t *rtems_assoc_ptr_by_local( |
---|
133 | const rtems_assoc_t *ap, |
---|
134 | uint32_t local_value |
---|
135 | ); |
---|
136 | |
---|
137 | #if defined(INSIDE_ASSOC) |
---|
138 | |
---|
139 | #define rtems_assoc_is_default(_ap) \ |
---|
140 | ((_ap)->name && !strcmp((_ap)->name, RTEMS_ASSOC_DEFAULT_NAME)) |
---|
141 | |
---|
142 | /** |
---|
143 | * @brief RTEMS Associate Bad Name |
---|
144 | * |
---|
145 | * what to return if a value is not found |
---|
146 | * this is not reentrant, but it really shouldn't be invoked anyway |
---|
147 | */ |
---|
148 | const char *rtems_assoc_name_bad( |
---|
149 | uint32_t bad_value |
---|
150 | ); |
---|
151 | #endif |
---|
152 | |
---|
153 | #ifdef __cplusplus |
---|
154 | } |
---|
155 | #endif |
---|
156 | /**@}*/ |
---|
157 | #endif /* ! _RTEMS_RTEMS_ASSOC_H */ |
---|