source: rtems/cpukit/include/rtems/score/objectimpl.h @ d24b301

5
Last change on this file since d24b301 was c389f5b7, checked in by Andreas Dachsberger <andreas.dachsberger@…>, on 04/10/19 at 08:29:08

doxygen: score: adjust doc in objectimpl.h to doxygen guidelines

Update #3706.

  • Property mode set to 100644
File size: 26.2 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSScoreObject
5 *
6 * @brief Inlined Routines in the Object Handler
7 *
8 * This include file contains the static inline implementation of all
9 * of the inlined routines in the Object Handler.
10 */
11
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
24#include <rtems/score/objectdata.h>
25#include <rtems/score/apimutex.h>
26#include <rtems/score/isrlock.h>
27#include <rtems/score/threaddispatch.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 * @addtogroup RTEMSScoreObject
35 *
36 * @{
37 */
38
39/**
40 *  Functions which compare names are prototyped like this.
41 */
42typedef bool    (*Objects_Name_comparators)(
43  void       * /* name_1 */,
44  void       * /* name_2 */,
45  uint16_t     /* length */
46);
47
48/** This macro is used to generically specify the last API index. */
49#define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_THREADS
50
51/** This macro is used to generically specify the last API index. */
52#define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS
53
54/** This macro is used to generically specify the last API index. */
55#define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_SHMS
56
57/*
58 * For fake objects, which have an object identifier, but no objects
59 * information block.
60 */
61typedef enum {
62  OBJECTS_FAKE_OBJECTS_NO_CLASS   = 0,
63  OBJECTS_FAKE_OBJECTS_SCHEDULERS = 1
64} Objects_Fake_objects_API;
65
66/**
67 *  The following is referenced to the node number of the local node.
68 */
69#if defined(RTEMS_MULTIPROCESSING)
70extern uint16_t _Objects_Local_node;
71#else
72#define _Objects_Local_node ((uint16_t)1)
73#endif
74
75/**
76 *  The following is referenced to the number of nodes in the system.
77 */
78#if defined(RTEMS_MULTIPROCESSING)
79extern uint16_t _Objects_Maximum_nodes;
80#else
81#define _Objects_Maximum_nodes 1
82#endif
83
84/**
85 * This is the minimum object ID index associated with an object.
86 */
87#define OBJECTS_INDEX_MINIMUM 1U
88
89/**
90 *  The following is the list of information blocks per API for each object
91 *  class.  From the ID, we can go to one of these information blocks,
92 *  and obtain a pointer to the appropriate object control block.
93 */
94extern Objects_Information ** const
95_Objects_Information_table[ OBJECTS_APIS_LAST + 1 ];
96
97/**
98 * @brief Extends an object class information record.
99 *
100 * @param information Points to an object class information block.
101 */
102void _Objects_Extend_information(
103  Objects_Information *information
104);
105
106/**
107 * @brief Shrinks an object class information record.
108 *
109 * This function shrinks an object class information record.
110 * The object's name and object space are released. The local_table
111 * etc block does not shrink. The InActive list needs to be scanned
112 * to find the objects are remove them.
113 *
114 * @param information Points to an object class information block.
115 */
116void _Objects_Shrink_information(
117  Objects_Information *information
118);
119
120/**
121 * @brief Initializes the specified objects information.
122 *
123 * The objects information must be statically pre-initialized with the
124 * OBJECTS_INFORMATION_DEFINE() macro before this function is called.
125 *
126 * @param information The object information to be initialized.
127 */
128void _Objects_Initialize_information( Objects_Information *information );
129
130/**
131 * @brief Returns highest numeric value of a valid API for the specified API.
132 *
133 * This function returns the highest numeric value of a valid
134 * API for the specified @a api.
135 *
136 * @param api The API of interest.
137 *
138 * @retval some_value Positive integer on success.
139 * @retval 0 The method failed.
140 */
141unsigned int _Objects_API_maximum_class(
142  uint32_t api
143);
144
145/**
146 * @brief Allocates an object without locking the allocator mutex.
147 *
148 * This function can be called in two contexts
149 * - the executing thread is the owner of the object allocator mutex, or
150 * - in case the system state is not up, e.g. during sequential system
151 *   initialization.
152 *
153 * @param[in, out] information The object information block.
154 *
155 * @retval object The allocated object.
156 * @retval NULL No object available.
157 *
158 * @see _Objects_Allocate() and _Objects_Free().
159 */
160Objects_Control *_Objects_Allocate_unprotected(
161  Objects_Information *information
162);
163
164/**
165 * @brief Allocates an object.
166 *
167 * This function locks the object allocator mutex via
168 * _Objects_Allocator_lock().  The caller must later unlock the object
169 * allocator mutex via _Objects_Allocator_unlock().  The caller must unlock the
170 * mutex in any case, even if the allocation failed due to resource shortage.
171 *
172 * A typical object allocation code looks like this:
173 * @code
174 * rtems_status_code some_create( rtems_id *id )
175 * {
176 *   rtems_status_code  sc;
177 *   Some_Control      *some;
178 *
179 *   // The object allocator mutex protects the executing thread from
180 *   // asynchronous thread restart and deletion.
181 *   some = (Some_Control *) _Objects_Allocate( &_Some_Information );
182 *
183 *   if ( some != NULL ) {
184 *     _Some_Initialize( some );
185 *     sc = RTEMS_SUCCESSFUL;
186 *   } else {
187 *     sc = RTEMS_TOO_MANY;
188 *   }
189 *
190 *   _Objects_Allocator_unlock();
191 *
192 *   return sc;
193 * }
194 * @endcode
195 *
196 * @param[in, out] information The object information block.
197 *
198 * @retval object The allocated object.
199 * @retval NULL No object available.
200 *
201 * @see _Objects_Free().
202 */
203Objects_Control *_Objects_Allocate( Objects_Information *information );
204
205/**
206 * @brief Frees an object.
207 *
208 * Appends the object to the chain of inactive objects.
209 *
210 * @param information The object information block.
211 * @param[out] the_object The object to free.
212 *
213 * @see _Objects_Allocate().
214 *
215 * A typical object deletion code looks like this:
216 * @code
217 * rtems_status_code some_delete( rtems_id id )
218 * {
219 *   Some_Control      *some;
220 *
221 *   // The object allocator mutex protects the executing thread from
222 *   // asynchronous thread restart and deletion.
223 *   _Objects_Allocator_lock();
224 *
225 *   // Get the object under protection of the object allocator mutex.
226 *   some = (Semaphore_Control *)
227 *     _Objects_Get_no_protection( id, &_Some_Information );
228 *
229 *   if ( some == NULL ) {
230 *     _Objects_Allocator_unlock();
231 *     return RTEMS_INVALID_ID;
232 *   }
233 *
234 *   // After the object close an object get with this identifier will
235 *   // fail.
236 *   _Objects_Close( &_Some_Information, &some->Object );
237 *
238 *   _Some_Delete( some );
239 *
240 *   // Thread dispatching is enabled.  The object free is only protected
241 *   // by the object allocator mutex.
242 *   _Objects_Free( &_Some_Information, &some->Object );
243 *
244 *   _Objects_Allocator_unlock();
245 *   return RTEMS_SUCCESSFUL;
246 * }
247 * @endcode
248 */
249void _Objects_Free(
250  Objects_Information *information,
251  Objects_Control     *the_object
252);
253
254/**
255 *  This function implements the common portion of the object
256 *  identification directives.  This directive returns the object
257 *  id associated with name.  If more than one object of this class
258 *  is named name, then the object to which the id belongs is
259 *  arbitrary.  Node indicates the extent of the search for the
260 *  id of the object named name.  If the object class supports global
261 *  objects, then the search can be limited to a particular node
262 *  or allowed to encompass all nodes.
263 */
264typedef enum {
265  OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL,
266  OBJECTS_INVALID_NAME,
267  OBJECTS_INVALID_ADDRESS,
268  OBJECTS_INVALID_ID,
269  OBJECTS_INVALID_NODE
270} Objects_Name_or_id_lookup_errors;
271
272/**
273 *  This macro defines the first entry in the
274 *  @ref Objects_Name_or_id_lookup_errors enumerated list.
275 */
276#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL
277
278/**
279 *  This macro defines the last entry in the
280 *  @ref Objects_Name_or_id_lookup_errors enumerated list.
281 */
282#define OBJECTS_NAME_ERRORS_LAST  OBJECTS_INVALID_NODE
283
284/**
285 * @brief Converts an object name to an Id.
286 *
287 * This method converts an object name to an Id.  It performs a look up
288 * using the object information block for this object class.
289 *
290 * @param information points to an object class information block.
291 * @param name is the name of the object to find.
292 * @param node is the set of nodes to search.
293 * @param[out] id will contain the Id if the search is successful.
294 *
295 * @retval OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL The operations was successful
296 *      @a id contains the ID.
297 * @retval OBJECTS_INVALID_NAME The name was invalid.
298 * @retval OBJECTS_INVALID_ID The id is not 0 before the operation.
299 */
300Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
301  Objects_Information *information,
302  uint32_t             name,
303  uint32_t             node,
304  Objects_Id          *id
305);
306
307typedef enum {
308  OBJECTS_GET_BY_NAME_INVALID_NAME,
309  OBJECTS_GET_BY_NAME_NAME_TOO_LONG,
310  OBJECTS_GET_BY_NAME_NO_OBJECT
311} Objects_Get_by_name_error;
312
313/**
314 * @brief Gets an object control block identified by its name.
315 *
316 * The object information must use string names.
317 *
318 * @param information The object information.  Must not be NULL.
319 * @param name The object name.
320 * @param[out] name_length_p Optional parameter to return the name length.
321 * @param[out] error The error indication in case of failure.  Must not be NULL.
322 *
323 * @retval pointer The first object according to object index associated with
324 *      this name.
325 * @retval NULL No object exists for this name or invalid parameters.
326 */
327Objects_Control *_Objects_Get_by_name(
328  const Objects_Information *information,
329  const char                *name,
330  size_t                    *name_length_p,
331  Objects_Get_by_name_error *error
332);
333
334/**
335 * @brief Returns the name associated with object id.
336 *
337 * This function implements the common portion of the object Id
338 * to name directives.  This function returns the name
339 * associated with object id.
340 *
341 * @param id is the Id of the object whose name we are locating.
342 * @param[out] name will contain the name of the object, if found.
343 *
344 * @retval OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL The operation succeeded.  @a name
345 *      contains the name of the object.
346 * @retval OBJECTS_INVALID_ID The id is invalid, the operation failed.
347 *
348 * @note This function currently does not support string names.
349 */
350Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
351  Objects_Id      id,
352  Objects_Name   *name
353);
354
355/**
356 * @brief Maps the specified object identifier to the associated local object
357 * control block.
358 *
359 * In this function interrupts are disabled during the object lookup.  In case
360 * an associated object exists, then interrupts remain disabled, otherwise the
361 * previous interrupt state is restored.
362 *
363 * @param id The object identifier.  This is the first parameter since usual
364 *      callers get the object identifier as the first parameter themself.
365 * @param lock_context The interrupt lock context.  This is the second
366 *      parameter since usual callers get the interrupt lock context as the second
367 *      parameter themself.
368 * @param information The object class information block.
369 *
370 * @retval pointer The pointer to the associated object control block.
371 *      Interrupts are now disabled and must be restored using the specified lock
372 *      context via _ISR_lock_ISR_enable() or _ISR_lock_Release_and_ISR_enable().
373 * @retval NULL No associated object exists.
374 */
375Objects_Control *_Objects_Get(
376  Objects_Id                 id,
377  ISR_lock_Context          *lock_context,
378  const Objects_Information *information
379);
380
381/**
382 * @brief  Maps object ids to object control blocks.
383 *
384 * This function maps object ids to object control blocks.
385 * If id corresponds to a local object, then it returns
386 * the_object control pointer which maps to id and location
387 * is set to OBJECTS_LOCAL.  If the object class supports global
388 * objects and the object id is global and resides on a remote
389 * node, then location is set to OBJECTS_REMOTE, and the_object
390 * is undefined.  Otherwise, location is set to OBJECTS_ERROR
391 * and the_object is undefined.
392 *
393 * @param id The Id of the object whose name we are locating.
394 *   This is the first parameter since usual callers get the object identifier
395 *   as the first parameter themself.
396 * @param information Points to an object class information block.
397 *
398 * @retval pointer The local object corresponding to the given id.
399 * @retval NULL The object to the given id was not found locally.
400 */
401Objects_Control *_Objects_Get_no_protection(
402  Objects_Id                 id,
403  const Objects_Information *information
404);
405
406/**
407 * @brief Gets the next open object after the specified object identifier.
408 *
409 * Locks the object allocator mutex in case a next object exists.
410 *
411 * @param id The Id of the object whose name we are locating.
412 *   This is the first parameter since usual callers get the object identifier
413 *   as the first parameter themself.
414 * @param information Points to an object class information block.
415 * @param[in, out] next_id_p The Id of the next object we will look at.
416 *
417 * @retval pointer Pointer to the located object.
418 * @retval NULL An error occured.
419 */
420Objects_Control *_Objects_Get_next(
421  Objects_Id                 id,
422  const Objects_Information *information,
423  Objects_Id                *next_id_p
424);
425
426/**
427 * @brief Gets object information.
428 *
429 * This function returns the information structure given
430 * an API and Class.  This can be done independent of the
431 * existence of any objects created by the API.
432 *
433 * @param the_api Indicates the API for the information we want
434 * @param the_class Indicates the Class for the information we want
435 *
436 * @retval pointer Pointer to the Object Information Table
437 *         for the class of objects which corresponds to this object ID.
438 * @retval NULL An error occured.
439 */
440Objects_Information *_Objects_Get_information(
441  Objects_APIs   the_api,
442  uint16_t       the_class
443);
444
445/**
446 * @brief Gets information of an object from an ID.
447 *
448 * This function returns the information structure given
449 * an @a id of an object.
450 *
451 * @param id The object ID to get the information from.
452 *
453 * @retval pointer Pointer to the Object Information Table
454 *         for the class of objects which corresponds to this object ID.
455 * @retval NULL An error occured.
456 */
457Objects_Information *_Objects_Get_information_id(
458  Objects_Id  id
459);
460
461/**
462 * @brief Gets object name in the form of a C string.
463 *
464 * This method gets the name of an object and returns its name
465 * in the form of a C string.  It attempts to be careful about
466 * overflowing the user's string and about returning unprintable characters.
467 *
468 * @param id The object to obtain the name of.
469 * @param length Indicates the length of the caller's buffer.
470 * @param[out] name A string which will be filled in.
471 *
472 * @retval @a name The operation was succeeded and the string was correctly filled in.
473 * @retval NULL An error occured.
474 */
475char *_Objects_Get_name_as_string(
476  Objects_Id   id,
477  size_t       length,
478  char        *name
479);
480
481/**
482 * @brief Converts the specified object name to a text representation.
483 *
484 * Non-printable characters according to isprint() are converted to '*'.
485 *
486 * @param name The object name.
487 * @param is_string Indicates if the object name is a string or a four
488 *   character array (32-bit unsigned integer).
489 * @param[out] buffer The string buffer for the text representation.
490 * @param buffer_size The buffer size in characters.
491 *
492 * @return The length of the text representation.  May be greater than or equal
493 * to the buffer size if truncation occurred.
494 */
495size_t _Objects_Name_to_string(
496  Objects_Name  name,
497  bool          is_string,
498  char         *buffer,
499  size_t        buffer_size
500);
501
502/**
503 * @brief Sets objects name.
504 *
505 * This method sets the object name to either a copy of a string
506 * or up to the first four characters of the string based upon
507 * whether this object class uses strings for names.
508 *
509 * @param information points to the object information structure
510 * @param[out] the_object is the object to operate upon
511 * @param name is a pointer to the name to use
512 *
513 * @retval true The operation succeeded.
514 * @retval false The operation failed.
515 */
516bool _Objects_Set_name(
517  const Objects_Information *information,
518  Objects_Control           *the_object,
519  const char                *name
520);
521
522/**
523 * @brief Removes object with a 32-bit integer name from its namespace.
524 *
525 * @param information The corresponding object information table.
526 * @param[out] the_object The object to operate upon.
527 */
528void _Objects_Namespace_remove_u32(
529  const Objects_Information *information,
530  Objects_Control           *the_object
531);
532
533/**
534 * @brief Removes object with a string name from its namespace.
535 *
536 * @param information The corresponding object information table.
537 * @param[out] the_object The object the object to operate upon.
538 */
539void _Objects_Namespace_remove_string(
540  const Objects_Information *information,
541  Objects_Control           *the_object
542);
543
544/**
545 * @brief Closes object.
546 *
547 * This function removes the_object control pointer and object name
548 * in the Local Pointer and Local Name Tables.
549 *
550 * @param information Points to an Object Information Table.
551 * @param[out] the_object A pointer to an object.
552 */
553void _Objects_Close(
554  const Objects_Information *information,
555  Objects_Control           *the_object
556);
557
558/**
559 * @brief Returns the count of active objects.
560 *
561 * @param information The object information table.
562 *
563 * @return The count of active objects.
564 */
565Objects_Maximum _Objects_Active_count(
566  const Objects_Information *information
567);
568
569/**
570 * @brief Returns if the object has a string name.
571 *
572 * @param information The object information table.
573 *
574 * @retval true The object has a string name.
575 * @retval false The object does not have a string name.
576 */
577RTEMS_INLINE_ROUTINE bool _Objects_Has_string_name(
578  const Objects_Information *information
579)
580{
581  return information->name_length > 0;
582}
583
584/**
585 * @brief Returns the object's objects per block.
586 *
587 * @param information The object information table.
588 *
589 * @return The number of objects per block of @a information.
590 */
591RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size(
592  const Objects_Information *information
593)
594{
595  return information->objects_per_block;
596}
597
598/**
599 * @brief Checks if the api is valid.
600 *
601 * @param the_api is the api portion of an object ID.
602 *
603 * @retval true The specified api value is valid.
604 * @retval false The specified api value is not valid.
605 */
606RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid(
607  uint32_t   the_api
608)
609{
610  if ( !the_api || the_api > OBJECTS_APIS_LAST )
611   return false;
612  return true;
613}
614
615/**
616 * @brief Checks if the node is of the local object.
617 *
618 * @param node The node number and corresponds to the node number
619 *        portion of an object ID.
620 *
621 * @retval true The specified node is the local node.
622 * @retval false The specified node is not the local node.
623 */
624RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node(
625  uint32_t   node
626)
627{
628  return ( node == _Objects_Local_node );
629}
630
631/**
632 * @brief Checks if the id is of a local object.
633 *
634 * @param id The object ID.
635 *
636 * @retval true The specified object Id is local.
637 * @retval false The specified object Id is not local.
638 *
639 * @note On a single processor configuration, this always returns true.
640 */
641RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(
642#if defined(RTEMS_MULTIPROCESSING)
643  Objects_Id id
644#else
645  Objects_Id id RTEMS_UNUSED
646#endif
647)
648{
649#if defined(RTEMS_MULTIPROCESSING)
650  return _Objects_Is_local_node( _Objects_Get_node(id) );
651#else
652  return true;
653#endif
654}
655
656/**
657 * @brief Checks if two object IDs are equal.
658 *
659 * @param left The Id on the left hand side of the comparison.
660 * @param right The Id on the right hand side of the comparison.
661 *
662 * @retval true The specified object IDs are equal.
663 * @retval false The specified object IDs are not equal.
664 */
665RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(
666  Objects_Id left,
667  Objects_Id right
668)
669{
670  return ( left == right );
671}
672
673/**
674 * @brief Returns the identifier with the minimum index for the specified identifier.
675 *
676 * The specified identifier must have valid API, class and node fields.
677 *
678 * @param id The identifier to be processed.
679 *
680 * @return The corresponding ID with the minimum index.
681 */
682RTEMS_INLINE_ROUTINE Objects_Id _Objects_Get_minimum_id( Objects_Id id )
683{
684  id &= ~OBJECTS_INDEX_MASK;
685  id += (Objects_Id) OBJECTS_INDEX_MINIMUM << OBJECTS_INDEX_START_BIT;
686  return id;
687}
688
689/**
690 * @brief Returns the maximum index of the specified object class.
691 *
692 * @param information The object information.
693 *
694 * @return The maximum index of the specified object class.
695 */
696RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_maximum_index(
697  const Objects_Information *information
698)
699{
700  return _Objects_Get_index( information->maximum_id );
701}
702
703/**
704 * @brief Checks if the automatic object extension (unlimited objects) is
705 * enabled.
706 *
707 * @param information The object information.
708 *
709 * @retval true The automatic object extension (unlimited objects) is enabled.
710 * @retval false The automatic object extension (unlimited objects) is not enabled.
711 */
712RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Is_auto_extend(
713  const Objects_Information *information
714)
715{
716  return information->objects_per_block != 0;
717}
718
719/**
720 * @brief Sets the pointer to the local_table object
721 * referenced by the index.
722 *
723 * @param[in, out] information Points to an Object Information Table.
724 * @param index The index of the object the caller wants to access.
725 * @param the_object The local object pointer.
726 *
727 * @note This routine is ONLY to be called in places where the
728 *       index portion of the Id is known to be good.  This is
729 *       OK since it is normally called from object create/init
730 *       or delete/destroy operations.
731 */
732
733RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
734  const Objects_Information *information,
735  uint32_t                   index,
736  Objects_Control           *the_object
737)
738{
739  /*
740   *  This routine is ONLY to be called from places in the code
741   *  where the Id is known to be good.  Therefore, this should NOT
742   *  occur in normal situations.
743   */
744  _Assert( index >= OBJECTS_INDEX_MINIMUM );
745  _Assert( index <= _Objects_Get_maximum_index( information ) );
746
747  information->local_table[ index - OBJECTS_INDEX_MINIMUM ] = the_object;
748}
749
750/**
751 * @brief Invalidates an object Id.
752 *
753 * This function sets the pointer to the local_table object
754 * referenced by the index to NULL so the object Id is invalid
755 * after this call.
756 *
757 * @param[in, out] information points to an Object Information Table.
758 * @param the_object The local object pointer.
759 *
760 * @note This routine is ONLY to be called in places where the
761 *       index portion of the Id is known to be good.  This is
762 *       OK since it is normally called from object create/init
763 *       or delete/destroy operations.
764 */
765
766RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(
767  const Objects_Information *information,
768  Objects_Control           *the_object
769)
770{
771  _Assert( information != NULL );
772  _Assert( the_object != NULL );
773
774  _Objects_Set_local_object(
775    information,
776    _Objects_Get_index( the_object->id ),
777    NULL
778  );
779}
780
781/**
782 * @brief Places the_object control pointer and object name
783 *      in the Local Pointer and Local Name Tables, respectively.
784 *
785 * This method uses Objects_Name for the object name.
786 *
787 * @param[in, out] information Points to an Object Information Table.
788 * @param the_object Pointer to an object.
789 * @param name The name of the object to make accessible.
790 */
791RTEMS_INLINE_ROUTINE void _Objects_Open(
792  Objects_Information *information,
793  Objects_Control     *the_object,
794  Objects_Name         name
795)
796{
797  _Assert( information != NULL );
798  _Assert( the_object != NULL );
799
800  the_object->name = name;
801
802  _Objects_Set_local_object(
803    information,
804    _Objects_Get_index( the_object->id ),
805    the_object
806  );
807}
808
809/**
810 * @brief Places the_object control pointer and object name
811 *      in the Local Pointer and Local Name Tables, respectively.
812 *
813 * This method uses uint32_t for the object name.
814 *
815 * @param[in, out] information Points to an Object Information Table.
816 * @param the_object Pointer to an object.
817 * @param name The name of the object to make accessible.
818 */
819RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
820  const Objects_Information *information,
821  Objects_Control           *the_object,
822  uint32_t                   name
823)
824{
825  _Assert( !_Objects_Has_string_name( information ) );
826  the_object->name.name_u32 = name;
827
828  _Objects_Set_local_object(
829    information,
830    _Objects_Get_index( the_object->id ),
831    the_object
832  );
833}
834
835/**
836 * @brief Places the_object control pointer and object name
837 *      in the Local Pointer and Local Name Tables, respectively.
838 *
839 * This method uses a String for the object name.
840 *
841 * @param[in, out] information Points to an Object Information Table.
842 * @param the_object Pointer to an object.
843 * @param name The name of the object to make accessible.
844 */
845RTEMS_INLINE_ROUTINE void _Objects_Open_string(
846  const Objects_Information *information,
847  Objects_Control           *the_object,
848  const char                *name
849)
850{
851  _Assert( _Objects_Has_string_name( information ) );
852  the_object->name.name_p = name;
853
854  _Objects_Set_local_object(
855    information,
856    _Objects_Get_index( the_object->id ),
857    the_object
858  );
859}
860
861/**
862 * @brief Locks the object allocator mutex.
863 *
864 * While holding the allocator mutex the executing thread is protected from
865 * asynchronous thread restart and deletion.
866 *
867 * The usage of the object allocator mutex with the thread life protection
868 * makes it possible to allocate and free objects without thread dispatching
869 * disabled.  The usage of a unified workspace and unlimited objects may lead
870 * to heap fragmentation.  Thus the execution time of the _Objects_Allocate()
871 * function may increase during system run-time.
872 *
873 * @see _Objects_Allocator_unlock() and _Objects_Allocate().
874 */
875RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock( void )
876{
877  _RTEMS_Lock_allocator();
878}
879
880/**
881 * @brief Unlocks the object allocator mutex.
882 *
883 * In case the mutex is fully unlocked, then this function restores the
884 * previous thread life protection state and thus may not return if the
885 * executing thread was restarted or deleted in the mean-time.
886 */
887RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock( void )
888{
889  _RTEMS_Unlock_allocator();
890}
891
892/**
893 * @brief Checks if the allocator is the owner of the object allocator mutex
894 *
895 * @retval true The allocator is the owner of the object allocator mutex.
896 * @retval false The allocato is not the owner of the object allocator mutex.
897 */
898RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void )
899{
900  return _RTEMS_Allocator_is_owner();
901}
902
903/** @} */
904
905#ifdef __cplusplus
906}
907#endif
908
909#if defined(RTEMS_MULTIPROCESSING)
910#include <rtems/score/objectmp.h>
911#endif
912
913
914#endif
915/* end of include file */
Note: See TracBrowser for help on using the repository browser.