RTEMS
objectgetlocal.c
Go to the documentation of this file.
1 
8 /*
9  * Copyright (c) 2016 embedded brains GmbH. All rights reserved.
10  *
11  * embedded brains GmbH
12  * Dornierstr. 4
13  * 82178 Puchheim
14  * Germany
15  * <rtems@embedded-brains.de>
16  *
17  * The license and distribution terms for this file may be
18  * found in the file LICENSE in this distribution or at
19  * http://www.rtems.org/license/LICENSE.
20  */
21 
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 
26 #include <rtems/score/objectimpl.h>
27 
29  Objects_Id id,
30  ISR_lock_Context *lock_context,
31  const Objects_Information *information
32 )
33 {
34  Objects_Id delta;
35  Objects_Id maximum_id;
36  Objects_Id end;
37 
38  maximum_id = information->maximum_id;
39  delta = maximum_id - id;
40  end = _Objects_Get_index( maximum_id );
41 
42  if ( RTEMS_PREDICT_TRUE( delta < end ) ) {
43  ISR_Level level;
44  Objects_Control *the_object;
45 
46  _ISR_Local_disable( level );
47  _ISR_lock_Context_set_level( lock_context, level );
48 
49  the_object =
50  information->local_table[ end - OBJECTS_INDEX_MINIMUM - delta ];
51  if ( RTEMS_PREDICT_TRUE( the_object != NULL ) ) {
52  /* ISR disabled on behalf of caller */
53  return the_object;
54  }
55 
56  _ISR_Local_enable( level );
57  }
58 
59  return NULL;
60 }
static __inline__ void _ISR_lock_Context_set_level(ISR_lock_Context *context, ISR_Level level)
Sets the ISR level in the ISR lock context.
Definition: isrlock.h:159
#define _ISR_Local_disable(_level)
Disables interrupts on this processor.
Definition: isrlevel.h:57
#define OBJECTS_INDEX_MINIMUM
Definition: objectimpl.h:80
static __inline__ Objects_Maximum _Objects_Get_index(Objects_Id id)
Returns the index portion of the ID.
Definition: object.h:298
Inlined Routines in the Object Handler.
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
uint32_t ISR_Level
Definition: isrlevel.h:41
#define _ISR_Local_enable(_level)
Enables interrupts on this processor.
Definition: isrlevel.h:74
The information structure used to manage each API class of objects.
Definition: objectdata.h:176
uint32_t Objects_Id
Definition: object.h:80
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.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
#define RTEMS_PREDICT_TRUE(_exp)
Returns the value of the specified integral expression and tells the compiler that the predicted valu...
Definition: basedefs.h:765