RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
objectimpl.h
Go to the documentation of this file.
1
12/*
13 * COPYRIGHT (c) 1989-2011.
14 * On-Line Applications Research Corporation (OAR).
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21#ifndef _RTEMS_SCORE_OBJECTIMPL_H
22#define _RTEMS_SCORE_OBJECTIMPL_H
23
26#include <rtems/score/assert.h>
27#include <rtems/score/isrlock.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
45 void * /* name_1 */,
46 void * /* name_2 */,
47 uint16_t /* length */
48);
49
51#define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_THREADS
52
54#define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS
55
57#define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_SHMS
58
59/*
60 * For fake objects, which have an object identifier, but no objects
61 * information block.
62 */
63typedef enum {
64 OBJECTS_FAKE_OBJECTS_NO_CLASS = 0,
65 OBJECTS_FAKE_OBJECTS_SCHEDULERS = 1
66} Objects_Fake_objects_API;
67
71#if defined(RTEMS_MULTIPROCESSING)
72extern uint16_t _Objects_Maximum_nodes;
73#else
74#define _Objects_Maximum_nodes 1
75#endif
76
80#define OBJECTS_INDEX_MINIMUM 1U
81
87extern Objects_Information ** const
89
99 Objects_Information *information
100);
101
109 Objects_Information *information,
110 Objects_Maximum block
111);
112
124 Objects_Information *information
125);
126
136
148unsigned int _Objects_API_maximum_class(
149 uint32_t api
150);
151
192
203typedef enum {
204 OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL,
205 OBJECTS_INVALID_NAME,
206 OBJECTS_INVALID_ADDRESS,
207 OBJECTS_INVALID_ID,
208 OBJECTS_INVALID_NODE
210
215#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL
216
221#define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE
222
240 Objects_Information *information,
241 uint32_t name,
242 uint32_t node,
243 Objects_Id *id
244);
245
246typedef enum {
247 OBJECTS_GET_BY_NAME_INVALID_NAME,
248 OBJECTS_GET_BY_NAME_NAME_TOO_LONG,
249 OBJECTS_GET_BY_NAME_NO_OBJECT
250} Objects_Get_by_name_error;
251
267 const Objects_Information *information,
268 const char *name,
269 size_t *name_length_p,
270 Objects_Get_by_name_error *error
271);
272
290 Objects_Id id,
291 Objects_Name *name
292);
293
315 Objects_Id id,
316 ISR_lock_Context *lock_context,
317 const Objects_Information *information
318);
319
341 Objects_Id id,
342 const Objects_Information *information
343);
344
360 Objects_Id id,
361 const Objects_Information *information,
362 Objects_Id *next_id_p
363);
364
380 Objects_APIs the_api,
381 uint16_t the_class
382);
383
397 Objects_Id id
398);
399
409 const Objects_Information *information
410)
411{
412 return information->name_length > 0;
413}
414
430 Objects_Id id,
431 size_t length,
432 char *name
433);
434
450 Objects_Name name,
451 bool is_string,
452 char *buffer,
453 size_t buffer_size
454);
455
471 const Objects_Information *information,
472 Objects_Control *the_object,
473 const char *name
474);
475
483 const Objects_Information *information,
484 Objects_Control *the_object
485)
486{
487 _Assert( !_Objects_Has_string_name( information ) );
488 the_object->name.name_u32 = 0;
489}
490
498 const Objects_Information *information,
499 Objects_Control *the_object
500);
501
511void _Objects_Close(
512 const Objects_Information *information,
513 Objects_Control *the_object
514);
515
524 const Objects_Information *information
525);
526
535 const Objects_Information *information
536)
537{
538 return information->objects_per_block;
539}
540
550 uint32_t the_api
551)
552{
553 if ( !the_api || the_api > OBJECTS_APIS_LAST )
554 return false;
555 return true;
556}
557
568 uint32_t node
569)
570{
571 return ( node == _Objects_Local_node );
572}
573
585#if defined(RTEMS_MULTIPROCESSING)
586 Objects_Id id
587#else
589#endif
590)
591{
592#if defined(RTEMS_MULTIPROCESSING)
594#else
595 return true;
596#endif
597}
598
609 Objects_Id left,
610 Objects_Id right
611)
612{
613 return ( left == right );
614}
615
626{
627 id &= ~OBJECTS_INDEX_MASK;
629 return id;
630}
631
640 const Objects_Information *information
641)
642{
643 return _Objects_Get_index( information->maximum_id );
644}
645
653 Objects_Information *information
654)
655{
656 return (Objects_Control *) _Chain_Get_unprotected( &information->Inactive );
657}
658
669 const Objects_Information *information
670)
671{
672 return information->objects_per_block != 0;
673}
674
690 const Objects_Information *information,
691 uint32_t index,
692 Objects_Control *the_object
693)
694{
695 /*
696 * This routine is ONLY to be called from places in the code
697 * where the Id is known to be good. Therefore, this should NOT
698 * occur in normal situations.
699 */
700 _Assert( index >= OBJECTS_INDEX_MINIMUM );
701 _Assert( index <= _Objects_Get_maximum_index( information ) );
702
703 information->local_table[ index - OBJECTS_INDEX_MINIMUM ] = the_object;
704}
705
723 const Objects_Information *information,
724 Objects_Control *the_object
725)
726{
727 _Assert( information != NULL );
728 _Assert( the_object != NULL );
729
731 information,
732 _Objects_Get_index( the_object->id ),
733 NULL
734 );
735}
736
748 Objects_Information *information,
749 Objects_Control *the_object,
750 Objects_Name name
751)
752{
753 _Assert( information != NULL );
754 _Assert( the_object != NULL );
755
756 the_object->name = name;
757
759 information,
760 _Objects_Get_index( the_object->id ),
761 the_object
762 );
763}
764
776 const Objects_Information *information,
777 Objects_Control *the_object,
778 uint32_t name
779)
780{
781 _Assert( !_Objects_Has_string_name( information ) );
782 the_object->name.name_u32 = name;
783
785 information,
786 _Objects_Get_index( the_object->id ),
787 the_object
788 );
789}
790
802 const Objects_Information *information,
803 Objects_Control *the_object,
804 const char *name
805)
806{
807 _Assert( _Objects_Has_string_name( information ) );
808 the_object->name.name_p = name;
809
811 information,
812 _Objects_Get_index( the_object->id ),
813 the_object
814 );
815}
816
832{
833 _RTEMS_Lock_allocator();
834}
835
844{
845 _RTEMS_Unlock_allocator();
846}
847
855{
856 return _RTEMS_Allocator_is_owner();
857}
858
875 Objects_Information *information
876)
877{
878 _Assert(
881 );
882
883 return ( *information->allocate )( information );
884}
885
931 Objects_Information *information,
932 Objects_Control *the_object
933)
934{
936 _Assert( information->deallocate != NULL );
937 ( *information->deallocate )( information, the_object );
938}
939
952 Objects_Maximum index,
953 Objects_Maximum objects_per_block
954)
955{
956 return index >= objects_per_block;
957}
958
969 Objects_Information *information,
970 Objects_Control *the_object
971)
972{
973 Objects_Maximum objects_per_block;
974 Objects_Maximum index;
975
976 _Assert( _Objects_Is_auto_extend( information ) );
977
978 objects_per_block = information->objects_per_block;
979 index = _Objects_Get_index( the_object->id ) - OBJECTS_INDEX_MINIMUM;
980
981 if ( _Objects_Is_in_allocated_block( index, objects_per_block ) ) {
982 Objects_Maximum block;
983
984 block = index / objects_per_block;
985
986 information->inactive_per_block[ block ]--;
987 information->inactive--;
988 }
989}
990
1001 Objects_Information *information,
1002 void ( *extend )( Objects_Information * )
1003)
1004{
1005 Objects_Control *the_object;
1006
1007 _Assert( _Objects_Is_auto_extend( information ) );
1008
1009 the_object = _Objects_Get_inactive( information );
1010
1011 if ( the_object == NULL ) {
1012 ( *extend )( information );
1013 the_object = _Objects_Get_inactive( information );
1014 }
1015
1016 if ( the_object != NULL ) {
1017 _Objects_Activate_unlimited( information, the_object );
1018 }
1019
1020 return the_object;
1021}
1022
1025#ifdef __cplusplus
1026}
1027#endif
1028
1029#if defined(RTEMS_MULTIPROCESSING)
1030#include <rtems/score/objectmp.h>
1031#endif
1032
1033
1034#endif
1035/* end of include file */
API Mutex Handler API.
Information for the Assert Handler.
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:100
#define RTEMS_UNUSED
Definition: basedefs.h:174
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Get_unprotected(Chain_Control *the_chain)
Gets the first node (unprotected).
Definition: chainimpl.h:630
RTEMS_INLINE_ROUTINE void _Objects_Open(Objects_Information *information, Objects_Control *the_object, Objects_Name name)
Places the_object control pointer and object name in the Local Pointer and Local Name Tables,...
Definition: objectimpl.h:747
RTEMS_INLINE_ROUTINE bool _Objects_Has_string_name(const Objects_Information *information)
Returns if the object has a string name.
Definition: objectimpl.h:408
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:26
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
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
unsigned int _Objects_API_maximum_class(uint32_t api)
Returns highest numeric value of a valid API for the specified API.
Definition: objectapimaximumclass.c:23
void _Objects_Shrink_information(Objects_Information *information)
Shrinks an object class information record.
Definition: objectshrinkinformation.c:77
RTEMS_INLINE_ROUTINE void _Objects_Free(Objects_Information *information, Objects_Control *the_object)
Frees an object.
Definition: objectimpl.h:930
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index(Objects_Id id)
Returns the index portion of the ID.
Definition: object.h:298
RTEMS_INLINE_ROUTINE void _Objects_Open_string(const Objects_Information *information, Objects_Control *the_object, const char *name)
Places the_object control pointer and object name in the Local Pointer and Local Name Tables,...
Definition: objectimpl.h:801
#define OBJECTS_APIS_LAST
Definition: object.h:183
RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node(Objects_Id id)
Returns the node portion of the ID.
Definition: object.h:284
RTEMS_INLINE_ROUTINE Objects_Control * _Objects_Allocate_unprotected(Objects_Information *information)
Allocates an object without locking the allocator mutex.
Definition: objectimpl.h:874
Objects_APIs
Definition: object.h:174
RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock(void)
Locks the object allocator mutex.
Definition: objectimpl.h:831
Objects_Control * _Objects_Allocate(Objects_Information *information)
Allocates an object.
Definition: objectallocate.c:42
Objects_Information **const _Objects_Information_table[OBJECTS_APIS_LAST+1]
RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock(void)
Unlocks the object allocator mutex.
Definition: objectimpl.h:843
Objects_Maximum _Objects_Active_count(const Objects_Information *information)
Returns the count of active objects.
Definition: objectactivecount.c:23
void _Objects_Close(const Objects_Information *information, Objects_Control *the_object)
Closes object.
Definition: objectclose.c:23
Objects_Name_or_id_lookup_errors _Objects_Id_to_name(Objects_Id id, Objects_Name *name)
Returns the name associated with object id.
Definition: objectidtoname.c:23
void _Objects_Free_objects_block(Objects_Information *information, Objects_Maximum block)
Free the objects block with the specified index.
Definition: objectshrinkinformation.c:25
uint32_t Objects_Id
Definition: object.h:80
bool(* Objects_Name_comparators)(void *, void *, uint16_t)
Definition: objectimpl.h:44
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 bool _Objects_Allocator_is_owner(void)
Checks if the allocator is the owner of the object allocator mutex.
Definition: objectimpl.h:854
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
#define OBJECTS_INDEX_START_BIT
Definition: object.h:92
RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid(uint32_t the_api)
Checks if the api is valid.
Definition: objectimpl.h:549
RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node(uint32_t node)
Checks if the node is of the local object.
Definition: objectimpl.h:567
Objects_Information * _Objects_Get_information_id(Objects_Id id)
Gets information of an object from an ID.
Definition: objectgetinfoid.c:24
#define OBJECTS_INDEX_MINIMUM
Definition: objectimpl.h:80
#define _Objects_Maximum_nodes
Definition: objectimpl.h:74
Objects_Control * _Objects_Get_next(Objects_Id id, const Objects_Information *information, Objects_Id *next_id_p)
Gets the next open object after the specified object identifier.
Definition: objectgetnext.c:24
void _Objects_Initialize_information(Objects_Information *information)
Initializes the specified objects information.
Definition: objectinitializeinformation.c:29
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:25
RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(const Objects_Information *information, uint32_t index, Objects_Control *the_object)
Sets the pointer to the local_table object referenced by the index.
Definition: objectimpl.h:689
RTEMS_INLINE_ROUTINE Objects_Control * _Objects_Get_inactive(Objects_Information *information)
Get an inactive object or NULL.
Definition: objectimpl.h:652
uint16_t Objects_Maximum
Definition: object.h:86
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(const Objects_Information *information)
Returns the object's objects per block.
Definition: objectimpl.h:534
RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id(Objects_Id id)
Returns the identifier with the minimum index for the specified identifier.
Definition: objectimpl.h:625
RTEMS_INLINE_ROUTINE 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: objectimpl.h:482
RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(Objects_Id left, Objects_Id right)
Checks if two object IDs are equal.
Definition: objectimpl.h:608
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Is_auto_extend(const Objects_Information *information)
Checks if the automatic object extension (unlimited objects) is enabled.
Definition: objectimpl.h:668
RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(const Objects_Information *information, Objects_Control *the_object)
Invalidates an object Id.
Definition: objectimpl.h:722
RTEMS_INLINE_ROUTINE void _Objects_Open_u32(const Objects_Information *information, Objects_Control *the_object, uint32_t name)
Places the_object control pointer and object name in the Local Pointer and Local Name Tables,...
Definition: objectimpl.h:775
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
RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(Objects_Id id RTEMS_UNUSED)
Checks if the id is of a local object.
Definition: objectimpl.h:584
RTEMS_INLINE_ROUTINE void _Objects_Activate_unlimited(Objects_Information *information, Objects_Control *the_object)
Activate the object.
Definition: objectimpl.h:968
Objects_Name_or_id_lookup_errors
Definition: objectimpl.h:203
Objects_Information * _Objects_Get_information(Objects_APIs the_api, uint16_t the_class)
Gets object information.
Definition: objectgetinfo.c:23
bool _Objects_Set_name(const Objects_Information *information, Objects_Control *the_object, const char *name)
Sets objects name.
Definition: objectsetname.c:27
RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_maximum_index(const Objects_Information *information)
Returns the maximum index of the specified object class.
Definition: objectimpl.h:639
RTEMS_INLINE_ROUTINE Objects_Control * _Objects_Allocate_with_extend(Objects_Information *information, void(*extend)(Objects_Information *))
Allocate an object and extend the objects information on demand.
Definition: objectimpl.h:1000
Objects_Maximum _Objects_Extend_information(Objects_Information *information)
Extends an object class information record.
Definition: objectextendinformation.c:32
#define _Objects_Local_node
The local MPCI node number.
Definition: object.h:347
RTEMS_INLINE_ROUTINE bool _Objects_Is_in_allocated_block(Objects_Maximum index, Objects_Maximum objects_per_block)
Returns true, if the object associated with the zero-based index is contained in an allocated block o...
Definition: objectimpl.h:951
RTEMS_INLINE_ROUTINE System_state_Codes _System_state_Get(void)
Gets the current system state.
Definition: sysstate.h:90
RTEMS_INLINE_ROUTINE bool _System_state_Is_up(System_state_Codes state)
Checks if the state is up.
Definition: sysstate.h:133
ISR Locks.
Object Handler Data Structures.
Data Associated with the Manipulation of Global RTEMS Objects.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Definition: objectdata.h:39
Objects_Id id
Definition: objectdata.h:43
Objects_Name name
Definition: objectdata.h:45
The information structure used to manage each API class of objects.
Definition: objectdata.h:176
Objects_Id maximum_id
This is the maximum valid ID of this object API class.
Definition: objectdata.h:185
Objects_Control ** local_table
This points to the table of local object control blocks.
Definition: objectdata.h:195
Chain_Control Inactive
This is the chain of inactive object control blocks.
Definition: objectdata.h:256
Objects_Maximum inactive
This is the number of object control blocks on the inactive chain.
Definition: objectdata.h:222
Objects_Maximum * inactive_per_block
This is the number of inactive object control blocks per allocation block.
Definition: objectdata.h:264
uint16_t name_length
This is the maximum length of names.
Definition: objectdata.h:247
Objects_Maximum objects_per_block
This is the number of object control blocks in an allocation block.
Definition: objectdata.h:231
Objects_Control *(* allocate)(Objects_Information *)
Allocate an object.
Definition: objectdata.h:203
void(* deallocate)(Objects_Information *, Objects_Control *)
Free an object.
Definition: objectdata.h:213
System State Handler API.
Constants and Structures Related with Thread Dispatch.
Definition: object.h:64
const char * name_p
Definition: object.h:66
uint32_t name_u32
Definition: object.h:68