This alters the API for rtems_cache_coherent_add_area to allow reporting of failures that can occur during the process of adding a new area to the coherent cache heap. --- cpukit/include/rtems/rtems/cache.h | 7 +++++- cpukit/libcsupport/src/cachecoherentalloc.c | 27 ++++++++++++--------- 2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/cpukit/include/rtems/rtems/cache.h b/cpukit/include/rtems/rtems/cache.h index 20c630a3eb..d59a3fddca 100644 --- a/cpukit/include/rtems/rtems/cache.h +++ b/cpukit/include/rtems/rtems/cache.h @@ -59,6 +59,7 @@ #include <stddef.h> #include <stdint.h> +#include <rtems/rtems/status.h> #ifdef __cplusplus extern "C" { @@ -89,6 +90,10 @@ extern "C" { * * @param size is the size in bytes of the cache coherent memory area to add. * + * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. + * + * @retval ::RTEMS_UNSATISFIED The requested operation was not successful. + * * @par Constraints * @parblock * The following constraints apply to this directive: @@ -102,7 +107,7 @@ extern "C" { * cause the calling task to be preempted. * @endparblock */ -void rtems_cache_coherent_add_area( void *begin, uintptr_t size ); +rtems_status_code rtems_cache_coherent_add_area( void *begin, uintptr_t size ); /* Generated from spec:/rtems/cache/if/coherent-allocate */ diff --git a/cpukit/libcsupport/src/cachecoherentalloc.c b/cpukit/libcsupport/src/cachecoherentalloc.c index 198eb907b5..d6e3afa1a3 100644 --- a/cpukit/libcsupport/src/cachecoherentalloc.c +++ b/cpukit/libcsupport/src/cachecoherentalloc.c @@ -97,7 +97,7 @@ void rtems_cache_coherent_free( void *ptr ) _RTEMS_Unlock_allocator(); } -static void add_area( +static rtems_status_code add_area( void *area_begin, uintptr_t area_size ) @@ -105,31 +105,36 @@ static void add_area( Heap_Control *heap = cache_coherent_heap; if ( heap == NULL ) { - bool ok; - heap = &cache_coherent_heap_instance; - ok = _Heap_Initialize( heap, area_begin, area_size, 0 ); - if ( ok ) { - cache_coherent_heap = heap; + if ( _Heap_Initialize( heap, area_begin, area_size, 0 ) == 0 ) { + return RTEMS_UNSATISFIED; } + cache_coherent_heap = heap; } else { - _Heap_Extend( heap, area_begin, area_size, 0 ); + if (_Heap_Extend( heap, area_begin, area_size, 0 ) == 0) { + return RTEMS_UNSATISFIED; + } } + return RTEMS_SUCCESSFUL; } -void rtems_cache_coherent_add_area( +rtems_status_code rtems_cache_coherent_add_area( void *area_begin, uintptr_t area_size ) { + rtems_status_code sc; + if ( _System_state_Is_up( _System_state_Get()) ) { _RTEMS_Lock_allocator(); + } - add_area( area_begin, area_size ); + sc = add_area( area_begin, area_size ); + if ( _System_state_Is_up( _System_state_Get()) ) { _RTEMS_Unlock_allocator(); - } else { - add_area( area_begin, area_size ); } + + return sc; } -- 2.39.2 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel