[PATCH 1/5] score: _Objects_Get_isr_disable()
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Apr 20 13:45:56 UTC 2015
Use ISR_lock_Context instead of ISR_Level to allow use of ISR locks for
low-level locking.
Update #2273.
---
cpukit/posix/include/rtems/posix/muteximpl.h | 2 +-
cpukit/posix/src/mutexget.c | 4 +--
cpukit/posix/src/mutexlocksupp.c | 10 ++++--
cpukit/rtems/include/rtems/rtems/semimpl.h | 10 ++++--
cpukit/rtems/src/semobtain.c | 14 +++++---
cpukit/score/include/rtems/score/coremuteximpl.h | 44 ++++++++++++------------
cpukit/score/include/rtems/score/coresemimpl.h | 10 +++---
cpukit/score/include/rtems/score/objectimpl.h | 6 ++--
cpukit/score/src/apimutexlock.c | 6 ++--
cpukit/score/src/objectgetisr.c | 8 ++---
10 files changed, 62 insertions(+), 52 deletions(-)
diff --git a/cpukit/posix/include/rtems/posix/muteximpl.h b/cpukit/posix/include/rtems/posix/muteximpl.h
index e5955a6..821961c 100644
--- a/cpukit/posix/include/rtems/posix/muteximpl.h
+++ b/cpukit/posix/include/rtems/posix/muteximpl.h
@@ -148,7 +148,7 @@ POSIX_Mutex_Control *_POSIX_Mutex_Get (
POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
pthread_mutex_t *mutex,
Objects_Locations *location,
- ISR_Level *level
+ ISR_lock_Context *lock_context
);
#ifdef __cplusplus
diff --git a/cpukit/posix/src/mutexget.c b/cpukit/posix/src/mutexget.c
index 41a5495..5c0cc42 100644
--- a/cpukit/posix/src/mutexget.c
+++ b/cpukit/posix/src/mutexget.c
@@ -71,7 +71,7 @@ POSIX_Mutex_Control *_POSIX_Mutex_Get (
POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
pthread_mutex_t *mutex,
Objects_Locations *location,
- ISR_Level *level
+ ISR_lock_Context *lock_context
)
{
if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, location ) ) {
@@ -82,6 +82,6 @@ POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
&_POSIX_Mutex_Information,
(Objects_Id) *mutex,
location,
- level
+ lock_context
);
}
diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index 99d6454..3678a0b 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -43,10 +43,14 @@ int _POSIX_Mutex_Lock_support(
{
POSIX_Mutex_Control *the_mutex;
Objects_Locations location;
- ISR_Level level;
+ ISR_lock_Context lock_context;
Thread_Control *executing;
- the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &location, &level );
+ the_mutex = _POSIX_Mutex_Get_interrupt_disable(
+ mutex,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
@@ -57,7 +61,7 @@ int _POSIX_Mutex_Lock_support(
the_mutex->Object.id,
blocking,
timeout,
- level
+ &lock_context
);
_Objects_Put_for_get_isr_disable( &the_mutex->Object );
return _POSIX_Mutex_Translate_core_mutex_return_code(
diff --git a/cpukit/rtems/include/rtems/rtems/semimpl.h b/cpukit/rtems/include/rtems/rtems/semimpl.h
index b4d1e83..8c93e93 100644
--- a/cpukit/rtems/include/rtems/rtems/semimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/semimpl.h
@@ -190,11 +190,15 @@ RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get (
RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get_interrupt_disable (
Objects_Id id,
Objects_Locations *location,
- ISR_Level *level
+ ISR_lock_Context *lock_context
)
{
- return (Semaphore_Control *)
- _Objects_Get_isr_disable( &_Semaphore_Information, id, location, level );
+ return (Semaphore_Control *) _Objects_Get_isr_disable(
+ &_Semaphore_Information,
+ id,
+ location,
+ lock_context
+ );
}
#ifdef __cplusplus
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 3608a00..152274e 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -39,12 +39,16 @@ rtems_status_code rtems_semaphore_obtain(
{
Semaphore_Control *the_semaphore;
Objects_Locations location;
- ISR_Level level;
+ ISR_lock_Context lock_context;
Thread_Control *executing;
rtems_attribute attribute_set;
bool wait;
- the_semaphore = _Semaphore_Get_interrupt_disable( id, &location, &level );
+ the_semaphore = _Semaphore_Get_interrupt_disable(
+ id,
+ &location,
+ &lock_context
+ );
switch ( location ) {
case OBJECTS_LOCAL:
@@ -55,7 +59,7 @@ rtems_status_code rtems_semaphore_obtain(
if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
MRSP_Status mrsp_status;
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( &lock_context );
mrsp_status = _MRSP_Obtain(
&the_semaphore->Core_control.mrsp,
executing,
@@ -73,7 +77,7 @@ rtems_status_code rtems_semaphore_obtain(
id,
wait,
timeout,
- level
+ &lock_context
);
_Objects_Put_for_get_isr_disable( &the_semaphore->Object );
return _Semaphore_Translate_core_mutex_return_code(
@@ -87,7 +91,7 @@ rtems_status_code rtems_semaphore_obtain(
id,
wait,
timeout,
- level
+ &lock_context
);
_Objects_Put_for_get_isr_disable( &the_semaphore->Object );
return _Semaphore_Translate_core_semaphore_return_code(
diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h
index 63a4dba..e1478dd 100644
--- a/cpukit/score/include/rtems/score/coremuteximpl.h
+++ b/cpukit/score/include/rtems/score/coremuteximpl.h
@@ -129,7 +129,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
*
* @param[in,out] executing The currently executing thread.
* @param[in,out] the_mutex is the mutex to attempt to lock
- * @param[in] level is the interrupt level
+ * @param[in] lock_context is the interrupt level
*
* @retval This routine returns 0 if "trylock" can resolve whether or not
* the mutex is immediately obtained or there was an error attempting to
@@ -143,7 +143,7 @@ CORE_mutex_Status _CORE_mutex_Initialize(
RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
- ISR_Level level
+ ISR_lock_Context *lock_context
);
#if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__)
@@ -162,7 +162,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
int _CORE_mutex_Seize_interrupt_trylock(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
- ISR_Level level
+ ISR_lock_Context *lock_context
);
#else
/**
@@ -171,10 +171,10 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
*
* @param[in] _mutex will attempt to lock
* @param[in] _executing points to the executing thread
- * @param[in] _level is the interrupt level
+ * @param[in] _lock_context is the interrupt level
*/
- #define _CORE_mutex_Seize_interrupt_trylock( _mutex, _executing, _level ) \
- _CORE_mutex_Seize_interrupt_trylock_body( _mutex, _executing, _level )
+ #define _CORE_mutex_Seize_interrupt_trylock( _mutex, _executing, _lock_context ) \
+ _CORE_mutex_Seize_interrupt_trylock_body( _mutex, _executing, _lock_context )
#endif
/**
@@ -226,7 +226,7 @@ void _CORE_mutex_Seize_interrupt_blocking(
* @param[in] id is the Id of the owning API level Semaphore object
* @param[in] wait is true if the thread is willing to wait
* @param[in] timeout is the maximum number of ticks to block
- * @param[in] level is a temporary variable used to contain the ISR
+ * @param[in] lock_context is a temporary variable used to contain the ISR
* disable level cookie
*
* @note If the mutex is called from an interrupt service routine,
@@ -248,7 +248,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize_body(
Objects_Id id,
bool wait,
Watchdog_Interval timeout,
- ISR_Level level
+ ISR_lock_Context *lock_context
)
{
if ( _CORE_mutex_Check_dispatch_for_seize( wait ) ) {
@@ -258,9 +258,9 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize_body(
INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE
);
}
- if ( _CORE_mutex_Seize_interrupt_trylock( the_mutex, executing, level ) ) {
+ if ( _CORE_mutex_Seize_interrupt_trylock( the_mutex, executing, lock_context ) ) {
if ( !wait ) {
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
executing->Wait.return_code =
CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT;
} else {
@@ -268,7 +268,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize_body(
executing->Wait.queue = &the_mutex->Wait_queue;
executing->Wait.id = id;
_Thread_Disable_dispatch();
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
_CORE_mutex_Seize_interrupt_blocking( the_mutex, executing, timeout );
}
}
@@ -282,7 +282,7 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize_body(
* @param[in] _id is the Id of the owning API level Semaphore object
* @param[in] _wait is true if the thread is willing to wait
* @param[in] _timeout is the maximum number of ticks to block
- * @param[in] _level is a temporary variable used to contain the ISR
+ * @param[in] _lock_context is a temporary variable used to contain the ISR
* disable level cookie
*/
#if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__)
@@ -292,13 +292,13 @@ RTEMS_INLINE_ROUTINE void _CORE_mutex_Seize_body(
Objects_Id _id,
bool _wait,
Watchdog_Interval _timeout,
- ISR_Level _level
+ ISR_lock_Context *_lock_context
);
#else
#define _CORE_mutex_Seize( \
- _the_mutex, _executing, _id, _wait, _timeout, _level ) \
+ _the_mutex, _executing, _id, _wait, _timeout, _lock_context ) \
_CORE_mutex_Seize_body( \
- _the_mutex, _executing, _id, _wait, _timeout, _level )
+ _the_mutex, _executing, _id, _wait, _timeout, _lock_context )
#endif
/**
@@ -442,7 +442,7 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority_ceiling(
RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
CORE_mutex_Control *the_mutex,
Thread_Control *executing,
- ISR_Level level
+ ISR_lock_Context *lock_context
)
{
/* disabled when you get here */
@@ -464,7 +464,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
}
if ( !_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) {
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
return 0;
} /* else must be CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING
*
@@ -478,13 +478,13 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
ceiling = the_mutex->Attributes.priority_ceiling;
current = executing->current_priority;
if ( current == ceiling ) {
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
return 0;
}
if ( current > ceiling ) {
_Thread_Disable_dispatch();
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
_Thread_Change_priority(
executing,
ceiling,
@@ -498,7 +498,7 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
the_mutex->holder = NULL;
the_mutex->nest_count = 0; /* undo locking above */
executing->resource_count--; /* undo locking above */
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
return 0;
}
}
@@ -514,12 +514,12 @@ RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
switch ( the_mutex->Attributes.lock_nesting_behavior ) {
case CORE_MUTEX_NESTING_ACQUIRES:
the_mutex->nest_count++;
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
return 0;
#if defined(RTEMS_POSIX_API)
case CORE_MUTEX_NESTING_IS_ERROR:
executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED;
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
return 0;
#endif
case CORE_MUTEX_NESTING_BLOCKS:
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index fda908e..99303d7 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -203,7 +203,7 @@ RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count(
* @param[in] id is the Id of the owning API level Semaphore object
* @param[in] wait is true if the thread is willing to wait
* @param[in] timeout is the maximum number of ticks to block
- * @param[in] level is a temporary variable used to contain the ISR
+ * @param[in] lock_context is a temporary variable used to contain the ISR
* disable level cookie
*
* @note There is currently no MACRO version of this routine.
@@ -214,7 +214,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
Objects_Id id,
bool wait,
Watchdog_Interval timeout,
- ISR_Level level
+ ISR_lock_Context *lock_context
)
{
/* disabled when you get here */
@@ -222,12 +222,12 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
if ( the_semaphore->count != 0 ) {
the_semaphore->count -= 1;
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
return;
}
if ( !wait ) {
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
return;
}
@@ -236,7 +236,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
_Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
executing->Wait.queue = &the_semaphore->Wait_queue;
executing->Wait.id = id;
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
_Thread_queue_Enqueue( &the_semaphore->Wait_queue, executing, timeout );
_Thread_Enable_dispatch();
diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h
index d24f584..a137dea 100644
--- a/cpukit/score/include/rtems/score/objectimpl.h
+++ b/cpukit/score/include/rtems/score/objectimpl.h
@@ -21,7 +21,7 @@
#include <rtems/score/object.h>
#include <rtems/score/apimutex.h>
-#include <rtems/score/isrlevel.h>
+#include <rtems/score/isrlock.h>
#include <rtems/score/threaddispatch.h>
#ifdef __cplusplus
@@ -539,7 +539,7 @@ Objects_Control *_Objects_Get (
* @param[in] information points to an object class information block.
* @param[in] id is the Id of the object whose name we are locating.
* @param[in] location will contain an indication of success or failure.
- * @param[in] level is the interrupt level being turned.
+ * @param[in] lock_context is the previous interrupt state being turned.
*
* @retval This method returns one of the values from the
* @ref Objects_Name_or_id_lookup_errors enumeration to indicate
@@ -555,7 +555,7 @@ Objects_Control *_Objects_Get_isr_disable(
Objects_Information *information,
Objects_Id id,
Objects_Locations *location,
- ISR_Level *level
+ ISR_lock_Context *lock_context
);
/**
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c
index 07e5159..45ad0ba 100644
--- a/cpukit/score/src/apimutexlock.c
+++ b/cpukit/score/src/apimutexlock.c
@@ -26,7 +26,7 @@
void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
{
bool previous_thread_life_protection;
- ISR_Level level;
+ ISR_lock_Context lock_context;
previous_thread_life_protection = _Thread_Set_life_protection( true );
@@ -34,7 +34,7 @@ void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
_Thread_Disable_dispatch();
#endif
- _ISR_Disable( level );
+ _ISR_lock_ISR_disable( &lock_context );
_CORE_mutex_Seize(
&the_mutex->Mutex,
@@ -42,7 +42,7 @@ void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
the_mutex->Object.id,
true,
0,
- level
+ &lock_context
);
if ( the_mutex->Mutex.nest_count == 1 ) {
diff --git a/cpukit/score/src/objectgetisr.c b/cpukit/score/src/objectgetisr.c
index 25e8a3b..4feb7aa 100644
--- a/cpukit/score/src/objectgetisr.c
+++ b/cpukit/score/src/objectgetisr.c
@@ -24,12 +24,11 @@ Objects_Control *_Objects_Get_isr_disable(
Objects_Information *information,
Objects_Id id,
Objects_Locations *location,
- ISR_Level *level_p
+ ISR_lock_Context *lock_context
)
{
Objects_Control *the_object;
uint32_t index;
- ISR_Level level;
index = id - information->minimum_id + 1;
@@ -37,13 +36,12 @@ Objects_Control *_Objects_Get_isr_disable(
#if defined(RTEMS_SMP)
_Thread_Disable_dispatch();
#endif
- _ISR_Disable( level );
+ _ISR_lock_ISR_disable( lock_context );
if ( (the_object = information->local_table[ index ]) != NULL ) {
*location = OBJECTS_LOCAL;
- *level_p = level;
return the_object;
}
- _ISR_Enable( level );
+ _ISR_lock_ISR_enable( lock_context );
#if defined(RTEMS_SMP)
_Thread_Enable_dispatch();
#endif
--
1.8.4.5
More information about the devel
mailing list