source: rtems/cpukit/score/include/rtems/score/objectimpl.h @ 3a7628e8

4.11
Last change on this file since 3a7628e8 was 3a7628e8, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 15, 2013 at 2:38:52 PM

score: Objects_Information::extract visibility

This filed is only used if RTEMS_MULTIPROCESSING is defined.

  • Property mode set to 100644
File size: 28.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines in the Object Handler
5 *
6 * This include file contains the static inline implementation of all
7 * of the inlined routines in the Object Handler.
8 */
9
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.com/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_OBJECTIMPL_H
20#define _RTEMS_SCORE_OBJECTIMPL_H
21
22#include <rtems/score/object.h>
23#include <rtems/score/isrlevel.h>
24#include <rtems/score/threaddispatch.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @addtogroup ScoreObject
32 *
33 * @{
34 */
35
36/**
37 *  Functions which compare names are prototyped like this.
38 */
39typedef bool    (*Objects_Name_comparators)(
40  void       * /* name_1 */,
41  void       * /* name_2 */,
42  uint16_t     /* length */
43);
44
45/**
46 *  This enumerated type is used in the class field of the object ID
47 *  for RTEMS internal object classes.
48 */
49typedef enum {
50  OBJECTS_INTERNAL_NO_CLASS =  0,
51  OBJECTS_INTERNAL_THREADS  =  1,
52  OBJECTS_INTERNAL_MUTEXES  =  2
53} Objects_Internal_API;
54
55/** This macro is used to generically specify the last API index. */
56#define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_MUTEXES
57
58/**
59 *  This enumerated type is used in the class field of the object ID
60 *  for the RTEMS Classic API.
61 */
62typedef enum {
63  OBJECTS_CLASSIC_NO_CLASS     = 0,
64  OBJECTS_RTEMS_TASKS          = 1,
65  OBJECTS_RTEMS_TIMERS         = 2,
66  OBJECTS_RTEMS_SEMAPHORES     = 3,
67  OBJECTS_RTEMS_MESSAGE_QUEUES = 4,
68  OBJECTS_RTEMS_PARTITIONS     = 5,
69  OBJECTS_RTEMS_REGIONS        = 6,
70  OBJECTS_RTEMS_PORTS          = 7,
71  OBJECTS_RTEMS_PERIODS        = 8,
72  OBJECTS_RTEMS_EXTENSIONS     = 9,
73  OBJECTS_RTEMS_BARRIERS       = 10
74} Objects_Classic_API;
75
76/** This macro is used to generically specify the last API index. */
77#define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS
78
79/**
80 *  This enumerated type is used in the class field of the object ID
81 *  for the POSIX API.
82 */
83typedef enum {
84  OBJECTS_POSIX_NO_CLASS            = 0,
85  OBJECTS_POSIX_THREADS             = 1,
86  OBJECTS_POSIX_KEYS                = 2,
87  OBJECTS_POSIX_INTERRUPTS          = 3,
88  OBJECTS_POSIX_MESSAGE_QUEUE_FDS   = 4,
89  OBJECTS_POSIX_MESSAGE_QUEUES      = 5,
90  OBJECTS_POSIX_MUTEXES             = 6,
91  OBJECTS_POSIX_SEMAPHORES          = 7,
92  OBJECTS_POSIX_CONDITION_VARIABLES = 8,
93  OBJECTS_POSIX_TIMERS              = 9,
94  OBJECTS_POSIX_BARRIERS            = 10,
95  OBJECTS_POSIX_SPINLOCKS           = 11,
96  OBJECTS_POSIX_RWLOCKS             = 12
97} Objects_POSIX_API;
98
99/** This macro is used to generically specify the last API index. */
100#define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_RWLOCKS
101
102/**
103 *  This enumerated type lists the locations which may be returned
104 *  by _Objects_Get.  These codes indicate the success of locating
105 *  an object with the specified ID.
106 */
107typedef enum {
108#if defined(RTEMS_MULTIPROCESSING)
109  OBJECTS_REMOTE = 2,         /* object is remote */
110#endif
111  OBJECTS_LOCAL  = 0,         /* object is local */
112  OBJECTS_ERROR  = 1          /* id was invalid */
113} Objects_Locations;
114
115/**
116 *  The following type defines the callout used when a local task
117 *  is extracted from a remote thread queue (i.e. it's proxy must
118 *  extracted from the remote queue).
119 */
120typedef void ( *Objects_Thread_queue_Extract_callout )( void * );
121
122/**
123 *  The following defines the structure for the information used to
124 *  manage each class of objects.
125 */
126typedef struct {
127  /** This field indicates the API of this object class. */
128  Objects_APIs      the_api;
129  /** This is the class of this object set. */
130  uint16_t          the_class;
131  /** This is the minimum valid id of this object class. */
132  Objects_Id        minimum_id;
133  /** This is the maximum valid id of this object class. */
134  Objects_Id        maximum_id;
135  /** This is the maximum number of objects in this class. */
136  Objects_Maximum   maximum;
137  /** This is the true if unlimited objects in this class. */
138  bool              auto_extend;
139  /** This is the number of objects in a block. */
140  Objects_Maximum   allocation_size;
141  /** This is the size in bytes of each object instance. */
142  size_t            size;
143  /** This points to the table of local objects. */
144  Objects_Control **local_table;
145  /** This is the chain of inactive control blocks. */
146  Chain_Control     Inactive;
147  /** This is the number of objects on the Inactive list. */
148  Objects_Maximum   inactive;
149  /** This is the number of inactive objects per block. */
150  uint32_t         *inactive_per_block;
151  /** This is a table to the chain of inactive object memory blocks. */
152  void            **object_blocks;
153  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
154    /** This is true if names are strings. */
155    bool              is_string;
156  #endif
157  /** This is the maximum length of names. */
158  uint16_t          name_length;
159  #if defined(RTEMS_MULTIPROCESSING)
160    /** This is this object class' method called when extracting a thread. */
161    Objects_Thread_queue_Extract_callout extract;
162    /** This is this object class' pointer to the global name table */
163    Chain_Control    *global_table;
164  #endif
165}   Objects_Information;
166
167/**
168 *  The following is referenced to the node number of the local node.
169 */
170#if defined(RTEMS_MULTIPROCESSING)
171SCORE_EXTERN uint16_t       _Objects_Local_node;
172#else
173#define _Objects_Local_node ((uint16_t)1)
174#endif
175
176/**
177 *  The following is referenced to the number of nodes in the system.
178 */
179#if defined(RTEMS_MULTIPROCESSING)
180SCORE_EXTERN uint16_t    _Objects_Maximum_nodes;
181#else
182#define _Objects_Maximum_nodes 1
183#endif
184
185/**
186 *  The following is the list of information blocks per API for each object
187 *  class.  From the ID, we can go to one of these information blocks,
188 *  and obtain a pointer to the appropriate object control block.
189 */
190SCORE_EXTERN Objects_Information
191    **_Objects_Information_table[OBJECTS_APIS_LAST + 1];
192
193/**
194 *  This function extends an object class information record.
195 *
196 *  @param[in] information points to an object class information block.
197 */
198void _Objects_Extend_information(
199  Objects_Information *information
200);
201
202/**
203 *  @brief Shrink an object class information record
204 *
205 *  This function shrink an object class information record.
206 *  The object's name and object space are released. The local_table
207 *  etc block does not shrink. The InActive list needs to be scanned
208 *  to find the objects are remove them.
209 *
210 *  @param[in] information points to an object class information block.
211 */
212void _Objects_Shrink_information(
213  Objects_Information *information
214);
215
216/**
217 *  @brief Initialize object Information
218 *
219 *  This function initializes an object class information record.
220 *  SUPPORTS_GLOBAL is true if the object class supports global
221 *  objects, and false otherwise.  Maximum indicates the number
222 *  of objects required in this class and size indicates the size
223 *  in bytes of each control block for this object class.  The
224 *  name length and string designator are also set.  In addition,
225 *  the class may be a task, therefore this information is also included.
226 *
227 *  @param[in] information points to an object class information block.
228 *  @param[in] the_api indicates the API associated with this information block.
229 *  @param[in] the_class indicates the class of object being managed
230 *             by this information block.  It is specific to @a the_api.
231 *  @param[in] maximum is the maximum number of instances of this object
232 *             class which may be concurrently active.
233 *  @param[in] size is the size of the data structure for this class.
234 *  @param[in] is_string is true if this object uses string style names.
235 *  @param[in] maximum_name_length is the maximum length of object names.
236 */
237void _Objects_Initialize_information (
238  Objects_Information *information,
239  Objects_APIs         the_api,
240  uint16_t             the_class,
241  uint32_t             maximum,
242  uint16_t             size,
243  bool                 is_string,
244  uint32_t             maximum_name_length
245#if defined(RTEMS_MULTIPROCESSING)
246  ,
247  bool                 supports_global,
248  Objects_Thread_queue_Extract_callout extract
249#endif
250);
251
252/**
253 *  @brief Object API Maximum Class
254 *
255 *  This function returns the highest numeric value of a valid
256 *  API for the specified @a api.
257 *
258 *  @param[in] api is the API of interest
259 *
260 *  @retval A positive integer on success and 0 otherwise.
261 */
262unsigned int _Objects_API_maximum_class(
263  uint32_t api
264);
265
266/**
267 *  @brief Allocate an object.
268 *
269 *  This function allocates an object control block from
270 *  the inactive chain of free object control blocks.
271 *
272 *  @param[in] information points to an object class information block.
273 */
274Objects_Control *_Objects_Allocate(
275  Objects_Information *information
276);
277
278/**
279 *  @brief Free an object.
280 *
281 *  This function frees an object control block to the
282 *  inactive chain of free object control blocks.
283 *
284 *  @param[in] information points to an object class information block.
285 *  @param[in] the_object points to the object to deallocate.
286 */
287void _Objects_Free(
288  Objects_Information *information,
289  Objects_Control     *the_object
290);
291
292/**
293 *  This function implements the common portion of the object
294 *  identification directives.  This directive returns the object
295 *  id associated with name.  If more than one object of this class
296 *  is named name, then the object to which the id belongs is
297 *  arbitrary.  Node indicates the extent of the search for the
298 *  id of the object named name.  If the object class supports global
299 *  objects, then the search can be limited to a particular node
300 *  or allowed to encompass all nodes.
301 */
302typedef enum {
303  OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL,
304  OBJECTS_INVALID_NAME,
305  OBJECTS_INVALID_ADDRESS,
306  OBJECTS_INVALID_ID,
307  OBJECTS_INVALID_NODE
308} Objects_Name_or_id_lookup_errors;
309
310/**
311 *  This macro defines the first entry in the
312 *  @ref Objects_Name_or_id_lookup_errors enumerated list.
313 */
314#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL
315
316/**
317 *  This macro defines the last entry in the
318 *  @ref Objects_Name_or_id_lookup_errors enumerated list.
319 */
320#define OBJECTS_NAME_ERRORS_LAST  OBJECTS_INVALID_NODE
321
322/**
323 *  @brief Converts an object name to an Id.
324 *
325 *  This method converts an object name to an Id.  It performs a look up
326 *  using the object information block for this object class.
327 *
328 *  @param[in] information points to an object class information block.
329 *  @param[in] name is the name of the object to find.
330 *  @param[in] node is the set of nodes to search.
331 *  @param[in] id will contain the Id if the search is successful.
332 *
333 *  @retval This method returns one of the values from the
334 *          @ref Objects_Name_or_id_lookup_errors enumeration to indicate
335 *          successful or failure.  On success @a id will contain the Id of
336 *          the requested object.
337 */
338Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32(
339  Objects_Information *information,
340  uint32_t             name,
341  uint32_t             node,
342  Objects_Id          *id
343);
344
345#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
346/**
347 *  @brief Converts an object name to an Id.
348 *
349 *  This method converts an object name to an Id.  It performs a look up
350 *  using the object information block for this object class.
351 *
352 *  @param[in] information points to an object class information block.
353 *  @param[in] name is the name of the object to find.
354 *  @param[in] id will contain the Id if the search is successful.
355 *
356 *  @retval This method returns one of the values from the
357 *          @ref Objects_Name_or_id_lookup_errors enumeration to indicate
358 *          successful or failure.  On success @a id will contain the Id of
359 *          the requested object.
360 */
361Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string(
362  Objects_Information *information,
363  const char          *name,
364  Objects_Id          *id
365);
366#endif
367
368/**
369 *  @brief Implements the common portion of the object Id to name directives.
370 *
371 *  This function implements the common portion of the object Id
372 *  to name directives.  This function returns the name
373 *  associated with object id.
374 *
375 *  @param[in] id is the Id of the object whose name we are locating.
376 *  @param[in] name will contain the name of the object, if found.
377 *
378 *  @retval This method returns one of the values from the
379 *          @ref Objects_Name_or_id_lookup_errors enumeration to indicate
380 *          successful or failure.  On success @a name will contain the name of
381 *          the requested object.
382 *
383 *  @note This function currently does not support string names.
384 */
385Objects_Name_or_id_lookup_errors _Objects_Id_to_name (
386  Objects_Id      id,
387  Objects_Name   *name
388);
389
390/**
391 *  @brief Maps object ids to object control blocks.
392 *
393 *  This function maps object ids to object control blocks.
394 *  If id corresponds to a local object, then it returns
395 *  the_object control pointer which maps to id and location
396 *  is set to OBJECTS_LOCAL.  If the object class supports global
397 *  objects and the object id is global and resides on a remote
398 *  node, then location is set to OBJECTS_REMOTE, and the_object
399 *  is undefined.  Otherwise, location is set to OBJECTS_ERROR
400 *  and the_object is undefined.
401 *
402 *  @param[in] information points to an object class information block.
403 *  @param[in] id is the Id of the object whose name we are locating.
404 *  @param[in] location will contain an indication of success or failure.
405 *
406 *  @retval This method returns one of the values from the
407 *          @ref Objects_Name_or_id_lookup_errors enumeration to indicate
408 *          successful or failure.  On success @a id will contain the Id of
409 *          the requested object.
410 *
411 *  @note _Objects_Get returns with dispatching disabled for
412 *  local and remote objects.  _Objects_Get_isr_disable returns with
413 *  dispatching disabled for remote objects and interrupts for local
414 *  objects.
415 */
416Objects_Control *_Objects_Get (
417  Objects_Information *information,
418  Objects_Id           id,
419  Objects_Locations   *location
420);
421
422/**
423 *  @brief Maps object ids to object control blocks.
424 *
425 *  This function maps object ids to object control blocks.
426 *  If id corresponds to a local object, then it returns
427 *  the_object control pointer which maps to id and location
428 *  is set to OBJECTS_LOCAL.  If the object class supports global
429 *  objects and the object id is global and resides on a remote
430 *  node, then location is set to OBJECTS_REMOTE, and the_object
431 *  is undefined.  Otherwise, location is set to OBJECTS_ERROR
432 *  and the_object is undefined.
433 *
434 *  @param[in] information points to an object class information block.
435 *  @param[in] id is the Id of the object whose name we are locating.
436 *  @param[in] location will contain an indication of success or failure.
437 *  @param[in] level is the interrupt level being turned.
438 *
439 *  @retval This method returns one of the values from the
440 *          @ref Objects_Name_or_id_lookup_errors enumeration to indicate
441 *          successful or failure.  On success @a name will contain the name of
442 *          the requested object.
443 *
444 *  @note _Objects_Get returns with dispatching disabled for
445 *  local and remote objects.  _Objects_Get_isr_disable returns with
446 *  dispatchng disabled for remote objects and interrupts for local
447 *  objects.
448 */
449Objects_Control *_Objects_Get_isr_disable(
450  Objects_Information *information,
451  Objects_Id           id,
452  Objects_Locations   *location,
453  ISR_Level           *level
454);
455
456/**
457 *  @brief  Maps object ids to object control blocks.
458 *
459 *  This function maps object ids to object control blocks.
460 *  If id corresponds to a local object, then it returns
461 *  the_object control pointer which maps to id and location
462 *  is set to OBJECTS_LOCAL.  If the object class supports global
463 *  objects and the object id is global and resides on a remote
464 *  node, then location is set to OBJECTS_REMOTE, and the_object
465 *  is undefined.  Otherwise, location is set to OBJECTS_ERROR
466 *  and the_object is undefined.
467 *
468 *  @param[in] information points to an object class information block.
469 *  @param[in] id is the Id of the object whose name we are locating.
470 *  @param[in] location will contain an indication of success or failure.
471 *
472 *  @retval This method returns one of the values from the
473 *          @ref Objects_Name_or_id_lookup_errors enumeration to indicate
474 *          successful or failure.  On success @a id will contain the Id of
475 *          the requested object.
476 *
477 *  @note _Objects_Get returns with dispatching disabled for
478 *  local and remote objects.  _Objects_Get_isr_disable returns with
479 *  dispatching disabled for remote objects and interrupts for local
480 *  objects.
481 */
482Objects_Control *_Objects_Get_no_protection(
483  Objects_Information *information,
484  Objects_Id           id,
485  Objects_Locations   *location
486);
487
488/**
489 *  Like @ref _Objects_Get, but is used to find "next" open object.
490 *
491 *  @param[in] information points to an object class information block.
492 *  @param[in] id is the Id of the object whose name we are locating.
493 *  @param[in] location_p will contain an indication of success or failure.
494 *  @param[in] next_id_p is the Id of the next object we will look at.
495 *
496 *  @retval This method returns the pointer to the object located or
497 *          NULL on error.
498 */
499Objects_Control *_Objects_Get_next(
500    Objects_Information *information,
501    Objects_Id           id,
502    Objects_Locations   *location_p,
503    Objects_Id          *next_id_p
504);
505
506/**
507 *  @brief Get object information.
508 *
509 *  This function return the information structure given
510 *  an the API and Class.  This can be done independent of
511 *  the existence of any objects created by the API.
512 *
513 *  @param[in] the_api indicates the API for the information we want
514 *  @param[in] the_class indicates the Class for the information we want
515 *
516 *  @retval This method returns a pointer to the Object Information Table
517 *          for the class of objects which corresponds to this object ID.
518 */
519Objects_Information *_Objects_Get_information(
520  Objects_APIs   the_api,
521  uint16_t       the_class
522);
523
524/**
525 *  @brief Get information of an object from an ID.
526 *
527 *  This function return the information structure given
528 *  an @a id of an object.
529 *
530 *  @param[in] id is the object ID to get the information from
531 *
532 *  @retval This method returns a pointer to the Object Information Table
533 *          for the class of objects which corresponds to this object ID.
534 */
535Objects_Information *_Objects_Get_information_id(
536  Objects_Id  id
537);
538
539/**
540 *  @brief Gets object name in the form of a C string.
541 *
542 *  This method objects the name of an object and returns its name
543 *  in the form of a C string.  It attempts to be careful about
544 *  overflowing the user's string and about returning unprintable characters.
545 *
546 *  @param[in] id is the object to obtain the name of
547 *  @param[in] length indicates the length of the caller's buffer
548 *  @param[in] name points a string which will be filled in.
549 *
550 *  @retval This method returns @a name or NULL on error. @a *name will
551 *          contain the name if successful.
552 */
553char *_Objects_Get_name_as_string(
554  Objects_Id   id,
555  size_t       length,
556  char        *name
557);
558
559/**
560 *  @brief Set objects name.
561 *
562 *  This method sets the object name to either a copy of a string
563 *  or up to the first four characters of the string based upon
564 *  whether this object class uses strings for names.
565 *
566 *  @param[in] information points to the object information structure
567 *  @param[in] the_object is the object to operate upon
568 *  @param[in] name is a pointer to the name to use
569 *
570 *  @retval If successful, true is returned.  Otherwise false is returned.
571 */
572bool _Objects_Set_name(
573  Objects_Information *information,
574  Objects_Control     *the_object,
575  const char          *name
576);
577
578/**
579 *  @brief Removes object from namespace.
580 *
581 *  This function removes @a the_object from the namespace.
582 *
583 *  @param[in] information points to an Object Information Table.
584 *  @param[in] the_object is a pointer to an object.
585 */
586void _Objects_Namespace_remove(
587  Objects_Information  *information,
588  Objects_Control      *the_object
589);
590
591/**
592 *  @brief Close object.
593 *
594 *  This function removes the_object control pointer and object name
595 *  in the Local Pointer and Local Name Tables.
596 *
597 *  @param[in] information points to an Object Information Table
598 *  @param[in] the_object is a pointer to an object
599 */
600void _Objects_Close(
601  Objects_Information  *information,
602  Objects_Control      *the_object
603);
604
605/**
606 * @brief Returns the count of active objects.
607 *
608 * @param[in] information The object information table.
609 *
610 * @retval The count of active objects.
611 */
612Objects_Maximum _Objects_Active_count(
613  const Objects_Information *information
614);
615
616/**
617 * This function returns true if the api is valid.
618 *
619 * @param[in] the_api is the api portion of an object ID.
620 *
621 * @return This method returns true if the specified api value is valid
622 *         and false otherwise.
623 */
624RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid(
625  uint32_t   the_api
626)
627{
628  if ( !the_api || the_api > OBJECTS_APIS_LAST )
629   return false;
630  return true;
631}
632
633/**
634 * This function returns true if the node is of the local object, and
635 * false otherwise.
636 *
637 * @param[in] node is the node number and corresponds to the node number
638 *        portion of an object ID.
639 *
640 * @return This method returns true if the specified node is the local node
641 *         and false otherwise.
642 */
643RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node(
644  uint32_t   node
645)
646{
647  return ( node == _Objects_Local_node );
648}
649
650/**
651 * This function returns true if the id is of a local object, and
652 * false otherwise.
653 *
654 * @param[in] id is an object ID
655 *
656 * @return This method returns true if the specified object Id is local
657 *         and false otherwise.
658 *
659 * @note On a single processor configuration, this always returns true.
660 */
661RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id(
662#if defined(RTEMS_MULTIPROCESSING)
663  Objects_Id id
664#else
665  Objects_Id id __attribute__((unused))
666#endif
667)
668{
669#if defined(RTEMS_MULTIPROCESSING)
670  return _Objects_Is_local_node( _Objects_Get_node(id) );
671#else
672  return true;
673#endif
674}
675
676/**
677 * This function returns true if left and right are equal,
678 * and false otherwise.
679 *
680 * @param[in] left is the Id on the left hand side of the comparison
681 * @param[in] right is the Id on the right hand side of the comparison
682 *
683 * @return This method returns true if the specified object IDs are equal
684 *         and false otherwise.
685 */
686RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal(
687  Objects_Id left,
688  Objects_Id right
689)
690{
691  return ( left == right );
692}
693
694/**
695 * This function returns a pointer to the local_table object
696 * referenced by the index.
697 *
698 * @param[in] information points to an Object Information Table
699 * @param[in] index is the index of the object the caller wants to access
700 *
701 * @return This method returns a pointer to a local object or NULL if the
702 *         index is invalid and RTEMS_DEBUG is enabled.
703 */
704RTEMS_INLINE_ROUTINE Objects_Control *_Objects_Get_local_object(
705  Objects_Information *information,
706  uint16_t             index
707)
708{
709  /*
710   * This routine is ONLY to be called from places in the code
711   * where the Id is known to be good.  Therefore, this should NOT
712   * occur in normal situations.
713   */
714  #if defined(RTEMS_DEBUG)
715    if ( index > information->maximum )
716      return NULL;
717  #endif
718  return information->local_table[ index ];
719}
720
721/**
722 * This function sets the pointer to the local_table object
723 * referenced by the index.
724 *
725 * @param[in] information points to an Object Information Table
726 * @param[in] index is the index of the object the caller wants to access
727 * @param[in] the_object is the local object pointer
728 *
729 * @note This routine is ONLY to be called in places where the
730 *       index portion of the Id is known to be good.  This is
731 *       OK since it is normally called from object create/init
732 *       or delete/destroy operations.
733 */
734
735RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
736  Objects_Information *information,
737  uint32_t             index,
738  Objects_Control     *the_object
739)
740{
741  /*
742   *  This routine is ONLY to be called from places in the code
743   *  where the Id is known to be good.  Therefore, this should NOT
744   *  occur in normal situations.
745   */
746  #if defined(RTEMS_DEBUG)
747    if ( index > information->maximum )
748      return;
749  #endif
750
751  information->local_table[ index ] = the_object;
752}
753
754/**
755 * This function sets the pointer to the local_table object
756 * referenced by the index to a NULL so the object Id is invalid
757 * after this call.
758 *
759 * @param[in] information points to an Object Information Table
760 * @param[in] the_object is the local object pointer
761 *
762 * @note This routine is ONLY to be called in places where the
763 *       index portion of the Id is known to be good.  This is
764 *       OK since it is normally called from object create/init
765 *       or delete/destroy operations.
766 */
767
768RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(
769  Objects_Information  *information,
770  Objects_Control      *the_object
771)
772{
773  _Objects_Set_local_object(
774    information,
775    _Objects_Get_index( the_object->id ),
776    NULL
777  );
778}
779
780/**
781 * This function places the_object control pointer and object name
782 * in the Local Pointer and Local Name Tables, respectively.
783 *
784 * @param[in] information points to an Object Information Table
785 * @param[in] the_object is a pointer to an object
786 * @param[in] name is the name of the object to make accessible
787 */
788RTEMS_INLINE_ROUTINE void _Objects_Open(
789  Objects_Information *information,
790  Objects_Control     *the_object,
791  Objects_Name         name
792)
793{
794  _Objects_Set_local_object(
795    information,
796    _Objects_Get_index( the_object->id ),
797    the_object
798  );
799
800  the_object->name = name;
801}
802
803/**
804 * This function places the_object control pointer and object name
805 * in the Local Pointer and Local Name Tables, respectively.
806 *
807 * @param[in] information points to an Object Information Table
808 * @param[in] the_object is a pointer to an object
809 * @param[in] name is the name of the object to make accessible
810 */
811RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
812  Objects_Information *information,
813  Objects_Control     *the_object,
814  uint32_t             name
815)
816{
817  _Objects_Set_local_object(
818    information,
819    _Objects_Get_index( the_object->id ),
820    the_object
821  );
822
823  /* ASSERT: information->is_string == false */
824  the_object->name.name_u32 = name;
825}
826
827/**
828 * This function places the_object control pointer and object name
829 * in the Local Pointer and Local Name Tables, respectively.
830 *
831 * @param[in] information points to an Object Information Table
832 * @param[in] the_object is a pointer to an object
833 * @param[in] name is the name of the object to make accessible
834 */
835RTEMS_INLINE_ROUTINE void _Objects_Open_string(
836  Objects_Information *information,
837  Objects_Control     *the_object,
838  const char          *name
839)
840{
841  _Objects_Set_local_object(
842    information,
843    _Objects_Get_index( the_object->id ),
844    the_object
845  );
846
847  #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
848    /* ASSERT: information->is_string */
849    the_object->name.name_p = name;
850  #endif
851}
852
853/**
854 * @brief Puts back an object obtained with _Objects_Get().
855 *
856 * This function decrements the thread dispatch disable level.  The
857 * _Thread_Dispatch() is called if the level reaches zero.
858 */
859RTEMS_INLINE_ROUTINE void _Objects_Put(
860  Objects_Control *the_object
861)
862{
863  (void) the_object;
864  _Thread_Enable_dispatch();
865}
866
867/**
868 * @brief Puts back an object obtained with _Objects_Get().
869 *
870 * This function decrements the thread dispatch disable level.  The
871 * _Thread_Dispatch() is not called if the level reaches zero, thus a thread
872 * dispatch will not take place immediately on the current processor.
873 */
874RTEMS_INLINE_ROUTINE void _Objects_Put_without_thread_dispatch(
875  Objects_Control *the_object
876)
877{
878  (void) the_object;
879  _Thread_Unnest_dispatch();
880}
881
882/**
883 * @brief Puts back an object obtained with _Objects_Get().
884 *
885 * The thread dispatch disable level will remain unchanged.
886 *
887 * On SMP configurations the Giant lock will be released.
888 */
889RTEMS_INLINE_ROUTINE void _Objects_Put_and_keep_thread_dispatch_disabled(
890  Objects_Control *the_object
891)
892{
893  (void) the_object;
894#if defined(RTEMS_SMP)
895  _Giant_Release();
896#endif
897}
898
899/**
900 * @brief Puts back an object obtained with _Objects_Get_isr_disable().
901 */
902RTEMS_INLINE_ROUTINE void _Objects_Put_for_get_isr_disable(
903  Objects_Control *the_object
904)
905{
906  (void) the_object;
907#if defined(RTEMS_SMP)
908  _Thread_Enable_dispatch();
909#endif
910}
911
912/** @} */
913
914#ifdef __cplusplus
915}
916#endif
917
918#if defined(RTEMS_MULTIPROCESSING)
919#include <rtems/score/objectmp.h>
920#endif
921
922
923#endif
924/* end of include file */
Note: See TracBrowser for help on using the repository browser.