RTEMS CPU Kit with SuperCore  4.11.2
objectimpl.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2011.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_SCORE_OBJECTIMPL_H
20 #define _RTEMS_SCORE_OBJECTIMPL_H
21 
22 #include <rtems/score/object.h>
23 #include <rtems/score/apimutex.h>
24 #include <rtems/score/isrlock.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
40 typedef bool (*Objects_Name_comparators)(
41  void * /* name_1 */,
42  void * /* name_2 */,
43  uint16_t /* length */
44 );
45 
50 typedef enum {
51  OBJECTS_INTERNAL_NO_CLASS = 0,
52  OBJECTS_INTERNAL_THREADS = 1,
53  OBJECTS_INTERNAL_MUTEXES = 2
55 
57 #define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_MUTEXES
58 
63 typedef enum {
64  OBJECTS_CLASSIC_NO_CLASS = 0,
65  OBJECTS_RTEMS_TASKS = 1,
66  OBJECTS_RTEMS_TIMERS = 2,
67  OBJECTS_RTEMS_SEMAPHORES = 3,
68  OBJECTS_RTEMS_MESSAGE_QUEUES = 4,
69  OBJECTS_RTEMS_PARTITIONS = 5,
70  OBJECTS_RTEMS_REGIONS = 6,
71  OBJECTS_RTEMS_PORTS = 7,
72  OBJECTS_RTEMS_PERIODS = 8,
73  OBJECTS_RTEMS_EXTENSIONS = 9,
74  OBJECTS_RTEMS_BARRIERS = 10
76 
78 #define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS
79 
84 typedef enum {
85  OBJECTS_POSIX_NO_CLASS = 0,
86  OBJECTS_POSIX_THREADS = 1,
87  OBJECTS_POSIX_KEYS = 2,
88  OBJECTS_POSIX_INTERRUPTS = 3,
89  OBJECTS_POSIX_MESSAGE_QUEUE_FDS = 4,
90  OBJECTS_POSIX_MESSAGE_QUEUES = 5,
91  OBJECTS_POSIX_MUTEXES = 6,
92  OBJECTS_POSIX_SEMAPHORES = 7,
93  OBJECTS_POSIX_CONDITION_VARIABLES = 8,
94  OBJECTS_POSIX_TIMERS = 9,
95  OBJECTS_POSIX_BARRIERS = 10,
96  OBJECTS_POSIX_SPINLOCKS = 11,
97  OBJECTS_POSIX_RWLOCKS = 12
99 
101 #define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_RWLOCKS
102 
103 /*
104  * For fake objects, which have an object identifier, but no objects
105  * information block.
106  */
107 typedef enum {
108  OBJECTS_FAKE_OBJECTS_NO_CLASS = 0,
109  OBJECTS_FAKE_OBJECTS_SCHEDULERS = 1
110 } Objects_Fake_objects_API;
111 
117 typedef enum {
118 #if defined(RTEMS_MULTIPROCESSING)
119  OBJECTS_REMOTE = 2, /* object is remote */
120 #endif
121  OBJECTS_LOCAL = 0, /* object is local */
122  OBJECTS_ERROR = 1 /* id was invalid */
124 
130 typedef void ( *Objects_Thread_queue_Extract_callout )( void * );
131 
136 typedef struct {
140  uint16_t the_class;
152  size_t size;
163  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
164 
165  bool is_string;
166  #endif
167 
168  uint16_t name_length;
169  #if defined(RTEMS_MULTIPROCESSING)
170 
173  Chain_Control *global_table;
174  #endif
176 
180 #if defined(RTEMS_MULTIPROCESSING)
182 #else
183 #define _Objects_Local_node ((uint16_t)1)
184 #endif
185 
189 #if defined(RTEMS_MULTIPROCESSING)
191 #else
192 #define _Objects_Maximum_nodes 1
193 #endif
194 
202 
209  Objects_Information *information
210 );
211 
223  Objects_Information *information
224 );
225 
248  Objects_Information *information,
249  Objects_APIs the_api,
250  uint16_t the_class,
251  uint32_t maximum,
252  uint16_t size,
253  bool is_string,
254  uint32_t maximum_name_length
255 #if defined(RTEMS_MULTIPROCESSING)
256  ,
257  bool supports_global,
259 #endif
260 );
261 
272 unsigned int _Objects_API_maximum_class(
273  uint32_t api
274 );
275 
292  Objects_Information *information
293 );
294 
335 
392 void _Objects_Free(
393  Objects_Information *information,
394  Objects_Control *the_object
395 );
396 
407 typedef enum {
408  OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL,
409  OBJECTS_INVALID_NAME,
410  OBJECTS_INVALID_ADDRESS,
411  OBJECTS_INVALID_ID,
412  OBJECTS_INVALID_NODE
414 
419 #define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL
420 
425 #define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE
426 
443 Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
444  Objects_Information *information,
445  uint32_t name,
446  uint32_t node,
447  Objects_Id *id
448 );
449 
450 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
451 
466 Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string(
467  Objects_Information *information,
468  const char *name,
469  Objects_Id *id
470 );
471 #endif
472 
490 Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
491  Objects_Id id,
492  Objects_Name *name
493 );
494 
522  Objects_Information *information,
523  Objects_Id id,
524  Objects_Locations *location
525 );
526 
555  Objects_Information *information,
556  Objects_Id id,
557  Objects_Locations *location,
558  ISR_lock_Context *lock_context
559 );
560 
588  Objects_Information *information,
589  Objects_Id id,
590  Objects_Locations *location
591 );
592 
605  Objects_Information *information,
606  Objects_Id id,
607  Objects_Locations *location_p,
608  Objects_Id *next_id_p
609 );
610 
625  Objects_APIs the_api,
626  uint16_t the_class
627 );
628 
641  Objects_Id id
642 );
643 
659  Objects_Id id,
660  size_t length,
661  char *name
662 );
663 
677 bool _Objects_Set_name(
678  Objects_Information *information,
679  Objects_Control *the_object,
680  const char *name
681 );
682 
692  Objects_Information *information,
693  Objects_Control *the_object
694 );
695 
705 void _Objects_Close(
706  Objects_Information *information,
707  Objects_Control *the_object
708 );
709 
718  const Objects_Information *information
719 );
720 
730  uint32_t the_api
731 )
732 {
733  if ( !the_api || the_api > OBJECTS_APIS_LAST )
734  return false;
735  return true;
736 }
737 
749  uint32_t node
750 )
751 {
752  return ( node == _Objects_Local_node );
753 }
754 
767 #if defined(RTEMS_MULTIPROCESSING)
768  Objects_Id id
769 #else
770  Objects_Id id __attribute__((unused))
771 #endif
772 )
773 {
774 #if defined(RTEMS_MULTIPROCESSING)
776 #else
777  return true;
778 #endif
779 }
780 
792  Objects_Id left,
793  Objects_Id right
794 )
795 {
796  return ( left == right );
797 }
798 
810  Objects_Information *information,
811  uint16_t index
812 )
813 {
814  /*
815  * This routine is ONLY to be called from places in the code
816  * where the Id is known to be good. Therefore, this should NOT
817  * occur in normal situations.
818  */
819  #if defined(RTEMS_DEBUG)
820  if ( index > information->maximum )
821  return NULL;
822  #endif
823  return information->local_table[ index ];
824 }
825 
841  Objects_Information *information,
842  uint32_t index,
843  Objects_Control *the_object
844 )
845 {
846  /*
847  * This routine is ONLY to be called from places in the code
848  * where the Id is known to be good. Therefore, this should NOT
849  * occur in normal situations.
850  */
851  #if defined(RTEMS_DEBUG)
852  if ( index > information->maximum )
853  return;
854  #endif
855 
856  information->local_table[ index ] = the_object;
857 }
858 
874  Objects_Information *information,
875  Objects_Control *the_object
876 )
877 {
878  _Assert( information != NULL );
879  _Assert( the_object != NULL );
880 
882  information,
883  _Objects_Get_index( the_object->id ),
884  NULL
885  );
886 }
887 
897  Objects_Information *information,
898  Objects_Control *the_object,
899  Objects_Name name
900 )
901 {
902  _Assert( information != NULL );
903  _Assert( the_object != NULL );
904 
905  the_object->name = name;
906 
908  information,
909  _Objects_Get_index( the_object->id ),
910  the_object
911  );
912 }
913 
923  Objects_Information *information,
924  Objects_Control *the_object,
925  uint32_t name
926 )
927 {
928  /* ASSERT: information->is_string == false */
929  the_object->name.name_u32 = name;
930 
932  information,
933  _Objects_Get_index( the_object->id ),
934  the_object
935  );
936 }
937 
947  Objects_Information *information,
948  Objects_Control *the_object,
949  const char *name
950 )
951 {
952  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
953  /* ASSERT: information->is_string */
954  the_object->name.name_p = name;
955  #endif
956 
958  information,
959  _Objects_Get_index( the_object->id ),
960  the_object
961  );
962 }
963 
971  Objects_Control *the_object
972 )
973 {
974  (void) the_object;
976 }
977 
986  Objects_Control *the_object
987 )
988 {
989  (void) the_object;
991 }
992 
1008 {
1009  _RTEMS_Lock_allocator();
1010 }
1011 
1020 {
1021  _RTEMS_Unlock_allocator();
1022 }
1023 
1026 #ifdef __cplusplus
1027 }
1028 #endif
1029 
1030 #if defined(RTEMS_MULTIPROCESSING)
1031 #include <rtems/score/objectmp.h>
1032 #endif
1033 
1034 
1035 #endif
1036 /* end of include file */
Constants and Structures Associated with the Object Handler.
uint32_t name_u32
This is the actual 32-bit "raw" integer name.
Definition: object.h:74
void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectfree.c:25
uint16_t the_class
This is the class of this object set.
Definition: objectimpl.h:140
Objects_Name_or_id_lookup_errors
This function implements the common portion of the object identification directives.
Definition: objectimpl.h:407
RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node(uint32_t node)
This function returns true if the node is of the local object, and false otherwise.
Definition: objectimpl.h:748
The following defines the Object Control Block used to manage each object local to this node...
Definition: object.h:232
Objects_Control * _Objects_Allocate_unprotected(Objects_Information *information)
Allocates an object without locking the allocator mutex.
Definition: objectallocate.c:39
void(* Objects_Thread_queue_Extract_callout)(void *)
The following type defines the callout used when a local task is extracted from a remote thread queue...
Definition: objectimpl.h:130
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index(Objects_Id id)
This function returns the index portion of the ID.
Definition: object.h:376
RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid(uint32_t the_api)
This function returns true if the api is valid.
Definition: objectimpl.h:729
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:101
Objects_Maximum allocation_size
This is the number of objects in a block.
Definition: objectimpl.h:150
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
Chain_Control Inactive
This is the chain of inactive control blocks.
Definition: objectimpl.h:156
This is used to manage a chain.
Definition: chain.h:83
bool auto_extend
This is the true if unlimited objects in this class.
Definition: objectimpl.h:148
size_t size
This is the size in bytes of each object instance.
Definition: objectimpl.h:152
Objects_Maximum inactive
This is the number of objects on the Inactive list.
Definition: objectimpl.h:158
Objects_Control * _Objects_Get_no_protection(Objects_Information *information, Objects_Id id, Objects_Locations *location)
Maps object ids to object control blocks.
Definition: objectgetnoprotection.c:23
Objects_Name_or_id_lookup_errors _Objects_Id_to_name(Objects_Id id, Objects_Name *name)
Implements the common portion of the object Id to name directives.
Definition: objectidtoname.c:23
Objects_Control * _Objects_Get(Objects_Information *information, Objects_Id id, Objects_Locations *location)
Maps object ids to object control blocks.
Definition: objectget.c:23
void _Thread_Enable_dispatch(void)
Enables thread dispatching and releases the Giant lock.
Objects_Id maximum_id
This is the maximum valid id of this object class.
Definition: objectimpl.h:144
Objects_Control ** local_table
This points to the table of local objects.
Definition: objectimpl.h:154
void _Objects_Close(Objects_Information *information, Objects_Control *the_object)
Close object.
Definition: objectclose.c:23
RTEMS_INLINE_ROUTINE void _Objects_Open(Objects_Information *information, Objects_Control *the_object, Objects_Name name)
This function places the_object control pointer and object name in the Local Pointer and Local Name T...
Definition: objectimpl.h:896
void _Objects_Initialize_information(Objects_Information *information, Objects_APIs the_api, uint16_t the_class, uint32_t maximum, uint16_t size, bool is_string, uint32_t maximum_name_length)
Initialize object Information.
Definition: objectinitializeinformation.c:27
RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(Objects_Information *information, Objects_Control *the_object)
This function sets the pointer to the local_table object referenced by the index to a NULL so the obj...
Definition: objectimpl.h:873
RTEMS_INLINE_ROUTINE void _Objects_Open_u32(Objects_Information *information, Objects_Control *the_object, uint32_t name)
This function places the_object control pointer and object name in the Local Pointer and Local Name T...
Definition: objectimpl.h:922
API Mutex Handler API.
SCORE_EXTERN Objects_Information ** _Objects_Information_table[OBJECTS_APIS_LAST+1]
The following is the list of information blocks per API for each object class.
Definition: objectimpl.h:201
RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock(void)
Unlocks the object allocator mutex.
Definition: objectimpl.h:1019
Objects_Maximum maximum
This is the maximum number of objects in this class.
Definition: objectimpl.h:146
void _Objects_Extend_information(Objects_Information *information)
This function extends an object class information record.
Definition: objectextendinformation.c:42
RTEMS_INLINE_ROUTINE void _Thread_Unnest_dispatch(void)
Enables thread dispatching and releases the Giant lock.
Definition: threaddispatch.h:369
#define _Objects_Maximum_nodes
The following is referenced to the number of nodes in the system.
Definition: objectimpl.h:192
The following defines the structure for the information used to manage each class of objects...
Definition: objectimpl.h:136
uint32_t * inactive_per_block
This is the number of inactive objects per block.
Definition: objectimpl.h:160
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:83
void _Objects_Shrink_information(Objects_Information *information)
Shrink an object class information record.
Definition: objectshrinkinformation.c:26
RTEMS_INLINE_ROUTINE Objects_Control * _Objects_Get_local_object(Objects_Information *information, uint16_t index)
This function returns a pointer to the local_table object referenced by the index.
Definition: objectimpl.h:809
char * _Objects_Get_name_as_string(Objects_Id id, size_t length, char *name)
Gets object name in the form of a C string.
Definition: objectgetnameasstring.c:32
Objects_APIs the_api
This field indicates the API of this object class.
Definition: objectimpl.h:138
Objects_Maximum _Objects_Active_count(const Objects_Information *information)
Returns the count of active objects.
Definition: objectactivecount.c:24
Objects_Internal_API
This enumerated type is used in the class field of the object ID for RTEMS internal object classes...
Definition: objectimpl.h:50
RTEMS_INLINE_ROUTINE void _Objects_Open_string(Objects_Information *information, Objects_Control *the_object, const char *name)
This function places the_object control pointer and object name in the Local Pointer and Local Name T...
Definition: objectimpl.h:946
uint16_t name_length
This is the maximum length of names.
Definition: objectimpl.h:168
uint16_t Objects_Maximum
This type is used to store the maximum number of allowed objects of each type.
Definition: object.h:128
bool _Objects_Set_name(Objects_Information *information, Objects_Control *the_object, const char *name)
Set objects name.
Definition: objectsetname.c:26
Objects_Locations
This enumerated type lists the locations which may be returned by _Objects_Get.
Definition: objectimpl.h:117
Objects_Id minimum_id
This is the minimum valid id of this object class.
Definition: objectimpl.h:142
RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock(void)
Locks the object allocator mutex.
Definition: objectimpl.h:1007
RTEMS_INLINE_ROUTINE void _Objects_Put_without_thread_dispatch(Objects_Control *the_object)
Puts back an object obtained with _Objects_Get().
Definition: objectimpl.h:985
RTEMS_INLINE_ROUTINE void _Objects_Put(Objects_Control *the_object)
Puts back an object obtained with _Objects_Get().
Definition: objectimpl.h:970
#define OBJECTS_APIS_LAST
This macro is used to generically specify the last API index.
Definition: object.h:226
Objects_Control * _Objects_Get_next(Objects_Information *information, Objects_Id id, Objects_Locations *location_p, Objects_Id *next_id_p)
Like _Objects_Get, but is used to find "next" open object.
Definition: objectgetnext.c:49
RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(Objects_Id left, Objects_Id right)
This function returns true if left and right are equal, and false otherwise.
Definition: objectimpl.h:791
RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node(Objects_Id id)
This function returns the node portion of the ID.
Definition: object.h:354
Objects_POSIX_API
This enumerated type is used in the class field of the object ID for the POSIX API.
Definition: objectimpl.h:84
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Objects_Classic_API
This enumerated type is used in the class field of the object ID for the RTEMS Classic API...
Definition: objectimpl.h:63
Objects_Name name
This is the object&#39;s name.
Definition: object.h:238
RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(Objects_Id id)
This function returns true if the id is of a local object, and false otherwise.
Definition: objectimpl.h:766
void ** object_blocks
This is a table to the chain of inactive object memory blocks.
Definition: objectimpl.h:162
uint32_t Objects_Id
The following type defines the control block used to manage object IDs.
Definition: object.h:122
The following type defines the control block used to manage object names.
Definition: object.h:68
#define SCORE_EXTERN
The following ensures that all data is declared in the space of the initialization routine for either...
Definition: basedefs.h:81
bool(* Objects_Name_comparators)(void *, void *, uint16_t)
Functions which compare names are prototyped like this.
Definition: objectimpl.h:40
Objects_Information * _Objects_Get_information_id(Objects_Id id)
Get information of an object from an ID.
Definition: objectgetinfoid.c:24
#define _Objects_Local_node
The following is referenced to the node number of the local node.
Definition: objectimpl.h:183
ISR Locks.
Objects_APIs
This enumerated type is used in the class field of the object ID.
Definition: object.h:217
unsigned int _Objects_API_maximum_class(uint32_t api)
Object API Maximum Class.
Definition: objectapimaximumclass.c:23
Objects_Control * _Objects_Get_isr_disable(Objects_Information *information, Objects_Id id, Objects_Locations *location, ISR_lock_Context *lock_context)
Maps object ids to object control blocks.
Definition: objectgetisr.c:23
void _Objects_Namespace_remove(Objects_Information *information, Objects_Control *the_object)
Removes object from namespace.
Definition: objectnamespaceremove.c:25
Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(Objects_Information *information, uint32_t name, uint32_t node, Objects_Id *id)
Converts an object name to an Id.
Definition: objectnametoid.c:23
RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(Objects_Information *information, uint32_t index, Objects_Control *the_object)
This function sets the pointer to the local_table object referenced by the index. ...
Definition: objectimpl.h:840
Data Associated with the Manipulation of Global RTEMS Objects.
Objects_Information * _Objects_Get_information(Objects_APIs the_api, uint16_t the_class)
Get object information.
Definition: objectgetinfo.c:23
Objects_Id id
This is the object&#39;s ID.
Definition: object.h:236