diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-07 16:01:57 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-14 09:06:27 +0100 |
commit | 77e6eba7146ba2e2074b719eec01cc7c40bbe98b (patch) | |
tree | ec87c51ccd9c53cb65067a2a06a75d29b32387f3 /cpukit/score | |
parent | pc386: Fix linker usage issues with -r and function sections (diff) | |
download | rtems-77e6eba7146ba2e2074b719eec01cc7c40bbe98b.tar.bz2 |
score: Add and use _Objects_Get_local()
This simplifies the handling with local-only objects.
Update #2555.
Diffstat (limited to 'cpukit/score')
-rw-r--r-- | cpukit/score/Makefile.am | 1 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/objectimpl.h | 23 | ||||
-rw-r--r-- | cpukit/score/src/objectgetlocal.c | 53 |
3 files changed, 77 insertions, 0 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index ea440b384e..af78f15645 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -214,6 +214,7 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \ src/objectgetinfo.c src/objectgetinfoid.c src/objectapimaximumclass.c \ src/objectnamespaceremove.c \ src/objectactivecount.c +libscore_a_SOURCES += src/objectgetlocal.c ## SCHEDULER_C_FILES libscore_a_SOURCES += src/log2table.c diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h index f7bd69aa8e..933e7e93cf 100644 --- a/cpukit/score/include/rtems/score/objectimpl.h +++ b/cpukit/score/include/rtems/score/objectimpl.h @@ -559,6 +559,29 @@ Objects_Control *_Objects_Get_isr_disable( ); /** + * @brief Maps the specified object identifier to the associated local object + * control block. + * + * In this function interrupts are disabled during the object lookup. In case + * an associated object exists, then interrupts remain disabled, otherwise the + * previous interrupt state is restored. + * + * @param information The object class information block. + * @param[in] id The object identifier. + * @param[in] lock_context The interrupt lock context. + * + * @retval NULL No associated object exists. + * @retval other The pointer to the associated object control block. + * Interrupts are now disabled and must be restored using the specified lock + * context via _ISR_lock_ISR_enable() or _ISR_lock_Release_and_ISR_enable(). + */ +Objects_Control *_Objects_Get_local( + const Objects_Information *information, + Objects_Id id, + ISR_lock_Context *lock_context +); + +/** * @brief Maps object ids to object control blocks. * * This function maps object ids to object control blocks. diff --git a/cpukit/score/src/objectgetlocal.c b/cpukit/score/src/objectgetlocal.c new file mode 100644 index 0000000000..8a93a765c9 --- /dev/null +++ b/cpukit/score/src/objectgetlocal.c @@ -0,0 +1,53 @@ +/** + * @file + * + * @brief Object Get Local + * @ingroup ScoreObject + */ + +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/score/objectimpl.h> + +Objects_Control *_Objects_Get_local( + const Objects_Information *information, + Objects_Id id, + ISR_lock_Context *lock_context +) +{ + uint32_t index; + + index = id - information->minimum_id + 1; + + if ( information->maximum >= index ) { + Objects_Control *the_object; + + _ISR_lock_ISR_disable( lock_context ); + + the_object = information->local_table[ index ]; + if ( the_object != NULL ) { + /* ISR disabled on behalf of caller */ + return the_object; + } + + _ISR_lock_ISR_enable( lock_context ); + } + + return NULL; +} |