1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ScoreObject |
---|
5 | * |
---|
6 | * @brief Object Handler Data Structures |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2011. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _RTEMS_SCORE_OBJECTDATA_H |
---|
19 | #define _RTEMS_SCORE_OBJECTDATA_H |
---|
20 | |
---|
21 | #include <rtems/score/object.h> |
---|
22 | #include <rtems/score/chainimpl.h> |
---|
23 | #include <rtems/score/rbtree.h> |
---|
24 | |
---|
25 | #ifdef __cplusplus |
---|
26 | extern "C" { |
---|
27 | #endif |
---|
28 | |
---|
29 | /** |
---|
30 | * @addtogroup ScoreObject |
---|
31 | * |
---|
32 | * @{ |
---|
33 | */ |
---|
34 | |
---|
35 | /** |
---|
36 | * The following defines the Object Control Block used to manage |
---|
37 | * each object local to this node. |
---|
38 | */ |
---|
39 | typedef struct { |
---|
40 | /** This is the chain node portion of an object. */ |
---|
41 | Chain_Node Node; |
---|
42 | /** This is the object's ID. */ |
---|
43 | Objects_Id id; |
---|
44 | /** This is the object's name. */ |
---|
45 | Objects_Name name; |
---|
46 | } Objects_Control; |
---|
47 | |
---|
48 | /** |
---|
49 | * This enumerated type is used in the class field of the object ID |
---|
50 | * for RTEMS internal object classes. |
---|
51 | */ |
---|
52 | typedef enum { |
---|
53 | OBJECTS_INTERNAL_NO_CLASS = 0, |
---|
54 | OBJECTS_INTERNAL_THREADS = 1 |
---|
55 | } Objects_Internal_API; |
---|
56 | |
---|
57 | /** |
---|
58 | * This enumerated type is used in the class field of the object ID |
---|
59 | * for the RTEMS Classic API. |
---|
60 | */ |
---|
61 | typedef enum { |
---|
62 | OBJECTS_CLASSIC_NO_CLASS = 0, |
---|
63 | OBJECTS_RTEMS_TASKS = 1, |
---|
64 | OBJECTS_RTEMS_TIMERS = 2, |
---|
65 | OBJECTS_RTEMS_SEMAPHORES = 3, |
---|
66 | OBJECTS_RTEMS_MESSAGE_QUEUES = 4, |
---|
67 | OBJECTS_RTEMS_PARTITIONS = 5, |
---|
68 | OBJECTS_RTEMS_REGIONS = 6, |
---|
69 | OBJECTS_RTEMS_PORTS = 7, |
---|
70 | OBJECTS_RTEMS_PERIODS = 8, |
---|
71 | OBJECTS_RTEMS_EXTENSIONS = 9, |
---|
72 | OBJECTS_RTEMS_BARRIERS = 10 |
---|
73 | } Objects_Classic_API; |
---|
74 | |
---|
75 | /** |
---|
76 | * This enumerated type is used in the class field of the object ID |
---|
77 | * for the POSIX API. |
---|
78 | */ |
---|
79 | typedef enum { |
---|
80 | OBJECTS_POSIX_NO_CLASS = 0, |
---|
81 | OBJECTS_POSIX_THREADS = 1, |
---|
82 | OBJECTS_POSIX_KEYS = 2, |
---|
83 | OBJECTS_POSIX_INTERRUPTS = 3, |
---|
84 | OBJECTS_POSIX_MESSAGE_QUEUES = 5, |
---|
85 | OBJECTS_POSIX_SEMAPHORES = 7, |
---|
86 | OBJECTS_POSIX_TIMERS = 9, |
---|
87 | OBJECTS_POSIX_SHMS = 12 |
---|
88 | } Objects_POSIX_API; |
---|
89 | |
---|
90 | /** |
---|
91 | * @brief Constant for the object information string name length to indicate |
---|
92 | * that this object class has no string names. |
---|
93 | */ |
---|
94 | #define OBJECTS_NO_STRING_NAME 0 |
---|
95 | |
---|
96 | #if defined( RTEMS_MULTIPROCESSING ) |
---|
97 | struct _Thread_Control; |
---|
98 | |
---|
99 | /** |
---|
100 | * @brief This defines the Global Object Control Block used to manage objects |
---|
101 | * resident on other nodes. |
---|
102 | */ |
---|
103 | typedef struct { |
---|
104 | /** |
---|
105 | * @brief Nodes to manage active and inactive global objects. |
---|
106 | */ |
---|
107 | union { |
---|
108 | /** |
---|
109 | * @brief Inactive global objects reside on a chain. |
---|
110 | */ |
---|
111 | Chain_Node Inactive; |
---|
112 | |
---|
113 | struct { |
---|
114 | /** |
---|
115 | * @brief Node to lookup an active global object by identifier. |
---|
116 | */ |
---|
117 | RBTree_Node Id_lookup; |
---|
118 | |
---|
119 | /** |
---|
120 | * @brief Node to lookup an active global object by name. |
---|
121 | */ |
---|
122 | RBTree_Node Name_lookup; |
---|
123 | } Active; |
---|
124 | } Nodes; |
---|
125 | |
---|
126 | /** |
---|
127 | * @brief The global object identifier. |
---|
128 | */ |
---|
129 | Objects_Id id; |
---|
130 | |
---|
131 | /** |
---|
132 | * @brief The global object name. |
---|
133 | * |
---|
134 | * Using an unsigned thirty two bit value is broken but works. If any API is |
---|
135 | * MP with variable length names .. BOOM!!!! |
---|
136 | */ |
---|
137 | uint32_t name; |
---|
138 | } Objects_MP_Control; |
---|
139 | |
---|
140 | /** |
---|
141 | * The following type defines the callout used when a local task |
---|
142 | * is extracted from a remote thread queue (i.e. it's proxy must |
---|
143 | * extracted from the remote queue). |
---|
144 | */ |
---|
145 | typedef void ( *Objects_Thread_queue_Extract_callout )( |
---|
146 | struct _Thread_Control *, |
---|
147 | Objects_Id |
---|
148 | ); |
---|
149 | #endif |
---|
150 | |
---|
151 | /** |
---|
152 | * The following defines the structure for the information used to |
---|
153 | * manage each class of objects. |
---|
154 | */ |
---|
155 | typedef struct { |
---|
156 | /** This is the maximum valid id of this object class. */ |
---|
157 | Objects_Id maximum_id; |
---|
158 | /** This points to the table of local objects. */ |
---|
159 | Objects_Control **local_table; |
---|
160 | /** This is the number of objects on the Inactive list. */ |
---|
161 | Objects_Maximum inactive; |
---|
162 | /** This is the number of objects in a block. */ |
---|
163 | Objects_Maximum objects_per_block; |
---|
164 | /** This is the size in bytes of each object instance. */ |
---|
165 | uint16_t object_size; |
---|
166 | /** |
---|
167 | * @brief This is the maximum length of names. |
---|
168 | * |
---|
169 | * A length of zero indicates that this object has a no string name |
---|
170 | * (OBJECTS_NO_STRING_NAME). |
---|
171 | */ |
---|
172 | uint16_t name_length; |
---|
173 | /** This is the chain of inactive control blocks. */ |
---|
174 | Chain_Control Inactive; |
---|
175 | /** This is the number of inactive objects per block. */ |
---|
176 | Objects_Maximum *inactive_per_block; |
---|
177 | /** This is a table to the chain of inactive object memory blocks. */ |
---|
178 | Objects_Control **object_blocks; |
---|
179 | Objects_Control *initial_objects; |
---|
180 | #if defined(RTEMS_MULTIPROCESSING) |
---|
181 | /** This is this object class' method called when extracting a thread. */ |
---|
182 | Objects_Thread_queue_Extract_callout extract; |
---|
183 | |
---|
184 | /** |
---|
185 | * @brief The global objects of this object information sorted by object |
---|
186 | * identifier. |
---|
187 | */ |
---|
188 | RBTree_Control Global_by_id; |
---|
189 | |
---|
190 | /** |
---|
191 | * @brief The global objects of this object information sorted by object |
---|
192 | * name. |
---|
193 | * |
---|
194 | * Objects with the same name are sorted according to their identifier. |
---|
195 | */ |
---|
196 | RBTree_Control Global_by_name; |
---|
197 | #endif |
---|
198 | } Objects_Information; |
---|
199 | |
---|
200 | #if defined(RTEMS_MULTIPROCESSING) |
---|
201 | #define OBJECTS_INFORMATION_MP( name, extract ) \ |
---|
202 | , \ |
---|
203 | extract, \ |
---|
204 | RBTREE_INITIALIZER_EMPTY( name.Global_by_id ), \ |
---|
205 | RBTREE_INITIALIZER_EMPTY( name.Global_by_name ) |
---|
206 | #else |
---|
207 | #define OBJECTS_INFORMATION_MP( name, extract ) |
---|
208 | #endif |
---|
209 | |
---|
210 | /** |
---|
211 | * @brief Statically initializes an objects information. |
---|
212 | * |
---|
213 | * The initialized objects information contains no objects. |
---|
214 | * |
---|
215 | * @param name The object class C designator namespace prefix, e.g. _Semaphore. |
---|
216 | * @param api The object API number, e.g. OBJECTS_CLASSIC_API. |
---|
217 | * @param cls The object class number, e.g. OBJECTS_RTEMS_SEMAPHORES. |
---|
218 | * @param nl The object name string length, use OBJECTS_NO_STRING_NAME for |
---|
219 | * objects without a string name. |
---|
220 | */ |
---|
221 | #define OBJECTS_INFORMATION_DEFINE_ZERO( name, api, cls, nl ) \ |
---|
222 | Objects_Information name##_Information = { \ |
---|
223 | _Objects_Build_id( api, cls, 1, 0 ), \ |
---|
224 | NULL, \ |
---|
225 | 0, \ |
---|
226 | 0, \ |
---|
227 | 0, \ |
---|
228 | nl, \ |
---|
229 | CHAIN_INITIALIZER_EMPTY( name##_Information.Inactive ), \ |
---|
230 | NULL, \ |
---|
231 | NULL, \ |
---|
232 | NULL \ |
---|
233 | OBJECTS_INFORMATION_MP( name##_Information, NULL ) \ |
---|
234 | } |
---|
235 | |
---|
236 | /** |
---|
237 | * @brief Statically initializes an objects information. |
---|
238 | * |
---|
239 | * The initialized objects information references a table with statically |
---|
240 | * allocated objects as specified by the object maximum parameter. These |
---|
241 | * objects must be registered via a call to _Objects_Information(). |
---|
242 | * |
---|
243 | * @param name The object class C designator namespace prefix, e.g. _Semaphore. |
---|
244 | * @param api The object API number, e.g. OBJECTS_CLASSIC_API. |
---|
245 | * @param cls The object class number, e.g. OBJECTS_RTEMS_SEMAPHORES. |
---|
246 | * @param type The object class type. |
---|
247 | * @param max The configured object maximum (the OBJECTS_UNLIMITED_OBJECTS flag |
---|
248 | * may be set). |
---|
249 | * @param nl The object name string length, use OBJECTS_NO_STRING_NAME for |
---|
250 | * objects without a string name. |
---|
251 | * @param ex The optional object extraction method. Used only if |
---|
252 | * multiprocessing (RTEMS_MULTIPROCESSING) is enabled. |
---|
253 | */ |
---|
254 | #define OBJECTS_INFORMATION_DEFINE( name, api, cls, type, max, nl, ex ) \ |
---|
255 | static Objects_Control * \ |
---|
256 | name##_Local_table[ _Objects_Maximum_per_allocation( max ) ]; \ |
---|
257 | static type name##_Objects[ _Objects_Maximum_per_allocation( max ) ]; \ |
---|
258 | Objects_Information name##_Information = { \ |
---|
259 | _Objects_Build_id( api, cls, 1, _Objects_Maximum_per_allocation( max ) ), \ |
---|
260 | name##_Local_table, \ |
---|
261 | 0, \ |
---|
262 | _Objects_Is_unlimited( max ) ? _Objects_Maximum_per_allocation( max ) : 0, \ |
---|
263 | sizeof( type ), \ |
---|
264 | nl, \ |
---|
265 | CHAIN_INITIALIZER_EMPTY( name##_Information.Inactive ), \ |
---|
266 | NULL, \ |
---|
267 | NULL, \ |
---|
268 | &name##_Objects[ 0 ].Object \ |
---|
269 | OBJECTS_INFORMATION_MP( name##_Information, ex ) \ |
---|
270 | } |
---|
271 | |
---|
272 | /** @} */ |
---|
273 | |
---|
274 | #ifdef __cplusplus |
---|
275 | } |
---|
276 | #endif |
---|
277 | |
---|
278 | #endif |
---|
279 | /* end of include file */ |
---|