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

Last change on this file was a00dff42, checked in by Sebastian Huber <sebastian.huber@…>, on Dec 12, 2019 at 5:37:01 AM

rtems: Add and use rtems_object_get_local_node()

Update #3841.

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