1 | /* object.h |
---|
2 | * |
---|
3 | * This include file contains all the constants and structures associated |
---|
4 | * with the Object Handler. This Handler provides mechanisms which |
---|
5 | * can be used to initialize and manipulate all objects which have |
---|
6 | * ids. |
---|
7 | * |
---|
8 | * COPYRIGHT (c) 1989-1999. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.OARcorp.com/rtems/license.html. |
---|
14 | * |
---|
15 | * $Id$ |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef __OBJECTS_h |
---|
19 | #define __OBJECTS_h |
---|
20 | |
---|
21 | #ifdef __cplusplus |
---|
22 | extern "C" { |
---|
23 | #endif |
---|
24 | |
---|
25 | #include <rtems/score/chain.h> |
---|
26 | #include <rtems/score/isr.h> |
---|
27 | |
---|
28 | /* |
---|
29 | * Mask to enable unlimited objects |
---|
30 | */ |
---|
31 | |
---|
32 | #define OBJECTS_UNLIMITED_OBJECTS 0x80000000 |
---|
33 | |
---|
34 | /* |
---|
35 | * The following type defines the control block used to manage |
---|
36 | * object names. |
---|
37 | */ |
---|
38 | |
---|
39 | typedef void * Objects_Name; |
---|
40 | |
---|
41 | /* |
---|
42 | * Space for object names is allocated in multiples of this. |
---|
43 | * |
---|
44 | * NOTE: Must be a power of 2. Matches the name manipulation routines. |
---|
45 | */ |
---|
46 | |
---|
47 | #define OBJECTS_NAME_ALIGNMENT sizeof( unsigned32 ) |
---|
48 | |
---|
49 | /* |
---|
50 | * Functions which compare names are prototyped like this. |
---|
51 | */ |
---|
52 | |
---|
53 | typedef boolean (*Objects_Name_comparators)( |
---|
54 | void * /* name_1 */, |
---|
55 | void * /* name_2 */, |
---|
56 | unsigned32 /* length */ |
---|
57 | ); |
---|
58 | |
---|
59 | /* |
---|
60 | * The following type defines the control block used to manage |
---|
61 | * object IDs. The format is as follows (0=LSB): |
---|
62 | * |
---|
63 | * Bits 0 .. 15 = index |
---|
64 | * Bits 16 .. 25 = node |
---|
65 | * Bits 26 .. 31 = class |
---|
66 | */ |
---|
67 | |
---|
68 | typedef unsigned32 Objects_Id; |
---|
69 | |
---|
70 | #define OBJECTS_INDEX_START_BIT 0 |
---|
71 | #define OBJECTS_NODE_START_BIT 16 |
---|
72 | #define OBJECTS_CLASS_START_BIT 26 |
---|
73 | |
---|
74 | #define OBJECTS_INDEX_MASK 0x0000ffff |
---|
75 | #define OBJECTS_NODE_MASK 0x03ff0000 |
---|
76 | #define OBJECTS_CLASS_MASK 0xfc000000 |
---|
77 | |
---|
78 | #define OBJECTS_INDEX_VALID_BITS 0x0000ffff |
---|
79 | #define OBJECTS_NODE_VALID_BITS 0x000003ff |
---|
80 | #define OBJECTS_CLASS_VALID_BITS 0x000000cf |
---|
81 | |
---|
82 | /* |
---|
83 | * This enumerated type is used in the class field of the object ID. |
---|
84 | */ |
---|
85 | |
---|
86 | typedef enum { |
---|
87 | OBJECTS_NO_CLASS = 0, |
---|
88 | OBJECTS_INTERNAL_THREADS = 1, |
---|
89 | OBJECTS_RTEMS_TASKS = 2, |
---|
90 | OBJECTS_POSIX_THREADS = 3, |
---|
91 | OBJECTS_ITRON_TASKS = 4, |
---|
92 | OBJECTS_RTEMS_TIMERS = 5, |
---|
93 | OBJECTS_RTEMS_SEMAPHORES = 6, |
---|
94 | OBJECTS_RTEMS_MESSAGE_QUEUES = 7, |
---|
95 | OBJECTS_RTEMS_PARTITIONS = 8, |
---|
96 | OBJECTS_RTEMS_REGIONS = 9, |
---|
97 | OBJECTS_RTEMS_PORTS = 10, |
---|
98 | OBJECTS_RTEMS_PERIODS = 11, |
---|
99 | OBJECTS_RTEMS_EXTENSIONS = 12, |
---|
100 | OBJECTS_POSIX_KEYS = 13, |
---|
101 | OBJECTS_POSIX_INTERRUPTS = 14, |
---|
102 | OBJECTS_POSIX_MESSAGE_QUEUES = 15, |
---|
103 | OBJECTS_POSIX_MUTEXES = 16, |
---|
104 | OBJECTS_POSIX_SEMAPHORES = 17, |
---|
105 | OBJECTS_POSIX_CONDITION_VARIABLES = 18, |
---|
106 | OBJECTS_ITRON_EVENTFLAGS = 19, |
---|
107 | OBJECTS_ITRON_MAILBOXES = 20, |
---|
108 | OBJECTS_ITRON_MESSAGE_BUFFERS = 21, |
---|
109 | OBJECTS_ITRON_PORTS = 22, |
---|
110 | OBJECTS_ITRON_SEMAPHORES = 23, |
---|
111 | OBJECTS_ITRON_VARIABLE_MEMORY_POOLS = 24, |
---|
112 | OBJECTS_ITRON_FIXED_MEMORY_POOLS = 25 |
---|
113 | } Objects_Classes; |
---|
114 | |
---|
115 | #define OBJECTS_CLASSES_FIRST OBJECTS_NO_CLASS |
---|
116 | #define OBJECTS_CLASSES_LAST OBJECTS_ITRON_FIXED_MEMORY_POOLS |
---|
117 | #define OBJECTS_CLASSES_FIRST_THREAD_CLASS OBJECTS_INTERNAL_THREADS |
---|
118 | #define OBJECTS_CLASSES_LAST_THREAD_CLASS OBJECTS_ITRON_TASKS |
---|
119 | |
---|
120 | /* |
---|
121 | * This enumerated type lists the locations which may be returned |
---|
122 | * by _Objects_Get. These codes indicate the success of locating |
---|
123 | * an object with the specified ID. |
---|
124 | */ |
---|
125 | |
---|
126 | typedef enum { |
---|
127 | OBJECTS_LOCAL = 0, /* object is local */ |
---|
128 | OBJECTS_REMOTE = 1, /* object is remote */ |
---|
129 | OBJECTS_ERROR = 2 /* id was invalid */ |
---|
130 | } Objects_Locations; |
---|
131 | |
---|
132 | /* |
---|
133 | * The following defines the Object Control Block used to manage |
---|
134 | * each object local to this node. |
---|
135 | */ |
---|
136 | |
---|
137 | typedef struct { |
---|
138 | Chain_Node Node; |
---|
139 | Objects_Id id; |
---|
140 | Objects_Name name; |
---|
141 | } Objects_Control; |
---|
142 | |
---|
143 | /* |
---|
144 | * The following defines the structure for the information used to |
---|
145 | * manage each class of objects. |
---|
146 | */ |
---|
147 | |
---|
148 | typedef struct { |
---|
149 | Objects_Classes the_class; /* Class of this object */ |
---|
150 | Objects_Id minimum_id; /* minimum valid id of this type */ |
---|
151 | Objects_Id maximum_id; /* maximum valid id of this type */ |
---|
152 | unsigned32 maximum; /* maximum number of objects */ |
---|
153 | boolean auto_extend; /* TRUE if unlimited objects */ |
---|
154 | unsigned32 allocation_size; /* number of objects in a block */ |
---|
155 | unsigned32 size; /* size of the objects */ |
---|
156 | Objects_Control **local_table; |
---|
157 | Objects_Name *name_table; |
---|
158 | Chain_Control *global_table; /* pointer to global table */ |
---|
159 | Chain_Control Inactive; /* chain of inactive ctl blocks */ |
---|
160 | unsigned32 inactive; /* number of objects on the InActive list */ |
---|
161 | unsigned32 *inactive_per_block; /* used to release a block */ |
---|
162 | void **object_blocks; /* the object memory to remove */ |
---|
163 | boolean is_string; /* TRUE if names are strings */ |
---|
164 | unsigned32 name_length; /* maximum length of names */ |
---|
165 | boolean is_thread; /* TRUE if these are threads */ |
---|
166 | /* irregardless of API */ |
---|
167 | } Objects_Information; |
---|
168 | |
---|
169 | /* |
---|
170 | * The following defines the data storage which contains the |
---|
171 | * node number of the local node. |
---|
172 | */ |
---|
173 | |
---|
174 | SCORE_EXTERN unsigned32 _Objects_Local_node; |
---|
175 | SCORE_EXTERN unsigned32 _Objects_Maximum_nodes; |
---|
176 | |
---|
177 | /* |
---|
178 | * The following is the list of information blocks for each object |
---|
179 | * class. From the ID, we can go to one of these information blocks, |
---|
180 | * and obtain a pointer to the appropriate object control block. |
---|
181 | */ |
---|
182 | |
---|
183 | SCORE_EXTERN Objects_Information |
---|
184 | *_Objects_Information_table[OBJECTS_CLASSES_LAST + 1]; |
---|
185 | |
---|
186 | /* |
---|
187 | * The following defines the constant which may be used |
---|
188 | * with _Objects_Get to manipulate the calling task. |
---|
189 | * |
---|
190 | */ |
---|
191 | |
---|
192 | #define OBJECTS_ID_OF_SELF ((Objects_Id) 0) |
---|
193 | |
---|
194 | /* |
---|
195 | * The following define the constants which may be used in name searches. |
---|
196 | */ |
---|
197 | |
---|
198 | #define OBJECTS_SEARCH_ALL_NODES 0 |
---|
199 | #define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE |
---|
200 | #define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF |
---|
201 | #define OBJECTS_WHO_AM_I 0 |
---|
202 | |
---|
203 | /* |
---|
204 | * Parameters and return id's for _Objects_Get_next |
---|
205 | */ |
---|
206 | |
---|
207 | #define OBJECTS_ID_INITIAL_INDEX (0) |
---|
208 | #define OBJECTS_ID_FINAL_INDEX (0xffff) |
---|
209 | |
---|
210 | #define OBJECTS_ID_INITIAL(_class, _node) \ |
---|
211 | _Objects_Build_id( (_class), (_node), OBJECTS_ID_INITIAL_INDEX ) |
---|
212 | |
---|
213 | #define OBJECTS_ID_FINAL ((Objects_Id)~0) |
---|
214 | |
---|
215 | /* |
---|
216 | * _Objects_Handler_initialization |
---|
217 | * |
---|
218 | * DESCRIPTION: |
---|
219 | * |
---|
220 | * This function performs the initialization necessary for this handler. |
---|
221 | * |
---|
222 | */ |
---|
223 | |
---|
224 | void _Objects_Handler_initialization( |
---|
225 | unsigned32 node, |
---|
226 | unsigned32 maximum_nodes, |
---|
227 | unsigned32 maximum_global_objects |
---|
228 | ); |
---|
229 | |
---|
230 | /* |
---|
231 | * _Objects_Extend_information |
---|
232 | * |
---|
233 | * DESCRIPTION: |
---|
234 | * |
---|
235 | * This function extends an object class information record. |
---|
236 | */ |
---|
237 | |
---|
238 | void _Objects_Extend_information( |
---|
239 | Objects_Information *information |
---|
240 | ); |
---|
241 | |
---|
242 | /* |
---|
243 | * _Objects_Shrink_information |
---|
244 | * |
---|
245 | * DESCRIPTION: |
---|
246 | * |
---|
247 | * This function shrink an object class information record. |
---|
248 | */ |
---|
249 | |
---|
250 | void _Objects_Shrink_information( |
---|
251 | Objects_Information *information |
---|
252 | ); |
---|
253 | |
---|
254 | /* |
---|
255 | * _Objects_Initialize_information |
---|
256 | * |
---|
257 | * DESCRIPTION: |
---|
258 | * |
---|
259 | * This function initializes an object class information record. |
---|
260 | * SUPPORTS_GLOBAL is TRUE if the object class supports global |
---|
261 | * objects, and FALSE otherwise. Maximum indicates the number |
---|
262 | * of objects required in this class and size indicates the size |
---|
263 | * in bytes of each control block for this object class. The |
---|
264 | * name length and string designator are also set. In addition, |
---|
265 | * the class may be a task, therefore this information is also included. |
---|
266 | */ |
---|
267 | |
---|
268 | void _Objects_Initialize_information ( |
---|
269 | Objects_Information *information, |
---|
270 | Objects_Classes the_class, |
---|
271 | boolean supports_global, |
---|
272 | unsigned32 maximum, |
---|
273 | unsigned32 size, |
---|
274 | boolean is_string, |
---|
275 | unsigned32 maximum_name_length, |
---|
276 | boolean is_task |
---|
277 | ); |
---|
278 | |
---|
279 | /*PAGE |
---|
280 | * |
---|
281 | * _Objects_Allocate |
---|
282 | * |
---|
283 | * DESCRIPTION: |
---|
284 | * |
---|
285 | * This function allocates a object control block from |
---|
286 | * the inactive chain of free object control blocks. |
---|
287 | */ |
---|
288 | |
---|
289 | Objects_Control *_Objects_Allocate( |
---|
290 | Objects_Information *information |
---|
291 | ); |
---|
292 | |
---|
293 | /* |
---|
294 | * _Objects_Allocate_by_index |
---|
295 | * |
---|
296 | * DESCRIPTION: |
---|
297 | * |
---|
298 | * This function allocates the object control block |
---|
299 | * specified by the index from the inactive chain of |
---|
300 | * free object control blocks. |
---|
301 | */ |
---|
302 | |
---|
303 | Objects_Control *_Objects_Allocate_by_index( |
---|
304 | Objects_Information *information, |
---|
305 | unsigned32 index, |
---|
306 | unsigned32 sizeof_control |
---|
307 | ); |
---|
308 | |
---|
309 | /*PAGE |
---|
310 | * |
---|
311 | * _Objects_Free |
---|
312 | * |
---|
313 | * DESCRIPTION: |
---|
314 | * |
---|
315 | * This function frees a object control block to the |
---|
316 | * inactive chain of free object control blocks. |
---|
317 | */ |
---|
318 | |
---|
319 | void _Objects_Free( |
---|
320 | Objects_Information *information, |
---|
321 | Objects_Control *the_object |
---|
322 | ); |
---|
323 | |
---|
324 | /* |
---|
325 | * _Objects_Clear_name |
---|
326 | * |
---|
327 | * DESCRIPTION: |
---|
328 | * |
---|
329 | * This method zeroes out the name. |
---|
330 | */ |
---|
331 | |
---|
332 | void _Objects_Clear_name( |
---|
333 | void *name, |
---|
334 | unsigned32 length |
---|
335 | ); |
---|
336 | |
---|
337 | /* |
---|
338 | * _Objects_Copy_name_string |
---|
339 | * |
---|
340 | * DESCRIPTION: |
---|
341 | * |
---|
342 | * This method copies a string style object name from source to destination. |
---|
343 | */ |
---|
344 | |
---|
345 | void _Objects_Copy_name_string( |
---|
346 | void *source, |
---|
347 | void *destination |
---|
348 | ); |
---|
349 | |
---|
350 | /* |
---|
351 | * _Objects_Copy_name_raw |
---|
352 | * |
---|
353 | * DESCRIPTION: |
---|
354 | * |
---|
355 | * This method copies a raw style object name from source to destination. |
---|
356 | */ |
---|
357 | |
---|
358 | void _Objects_Copy_name_raw( |
---|
359 | void *source, |
---|
360 | void *destination, |
---|
361 | unsigned32 length |
---|
362 | ); |
---|
363 | |
---|
364 | /* |
---|
365 | * _Objects_Compare_name_string |
---|
366 | * |
---|
367 | * DESCRIPTION: |
---|
368 | * |
---|
369 | * This method compares two string style object names. |
---|
370 | */ |
---|
371 | |
---|
372 | boolean _Objects_Compare_name_string( |
---|
373 | void *name_1, |
---|
374 | void *name_2, |
---|
375 | unsigned32 length |
---|
376 | ); |
---|
377 | |
---|
378 | /* |
---|
379 | * _Objects_Compare_name_raw |
---|
380 | * |
---|
381 | * DESCRIPTION: |
---|
382 | * |
---|
383 | * This method compares two raw style object names. |
---|
384 | */ |
---|
385 | |
---|
386 | boolean _Objects_Compare_name_raw( |
---|
387 | void *name_1, |
---|
388 | void *name_2, |
---|
389 | unsigned32 length |
---|
390 | ); |
---|
391 | /* |
---|
392 | * _Objects_Name_to_id |
---|
393 | * |
---|
394 | * DESCRIPTION: |
---|
395 | * |
---|
396 | * This function implements the common portion of the object |
---|
397 | * identification directives. This directive returns the object |
---|
398 | * id associated with name. If more than one object of this class |
---|
399 | * is named name, then the object to which the id belongs is |
---|
400 | * arbitrary. Node indicates the extent of the search for the |
---|
401 | * id of the object named name. If the object class supports global |
---|
402 | * objects, then the search can be limited to a particular node |
---|
403 | * or allowed to encompass all nodes. |
---|
404 | * |
---|
405 | */ |
---|
406 | |
---|
407 | typedef enum { |
---|
408 | OBJECTS_SUCCESSFUL, |
---|
409 | OBJECTS_INVALID_NAME, |
---|
410 | OBJECTS_INVALID_NODE |
---|
411 | } Objects_Name_to_id_errors; |
---|
412 | |
---|
413 | #define OBJECTS_NAME_ERRORS_FIRST OBJECTS_SUCCESSFUL |
---|
414 | #define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE |
---|
415 | |
---|
416 | Objects_Name_to_id_errors _Objects_Name_to_id( |
---|
417 | Objects_Information *information, |
---|
418 | Objects_Name name, |
---|
419 | unsigned32 node, |
---|
420 | Objects_Id *id |
---|
421 | ); |
---|
422 | |
---|
423 | /* |
---|
424 | * _Objects_Get |
---|
425 | * |
---|
426 | * DESCRIPTION: |
---|
427 | * |
---|
428 | * This function maps object ids to object control blocks. |
---|
429 | * If id corresponds to a local object, then it returns |
---|
430 | * the_object control pointer which maps to id and location |
---|
431 | * is set to OBJECTS_LOCAL. If the object class supports global |
---|
432 | * objects and the object id is global and resides on a remote |
---|
433 | * node, then location is set to OBJECTS_REMOTE, and the_object |
---|
434 | * is undefined. Otherwise, location is set to OBJECTS_ERROR |
---|
435 | * and the_object is undefined. |
---|
436 | * |
---|
437 | * NOTE: _Objects_Get returns with dispatching disabled for |
---|
438 | * local and remote objects. |
---|
439 | * _Objects_Get_isr_disable returns with dispatching |
---|
440 | * disabled for remote objects and interrupts for local |
---|
441 | * objects. |
---|
442 | */ |
---|
443 | |
---|
444 | Objects_Control *_Objects_Get ( |
---|
445 | Objects_Information *information, |
---|
446 | Objects_Id id, |
---|
447 | Objects_Locations *location |
---|
448 | ); |
---|
449 | |
---|
450 | Objects_Control *_Objects_Get_isr_disable( |
---|
451 | Objects_Information *information, |
---|
452 | Objects_Id id, |
---|
453 | Objects_Locations *location, |
---|
454 | ISR_Level *level |
---|
455 | ); |
---|
456 | |
---|
457 | /* |
---|
458 | * _Objects_Get_next |
---|
459 | * |
---|
460 | * DESCRIPTION: |
---|
461 | * |
---|
462 | * Like _Objects_Get, but is used to find "next" open object. |
---|
463 | * |
---|
464 | */ |
---|
465 | |
---|
466 | Objects_Control *_Objects_Get_next( |
---|
467 | Objects_Information *information, |
---|
468 | Objects_Id id, |
---|
469 | Objects_Locations *location_p, |
---|
470 | Objects_Id *next_id_p |
---|
471 | ); |
---|
472 | |
---|
473 | /* |
---|
474 | * Pieces of object.inl are promoted out to the user |
---|
475 | */ |
---|
476 | |
---|
477 | #include <rtems/score/object.inl> |
---|
478 | #if defined(RTEMS_MULTIPROCESSING) |
---|
479 | #include <rtems/score/objectmp.h> |
---|
480 | #endif |
---|
481 | |
---|
482 | #ifdef __cplusplus |
---|
483 | } |
---|
484 | #endif |
---|
485 | |
---|
486 | #endif |
---|
487 | /* end of include file */ |
---|