diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-21 07:52:19 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-22 09:25:10 +0200 |
commit | 9c3bae11b33dce144a9ec460151dad69dfdb6fa9 (patch) | |
tree | 41de1e1c6cbc518f616e436f56df55e311efa0f6 /cpukit/rtems/src/dpmeminternal2external.c | |
parent | score: Avoid Giant lock for CORE rwlock (diff) | |
download | rtems-9c3bae11b33dce144a9ec460151dad69dfdb6fa9.tar.bz2 |
rtems: Avoid Giant lock for dual ported memory
There is no need for an ISR lock since the Dual_ported_memory_Control is
immutable after initialization. ISR disable is enough for deletion
safety on uni-processor configurations.
Update #2555.
Diffstat (limited to 'cpukit/rtems/src/dpmeminternal2external.c')
-rw-r--r-- | cpukit/rtems/src/dpmeminternal2external.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/cpukit/rtems/src/dpmeminternal2external.c b/cpukit/rtems/src/dpmeminternal2external.c index e048d8aa3e..bd66ee45cb 100644 --- a/cpukit/rtems/src/dpmeminternal2external.c +++ b/cpukit/rtems/src/dpmeminternal2external.c @@ -18,12 +18,8 @@ #include "config.h" #endif -#include <rtems/system.h> -#include <rtems/rtems/status.h> -#include <rtems/rtems/support.h> -#include <rtems/score/address.h> #include <rtems/rtems/dpmemimpl.h> -#include <rtems/score/thread.h> +#include <rtems/score/address.h> rtems_status_code rtems_port_internal_to_external( rtems_id id, @@ -31,32 +27,28 @@ rtems_status_code rtems_port_internal_to_external( void **external ) { - Dual_ported_memory_Control *the_port; - Objects_Locations location; - uint32_t ending; + Dual_ported_memory_Control *the_port; + ISR_lock_Context lock_context; + uint32_t ending; - if ( !external ) + if ( external == NULL ) { return RTEMS_INVALID_ADDRESS; + } - the_port = _Dual_ported_memory_Get( id, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - ending = _Addresses_Subtract( internal, the_port->internal_base ); - if ( ending > the_port->length ) - *external = internal; - else - *external = _Addresses_Add_offset( the_port->external_base, - ending ); - _Objects_Put( &the_port->Object ); - return RTEMS_SUCCESSFUL; - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: /* this error cannot be returned */ -#endif - case OBJECTS_ERROR: - break; + the_port = _Dual_ported_memory_Get( id, &lock_context ); + + if ( the_port == NULL ) { + return RTEMS_INVALID_ID; + } + + ending = _Addresses_Subtract( internal, the_port->internal_base ); + + if ( ending > the_port->length ) { + *external = internal; + } else { + *external = _Addresses_Add_offset( the_port->external_base, ending ); } - return RTEMS_INVALID_ID; + _ISR_lock_ISR_enable( &lock_context ); + return RTEMS_SUCCESSFUL; } |