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/dpmemexternal2internal.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/dpmemexternal2internal.c')
-rw-r--r-- | cpukit/rtems/src/dpmemexternal2internal.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/cpukit/rtems/src/dpmemexternal2internal.c b/cpukit/rtems/src/dpmemexternal2internal.c index 237d5c4f90..0456010675 100644 --- a/cpukit/rtems/src/dpmemexternal2internal.c +++ b/cpukit/rtems/src/dpmemexternal2internal.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_external_to_internal( rtems_id id, @@ -31,31 +27,28 @@ rtems_status_code rtems_port_external_to_internal( void **internal ) { - 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 ( !internal ) + if ( internal == NULL ) { return RTEMS_INVALID_ADDRESS; + } - the_port = _Dual_ported_memory_Get( id, &location ); - switch ( location ) { - case OBJECTS_LOCAL: - ending = _Addresses_Subtract( external, the_port->external_base ); - if ( ending > the_port->length ) - *internal = external; - else - *internal = _Addresses_Add_offset( the_port->internal_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( external, the_port->external_base ); + + if ( ending > the_port->length ) { + *internal = external; + } else { + *internal = _Addresses_Add_offset( the_port->internal_base, ending ); } - return RTEMS_INVALID_ID; + _ISR_lock_ISR_enable( &lock_context ); + return RTEMS_SUCCESSFUL; } |