mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 18:45:30 +08:00
score: _Objects_Get_isr_disable()
Use ISR_lock_Context instead of ISR_Level to allow use of ISR locks for low-level locking. Update #2273.
This commit is contained in:
@@ -376,12 +376,12 @@ void
|
||||
rtems_bsdnet_semaphore_obtain (void)
|
||||
{
|
||||
#ifdef RTEMS_FAST_MUTEX
|
||||
ISR_Level level;
|
||||
ISR_lock_Context lock_context;
|
||||
Thread_Control *executing;
|
||||
#ifdef RTEMS_SMP
|
||||
_Thread_Disable_dispatch();
|
||||
#endif
|
||||
_ISR_Disable (level);
|
||||
_ISR_lock_ISR_disable(&lock_context);
|
||||
if (!the_networkSemaphore)
|
||||
rtems_panic ("rtems-net: network sema obtain: network not initialised\n");
|
||||
executing = _Thread_Executing;
|
||||
@@ -391,7 +391,7 @@ rtems_bsdnet_semaphore_obtain (void)
|
||||
networkSemaphore,
|
||||
1, /* wait */
|
||||
0, /* forever */
|
||||
level
|
||||
&lock_context
|
||||
);
|
||||
#ifdef RTEMS_SMP
|
||||
_Thread_Enable_dispatch();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user