RTEMS  5.0.0
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/objectdata.h>
23 #include <rtems/score/apimutex.h>
24 #include <rtems/score/isrlock.h>
25 #include <rtems/score/threaddispatch.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 
47 #define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_THREADS
48 
50 #define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS
51 
53 #define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_SHMS
54 
55 /*
56  * For fake objects, which have an object identifier, but no objects
57  * information block.
58  */
59 typedef enum {
60  OBJECTS_FAKE_OBJECTS_NO_CLASS = 0,
61  OBJECTS_FAKE_OBJECTS_SCHEDULERS = 1
62 } Objects_Fake_objects_API;
63 
67 #if defined(RTEMS_MULTIPROCESSING)
68 extern uint16_t _Objects_Local_node;
69 #else
70 #define _Objects_Local_node ((uint16_t)1)
71 #endif
72 
76 #if defined(RTEMS_MULTIPROCESSING)
77 extern uint16_t _Objects_Maximum_nodes;
78 #else
79 #define _Objects_Maximum_nodes 1
80 #endif
81 
85 #define OBJECTS_INDEX_MINIMUM 1U
86 
92 extern Objects_Information ** const
94 
101  Objects_Information *information
102 );
103 
115  Objects_Information *information
116 );
117 
125 
136 unsigned int _Objects_API_maximum_class(
137  uint32_t api
138 );
139 
156  Objects_Information *information
157 );
158 
199 
244 void _Objects_Free(
245  Objects_Information *information,
246  Objects_Control *the_object
247 );
248 
259 typedef enum {
260  OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL,
261  OBJECTS_INVALID_NAME,
262  OBJECTS_INVALID_ADDRESS,
263  OBJECTS_INVALID_ID,
264  OBJECTS_INVALID_NODE
266 
271 #define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL
272 
277 #define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE
278 
295 Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
296  Objects_Information *information,
297  uint32_t name,
298  uint32_t node,
299  Objects_Id *id
300 );
301 
302 typedef enum {
303  OBJECTS_GET_BY_NAME_INVALID_NAME,
304  OBJECTS_GET_BY_NAME_NAME_TOO_LONG,
305  OBJECTS_GET_BY_NAME_NO_OBJECT
306 } Objects_Get_by_name_error;
307 
323  const Objects_Information *information,
324  const char *name,
325  size_t *name_length_p,
326  Objects_Get_by_name_error *error
327 );
328 
346 Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
347  Objects_Id id,
348  Objects_Name *name
349 );
350 
372  Objects_Id id,
373  ISR_lock_Context *lock_context,
374  const Objects_Information *information
375 );
376 
400  Objects_Id id,
401  const Objects_Information *information
402 );
403 
419  Objects_Id id,
420  const Objects_Information *information,
421  Objects_Id *next_id_p
422 );
423 
438  Objects_APIs the_api,
439  uint16_t the_class
440 );
441 
454  Objects_Id id
455 );
456 
472  Objects_Id id,
473  size_t length,
474  char *name
475 );
476 
492  Objects_Name name,
493  bool is_string,
494  char *buffer,
495  size_t buffer_size
496 );
497 
511 bool _Objects_Set_name(
512  const Objects_Information *information,
513  Objects_Control *the_object,
514  const char *name
515 );
516 
524  const Objects_Information *information,
525  Objects_Control *the_object
526 );
527 
535  const Objects_Information *information,
536  Objects_Control *the_object
537 );
538 
548 void _Objects_Close(
549  const Objects_Information *information,
550  Objects_Control *the_object
551 );
552 
561  const Objects_Information *information
562 );
563 
564 RTEMS_INLINE_ROUTINE bool _Objects_Has_string_name(
565  const Objects_Information *information
566 )
567 {
568  return information->name_length > 0;
569 }
570 
571 RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(
572  const Objects_Information *information
573 )
574 {
575  return information->objects_per_block;
576 }
577 
587  uint32_t the_api
588 )
589 {
590  if ( !the_api || the_api > OBJECTS_APIS_LAST )
591  return false;
592  return true;
593 }
594 
606  uint32_t node
607 )
608 {
609  return ( node == _Objects_Local_node );
610 }
611 
624 #if defined(RTEMS_MULTIPROCESSING)
625  Objects_Id id
626 #else
628 #endif
629 )
630 {
631 #if defined(RTEMS_MULTIPROCESSING)
633 #else
634  return true;
635 #endif
636 }
637 
649  Objects_Id left,
650  Objects_Id right
651 )
652 {
653  return ( left == right );
654 }
655 
666 {
667  id &= ~OBJECTS_INDEX_MASK;
669  return id;
670 }
671 
680  const Objects_Information *information
681 )
682 {
683  return _Objects_Get_index( information->maximum_id );
684 }
685 
696  const Objects_Information *information
697 )
698 {
699  return information->objects_per_block != 0;
700 }
701 
717  const Objects_Information *information,
718  uint32_t index,
719  Objects_Control *the_object
720 )
721 {
722  /*
723  * This routine is ONLY to be called from places in the code
724  * where the Id is known to be good. Therefore, this should NOT
725  * occur in normal situations.
726  */
727  _Assert( index >= OBJECTS_INDEX_MINIMUM );
728  _Assert( index <= _Objects_Get_maximum_index( information ) );
729 
730  information->local_table[ index - OBJECTS_INDEX_MINIMUM ] = the_object;
731 }
732 
748  const Objects_Information *information,
749  Objects_Control *the_object
750 )
751 {
752  _Assert( information != NULL );
753  _Assert( the_object != NULL );
754 
756  information,
757  _Objects_Get_index( the_object->id ),
758  NULL
759  );
760 }
761 
771  Objects_Information *information,
772  Objects_Control *the_object,
773  Objects_Name name
774 )
775 {
776  _Assert( information != NULL );
777  _Assert( the_object != NULL );
778 
779  the_object->name = name;
780 
782  information,
783  _Objects_Get_index( the_object->id ),
784  the_object
785  );
786 }
787 
797  const Objects_Information *information,
798  Objects_Control *the_object,
799  uint32_t name
800 )
801 {
802  _Assert( !_Objects_Has_string_name( information ) );
803  the_object->name.name_u32 = name;
804 
806  information,
807  _Objects_Get_index( the_object->id ),
808  the_object
809  );
810 }
811 
821  const Objects_Information *information,
822  Objects_Control *the_object,
823  const char *name
824 )
825 {
826  _Assert( _Objects_Has_string_name( information ) );
827  the_object->name.name_p = name;
828 
830  information,
831  _Objects_Get_index( the_object->id ),
832  the_object
833  );
834 }
835 
851 {
852  _RTEMS_Lock_allocator();
853 }
854 
863 {
864  _RTEMS_Unlock_allocator();
865 }
866 
867 RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void )
868 {
869  return _RTEMS_Allocator_is_owner();
870 }
871 
874 #ifdef __cplusplus
875 }
876 #endif
877 
878 #if defined(RTEMS_MULTIPROCESSING)
879 #include <rtems/score/objectmp.h>
880 #endif
881 
882 
883 #endif
884 /* end of include file */
uint32_t name_u32
Definition: object.h:63
void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectfree.c:25
Objects_Name_or_id_lookup_errors
Definition: objectimpl.h:259
RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node(uint32_t node)
Definition: objectimpl.h:605
Definition: objectdata.h:39
Objects_Control * _Objects_Allocate_unprotected(Objects_Information *information)
Allocates an object without locking the allocator mutex.
Definition: objectallocate.c:33
Objects_Control * _Objects_Get_by_name(const Objects_Information *information, const char *name, size_t *name_length_p, Objects_Get_by_name_error *error)
Gets an object control block identified by its name.
Definition: objectnametoidstring.c:25
Objects_Control * _Objects_Get_next(Objects_Id id, const Objects_Information *information, Objects_Id *next_id_p)
Definition: objectgetnext.c:23
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index(Objects_Id id)
Definition: object.h:291
RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid(uint32_t the_api)
Definition: objectimpl.h:586
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:89
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
bool _Objects_Set_name(const Objects_Information *information, Objects_Control *the_object, const char *name)
Set objects name.
Definition: objectsetname.c:26
#define RTEMS_UNUSED
Definition: basedefs.h:162
RTEMS_INLINE_ROUTINE void _Objects_Open_u32(const Objects_Information *information, Objects_Control *the_object, uint32_t name)
Definition: objectimpl.h:796
Objects_Control * _Objects_Get(Objects_Id id, ISR_lock_Context *lock_context, const Objects_Information *information)
Maps the specified object identifier to the associated local object control block.
Definition: objectgetlocal.c:28
RTEMS_INLINE_ROUTINE void _Objects_Open_string(const Objects_Information *information, Objects_Control *the_object, const char *name)
Definition: objectimpl.h:820
Objects_Control * _Objects_Get_no_protection(Objects_Id id, const Objects_Information *information)
Maps object ids to object control blocks.
Definition: objectgetnoprotection.c:23
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Is_auto_extend(const Objects_Information *information)
Returns true if the automatic object extension (unlimited objects) is enabled, otherwise false...
Definition: objectimpl.h:695
#define OBJECTS_INDEX_START_BIT
Definition: object.h:87
RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(const Objects_Information *information, uint32_t index, Objects_Control *the_object)
Definition: objectimpl.h:716
Object Handler Data Structures.
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
void _Objects_Namespace_remove_string(const Objects_Information *information, Objects_Control *the_object)
Removes object with a string name from its namespace.
Definition: objectnamespaceremove.c:34
Objects_Id maximum_id
This is the maximum valid ID of this object API class.
Definition: objectdata.h:169
size_t _Objects_Name_to_string(Objects_Name name, bool is_string, char *buffer, size_t buffer_size)
Converts the specified object name to a text representation.
Definition: objectgetnameasstring.c:36
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_maximum_index(const Objects_Information *information)
Definition: objectimpl.h:679
Objects_Control ** local_table
This points to the table of local object control blocks.
Definition: objectdata.h:179
#define OBJECTS_INDEX_MASK
Definition: object.h:109
RTEMS_INLINE_ROUTINE void _Objects_Open(Objects_Information *information, Objects_Control *the_object, Objects_Name name)
Definition: objectimpl.h:770
API Mutex Handler API.
RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(Objects_Id id RTEMS_UNUSED)
Definition: objectimpl.h:623
RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock(void)
Unlocks the object allocator mutex.
Definition: objectimpl.h:862
void _Objects_Extend_information(Objects_Information *information)
Definition: objectextendinformation.c:42
#define _Objects_Maximum_nodes
Definition: objectimpl.h:79
The information structure used to manage each API class of objects.
Definition: objectdata.h:160
Objects_Information **const _Objects_Information_table[OBJECTS_APIS_LAST+1]
Definition: exinit.c:53
void _Objects_Shrink_information(Objects_Information *information)
Shrink an object class information record.
Definition: objectshrinkinformation.c:25
const char * name_p
Definition: object.h:61
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:87
void _Objects_Namespace_remove_u32(const Objects_Information *information, Objects_Control *the_object)
Removes object with a 32-bit integer name from its namespace.
Definition: objectnamespaceremove.c:25
Objects_Maximum _Objects_Active_count(const Objects_Information *information)
Returns the count of active objects.
Definition: objectactivecount.c:23
uint16_t name_length
This is the maximum length of names.
Definition: objectdata.h:213
uint16_t Objects_Maximum
Definition: object.h:81
RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock(void)
Locks the object allocator mutex.
Definition: objectimpl.h:850
#define OBJECTS_APIS_LAST
Definition: object.h:178
void _Objects_Close(const Objects_Information *information, Objects_Control *the_object)
Close object.
Definition: objectclose.c:23
RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(Objects_Id left, Objects_Id right)
Definition: objectimpl.h:648
RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node(Objects_Id id)
Definition: object.h:277
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Objects_Name name
Definition: objectdata.h:45
RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(const Objects_Information *information, Objects_Control *the_object)
Definition: objectimpl.h:747
Objects_Maximum objects_per_block
This is the number of object control blocks in an allocation block.
Definition: objectdata.h:197
uint32_t Objects_Id
Definition: object.h:75
Definition: object.h:59
#define OBJECTS_INDEX_MINIMUM
Definition: objectimpl.h:85
bool(* Objects_Name_comparators)(void *, void *, uint16_t)
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
Definition: objectimpl.h:70
ISR Locks.
Objects_APIs
Definition: object.h:169
unsigned int _Objects_API_maximum_class(uint32_t api)
Object API Maximum Class.
Definition: objectapimaximumclass.c:23
RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id(Objects_Id id)
Definition: objectimpl.h:665
void _Objects_Initialize_information(Objects_Information *information)
Initializes the specified objects information.
Definition: objectinitializeinformation.c:28
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
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
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
Definition: objectdata.h:43