00001
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _RTEMS_SCORE_OBJECT_H
00023 #define _RTEMS_SCORE_OBJECT_H
00024
00025 #include <rtems/score/chain.h>
00026 #include <rtems/score/isr.h>
00027
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031
00036 typedef union {
00038 const char *name_p;
00040 uint32_t name_u32;
00041 } Objects_Name;
00042
00048 #define OBJECTS_NAME_ALIGNMENT sizeof( uint32_t )
00049
00053 typedef boolean (*Objects_Name_comparators)(
00054 void * ,
00055 void * ,
00056 uint16_t
00057 );
00058
00059 #if defined(RTEMS_USE_16_BIT_OBJECT)
00060
00068 typedef uint16_t Objects_Id;
00069
00074 typedef uint8_t Objects_Maximum;
00075
00076 #define OBJECTS_INDEX_START_BIT 0
00077 #define OBJECTS_API_START_BIT 8
00078 #define OBJECTS_CLASS_START_BIT 11
00079
00080 #define OBJECTS_INDEX_MASK (Objects_Id)0x00ff
00081 #define OBJECTS_API_MASK (Objects_Id)0x0700
00082 #define OBJECTS_CLASS_MASK (Objects_Id)0xF800
00083
00084 #define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x00ff
00085 #define OBJECTS_API_VALID_BITS (Objects_Id)0x0007
00086
00087 #define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x001f
00088
00089 #define OBJECTS_UNLIMITED_OBJECTS 0x8000
00090
00091 #define OBJECTS_ID_INITIAL_INDEX (0)
00092 #define OBJECTS_ID_FINAL_INDEX (0xff)
00093
00094 #else
00095
00104 typedef uint32_t Objects_Id;
00105
00110 typedef uint16_t Objects_Maximum;
00111
00116 #define OBJECTS_INDEX_START_BIT 0
00117
00118
00123 #define OBJECTS_NODE_START_BIT 16
00124
00129 #define OBJECTS_API_START_BIT 24
00130
00135 #define OBJECTS_CLASS_START_BIT 27
00136
00140 #define OBJECTS_INDEX_MASK (Objects_Id)0x0000ffff
00141
00145 #define OBJECTS_NODE_MASK (Objects_Id)0x00ff0000
00146
00150 #define OBJECTS_API_MASK (Objects_Id)0x07000000
00151
00155 #define OBJECTS_CLASS_MASK (Objects_Id)0xf8000000
00156
00161 #define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x0000ffff
00162
00167 #define OBJECTS_NODE_VALID_BITS (Objects_Id)0x000000ff
00168
00173 #define OBJECTS_API_VALID_BITS (Objects_Id)0x00000007
00174
00179 #define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x0000001f
00180
00185 #define OBJECTS_UNLIMITED_OBJECTS 0x80000000
00186
00190 #define OBJECTS_ID_INITIAL_INDEX (0)
00191
00195 #define OBJECTS_ID_FINAL_INDEX (0xff)
00196 #endif
00197
00201 typedef enum {
00202 OBJECTS_NO_API = 0,
00203 OBJECTS_INTERNAL_API = 1,
00204 OBJECTS_CLASSIC_API = 2,
00205 OBJECTS_POSIX_API = 3,
00206 OBJECTS_ITRON_API = 4
00207 } Objects_APIs;
00208
00210 #define OBJECTS_APIS_LAST OBJECTS_ITRON_API
00211
00216 typedef enum {
00217 OBJECTS_INTERNAL_NO_CLASS = 0,
00218 OBJECTS_INTERNAL_THREADS = 1,
00219 OBJECTS_INTERNAL_MUTEXES = 2
00220 } Objects_Internal_API;
00221
00223 #define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_MUTEXES
00224
00229 typedef enum {
00230 OBJECTS_CLASSIC_NO_CLASS = 0,
00231 OBJECTS_RTEMS_TASKS = 1,
00232 OBJECTS_RTEMS_TIMERS = 2,
00233 OBJECTS_RTEMS_SEMAPHORES = 3,
00234 OBJECTS_RTEMS_MESSAGE_QUEUES = 4,
00235 OBJECTS_RTEMS_PARTITIONS = 5,
00236 OBJECTS_RTEMS_REGIONS = 6,
00237 OBJECTS_RTEMS_PORTS = 7,
00238 OBJECTS_RTEMS_PERIODS = 8,
00239 OBJECTS_RTEMS_EXTENSIONS = 9,
00240 OBJECTS_RTEMS_BARRIERS = 10
00241 } Objects_Classic_API;
00242
00244 #define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS
00245
00250 typedef enum {
00251 OBJECTS_POSIX_NO_CLASS = 0,
00252 OBJECTS_POSIX_THREADS = 1,
00253 OBJECTS_POSIX_KEYS = 2,
00254 OBJECTS_POSIX_INTERRUPTS = 3,
00255 OBJECTS_POSIX_MESSAGE_QUEUE_FDS = 4,
00256 OBJECTS_POSIX_MESSAGE_QUEUES = 5,
00257 OBJECTS_POSIX_MUTEXES = 6,
00258 OBJECTS_POSIX_SEMAPHORES = 7,
00259 OBJECTS_POSIX_CONDITION_VARIABLES = 8,
00260 OBJECTS_POSIX_TIMERS = 9,
00261 OBJECTS_POSIX_BARRIERS = 10,
00262 OBJECTS_POSIX_SPINLOCKS = 11,
00263 OBJECTS_POSIX_RWLOCKS = 12
00264 } Objects_POSIX_API;
00265
00267 #define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_RWLOCKS
00268
00273 typedef enum {
00274 OBJECTS_ITRON_NO_CLASS = 0,
00275 OBJECTS_ITRON_TASKS = 1,
00276 OBJECTS_ITRON_EVENTFLAGS = 2,
00277 OBJECTS_ITRON_MAILBOXES = 3,
00278 OBJECTS_ITRON_MESSAGE_BUFFERS = 4,
00279 OBJECTS_ITRON_PORTS = 5,
00280 OBJECTS_ITRON_SEMAPHORES = 6,
00281 OBJECTS_ITRON_VARIABLE_MEMORY_POOLS = 7,
00282 OBJECTS_ITRON_FIXED_MEMORY_POOLS = 8
00283 } Objects_ITRON_API;
00284
00286 #define OBJECTS_ITRON_CLASSES_LAST OBJECTS_ITRON_FIXED_MEMORY_POOLS
00287
00293 typedef enum {
00294 OBJECTS_LOCAL = 0,
00295 OBJECTS_ERROR = 1,
00296 #if defined(RTEMS_MULTIPROCESSING)
00297 OBJECTS_REMOTE = 2,
00298 #endif
00299 } Objects_Locations;
00300
00306 typedef void ( *Objects_Thread_queue_Extract_callout )( void * );
00307
00312 typedef struct {
00314 Chain_Node Node;
00316 Objects_Id id;
00318 Objects_Name name;
00319 } Objects_Control;
00320
00325 typedef struct {
00327 Objects_APIs the_api;
00329 uint16_t the_class;
00331 Objects_Id minimum_id;
00333 Objects_Id maximum_id;
00335 Objects_Maximum maximum;
00337 boolean auto_extend;
00339 uint32_t allocation_size;
00341 size_t size;
00343 Objects_Control **local_table;
00345 Chain_Control Inactive;
00347 Objects_Maximum inactive;
00349 uint32_t *inactive_per_block;
00351 void **object_blocks;
00353 boolean is_string;
00355 uint16_t name_length;
00357 Objects_Thread_queue_Extract_callout extract;
00358 #if defined(RTEMS_MULTIPROCESSING)
00359
00360 Chain_Control *global_table;
00361 #endif
00362 } Objects_Information;
00363
00367 #if defined(RTEMS_MULTIPROCESSING)
00368 SCORE_EXTERN uint16_t _Objects_Local_node;
00369 #else
00370 #define _Objects_Local_node ((uint16_t)1)
00371 #endif
00372
00376 #if defined(RTEMS_MULTIPROCESSING)
00377 SCORE_EXTERN uint16_t _Objects_Maximum_nodes;
00378 #else
00379 #define _Objects_Maximum_nodes 1
00380 #endif
00381
00387 SCORE_EXTERN Objects_Information
00388 **_Objects_Information_table[OBJECTS_APIS_LAST + 1];
00389
00393 #define OBJECTS_ID_NONE 0
00394
00399 #define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
00400
00405 #define OBJECTS_SEARCH_ALL_NODES 0
00406
00411 #define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE
00412
00417 #define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF
00418
00423 #define OBJECTS_WHO_AM_I 0
00424
00429 #define OBJECTS_ID_INITIAL(_api, _class, _node) \
00430 _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX )
00431
00435 #define OBJECTS_ID_FINAL ((Objects_Id)~0)
00436
00437 #if defined(RTEMS_MULTIPROCESSING)
00438
00446 void _Objects_Handler_initialization(
00447 uint32_t node,
00448 uint32_t maximum_nodes,
00449 uint32_t maximum_global_objects
00450 );
00451 #else
00452
00455 void _Objects_Handler_initialization(void);
00456 #endif
00457
00463 void _Objects_Extend_information(
00464 Objects_Information *information
00465 );
00466
00472 void _Objects_Shrink_information(
00473 Objects_Information *information
00474 );
00475
00495 void _Objects_Initialize_information (
00496 Objects_Information *information,
00497 Objects_APIs the_api,
00498 uint32_t the_class,
00499 uint32_t maximum,
00500 uint16_t size,
00501 boolean is_string,
00502 uint32_t maximum_name_length
00503 #if defined(RTEMS_MULTIPROCESSING)
00504 ,
00505 boolean supports_global,
00506 Objects_Thread_queue_Extract_callout extract
00507 #endif
00508 );
00509
00518 int _Objects_API_maximum_class(
00519 uint32_t api
00520 );
00521
00528 Objects_Control *_Objects_Allocate(
00529 Objects_Information *information
00530 );
00531
00541 Objects_Control *_Objects_Allocate_by_index(
00542 Objects_Information *information,
00543 uint16_t index,
00544 uint16_t sizeof_control
00545 );
00546
00555 void _Objects_Free(
00556 Objects_Information *information,
00557 Objects_Control *the_object
00558 );
00559
00570 #define _Objects_Build_name( _C1, _C2, _C3, _C4 ) \
00571 ( (uint32_t)(_C1) << 24 | \
00572 (uint32_t)(_C2) << 16 | \
00573 (uint32_t)(_C3) << 8 | \
00574 (uint32_t)(_C4) )
00575
00586 typedef enum {
00587 OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL,
00588 OBJECTS_INVALID_NAME,
00589 OBJECTS_INVALID_ADDRESS,
00590 OBJECTS_INVALID_ID,
00591 OBJECTS_INVALID_NODE
00592 } Objects_Name_or_id_lookup_errors;
00593
00598 #define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL
00599
00604 #define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE
00605
00620 Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
00621 Objects_Information *information,
00622 uint32_t name,
00623 uint32_t node,
00624 Objects_Id *id
00625 );
00626
00640 Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string(
00641 Objects_Information *information,
00642 const char *name,
00643 Objects_Id *id
00644 );
00645
00661 Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
00662 Objects_Id id,
00663 Objects_Name *name
00664 );
00665
00690 Objects_Control *_Objects_Get (
00691 Objects_Information *information,
00692 Objects_Id id,
00693 Objects_Locations *location
00694 );
00695
00721 Objects_Control *_Objects_Get_isr_disable(
00722 Objects_Information *information,
00723 Objects_Id id,
00724 Objects_Locations *location,
00725 ISR_Level *level
00726 );
00727
00750 Objects_Control *_Objects_Get_by_index (
00751 Objects_Information *information,
00752 Objects_Id id,
00753 Objects_Locations *location
00754 );
00755
00780 Objects_Control *_Objects_Get_no_protection(
00781 Objects_Information *information,
00782 Objects_Id id,
00783 Objects_Locations *location
00784 );
00785
00797 Objects_Control *_Objects_Get_next(
00798 Objects_Information *information,
00799 Objects_Id id,
00800 Objects_Locations *location_p,
00801 Objects_Id *next_id_p
00802 );
00803
00815 Objects_Information *_Objects_Get_information(
00816 Objects_APIs the_api,
00817 uint32_t the_class
00818 );
00819
00829 Objects_Information *_Objects_Get_information_id(
00830 Objects_Id id
00831 );
00832
00845 char *_Objects_Get_name_as_string(
00846 Objects_Id id,
00847 size_t length,
00848 char *name
00849 );
00850
00862 boolean _Objects_Set_name(
00863 Objects_Information *information,
00864 Objects_Control *the_object,
00865 const char *name
00866 );
00867
00874 void _Objects_Namespace_remove(
00875 Objects_Information *information,
00876 Objects_Control *the_object
00877 );
00878
00886 void _Objects_Close(
00887 Objects_Information *information,
00888 Objects_Control *the_object
00889 );
00890
00891
00892
00893
00894
00895 #include <rtems/score/object.inl>
00896 #if defined(RTEMS_MULTIPROCESSING)
00897 #include <rtems/score/objectmp.h>
00898 #endif
00899
00900 #ifdef __cplusplus
00901 }
00902 #endif
00903
00904 #endif
00905