diff options
author | Kinsey Moore <kinsey.moore@oarcorp.com> | 2024-01-24 11:13:34 -0600 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2024-01-26 08:19:15 -0600 |
commit | 4c948a6ae52ff4c897aca231ccea8df65a6d959d (patch) | |
tree | 237b81751ccd92f8fa73f8a94eb3763598285b0e /cpukit/libcsupport/src/cachecoherentalloc.c | |
parent | cpukit/dosfs: Simplify expressions where possible (diff) | |
download | rtems-4c948a6ae52ff4c897aca231ccea8df65a6d959d.tar.bz2 |
cpukit/cache: Report coherent add area failures
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.
Diffstat (limited to 'cpukit/libcsupport/src/cachecoherentalloc.c')
-rw-r--r-- | cpukit/libcsupport/src/cachecoherentalloc.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/cpukit/libcsupport/src/cachecoherentalloc.c b/cpukit/libcsupport/src/cachecoherentalloc.c index 198eb907b5..ed17ebffcb 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,37 @@ 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 ) { - if ( _System_state_Is_up( _System_state_Get()) ) { + rtems_status_code sc; + bool needs_locking = _System_state_Is_up( _System_state_Get()); + + if ( needs_locking ) { _RTEMS_Lock_allocator(); + } - add_area( area_begin, area_size ); + sc = add_area( area_begin, area_size ); + if ( needs_locking ) { _RTEMS_Unlock_allocator(); - } else { - add_area( area_begin, area_size ); } + + return sc; } |