From d4c881da04bd501acac4f6c877de3db1f671e728 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sat, 18 Nov 2023 04:24:45 -0500 Subject: [PATCH] lib: mem_block: move to own folder Move mem_block into own folder and seperate from lib/os and heap configuration. Signed-off-by: Anas Nashif --- lib/CMakeLists.txt | 1 + lib/Kconfig | 2 ++ lib/heap/Kconfig | 47 ------------------------- lib/mem_blocks/CMakeLists.txt | 3 ++ lib/mem_blocks/Kconfig | 54 +++++++++++++++++++++++++++++ lib/{os => mem_blocks}/mem_blocks.c | 0 lib/os/CMakeLists.txt | 2 -- lib/os/Kconfig | 1 - 8 files changed, 60 insertions(+), 50 deletions(-) create mode 100644 lib/mem_blocks/CMakeLists.txt create mode 100644 lib/mem_blocks/Kconfig rename lib/{os => mem_blocks}/mem_blocks.c (100%) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ceba13bc2a..75387fdbb9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -11,6 +11,7 @@ endif() add_subdirectory_ifdef(CONFIG_CPP cpp) add_subdirectory(hash) add_subdirectory(heap) +add_subdirectory(mem_blocks) add_subdirectory(os) add_subdirectory_ifdef(CONFIG_SMF smf) add_subdirectory_ifdef(CONFIG_OPENAMP open-amp) diff --git a/lib/Kconfig b/lib/Kconfig index 9b6eb56d27..1b95bde76b 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -13,6 +13,8 @@ source "lib/hash/Kconfig" source "lib/heap/Kconfig" +source "lib/mem_blocks/Kconfig" + source "lib/os/Kconfig" source "lib/posix/Kconfig" diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index 4f08bccf7c..7f01b280b3 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -132,51 +132,4 @@ config SHARED_MULTI_HEAP different capabilities / attributes (cacheable, non-cacheable, etc...) defined in the DT. -config SYS_MEM_BLOCKS - bool "(Yet Another) Memory Blocks Allocator" - help - This enables support for memory block allocator where: - () All memory blocks have a single fixed size. - () Multiple blocks can be allocated or freed at the same time. - () A group of blocks allocated together may not be contiguous. - This is useful for operations such as scatter-gather DMA - transfers. - () Bookkeeping of allocated blocks is done outside of - the associated buffer (unlike memory slab). This allows - the buffer to reside in memory regions where these can be - powered down to conserve energy. - -config SYS_MEM_BLOCKS_LISTENER - bool "Memory Blocks Allocator event notifications" - depends on SYS_MEM_BLOCKS - select HEAP_LISTENER - help - This allows application to listen for memory blocks allocator - events, such as memory allocation and de-allocation. - -config SYS_MEM_BLOCKS_RUNTIME_STATS - bool "Memory blocks runtime statistics" - depends on SYS_MEM_BLOCKS - help - This option enables the tracking and reporting of the memory - blocks statistics related to the current and maximum number - of allocations in a given memory block. - -config OBJ_CORE_SYS_MEM_BLOCKS - bool "Kernel object for memory blocks" - depends on SYS_MEM_BLOCKS && OBJ_CORE - default y if SYS_MEM_BLOCKS && OBJ_CORE - help - This option allows object cores to be integrated into memory block - objects. - -config OBJ_CORE_STATS_SYS_MEM_BLOCKS - bool "Object core statistics for memory blocks" - depends on SYS_MEM_BLOCKS && OBJ_CORE_STATS - default y if SYS_MEM_BLOCKS && OBJ_CORE_STATS - select SYS_MEM_BLOCKS_RUNTIME_STATS - help - This option integrates the object core statistics framework into - the memory blocks. - endmenu diff --git a/lib/mem_blocks/CMakeLists.txt b/lib/mem_blocks/CMakeLists.txt new file mode 100644 index 0000000000..9bf3392417 --- /dev/null +++ b/lib/mem_blocks/CMakeLists.txt @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_sources_ifdef(CONFIG_SYS_MEM_BLOCKS mem_blocks.c) diff --git a/lib/mem_blocks/Kconfig b/lib/mem_blocks/Kconfig new file mode 100644 index 0000000000..ea04f8be97 --- /dev/null +++ b/lib/mem_blocks/Kconfig @@ -0,0 +1,54 @@ +# Copyright (c) 2021,2023 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +menu "Memory Blocks" + +config SYS_MEM_BLOCKS + bool "(Yet Another) Memory Blocks Allocator" + help + This enables support for memory block allocator where: + () All memory blocks have a single fixed size. + () Multiple blocks can be allocated or freed at the same time. + () A group of blocks allocated together may not be contiguous. + This is useful for operations such as scatter-gather DMA + transfers. + () Bookkeeping of allocated blocks is done outside of + the associated buffer (unlike memory slab). This allows + the buffer to reside in memory regions where these can be + powered down to conserve energy. + +config SYS_MEM_BLOCKS_LISTENER + bool "Memory Blocks Allocator event notifications" + depends on SYS_MEM_BLOCKS + select HEAP_LISTENER + help + This allows application to listen for memory blocks allocator + events, such as memory allocation and de-allocation. + +config SYS_MEM_BLOCKS_RUNTIME_STATS + bool "Memory blocks runtime statistics" + depends on SYS_MEM_BLOCKS + help + This option enables the tracking and reporting of the memory + blocks statistics related to the current and maximum number + of allocations in a given memory block. + +config OBJ_CORE_SYS_MEM_BLOCKS + bool "Kernel object for memory blocks" + depends on SYS_MEM_BLOCKS && OBJ_CORE + default y if SYS_MEM_BLOCKS && OBJ_CORE + help + This option allows object cores to be integrated into memory block + objects. + +config OBJ_CORE_STATS_SYS_MEM_BLOCKS + bool "Object core statistics for memory blocks" + depends on SYS_MEM_BLOCKS && OBJ_CORE_STATS + default y if SYS_MEM_BLOCKS && OBJ_CORE_STATS + select SYS_MEM_BLOCKS_RUNTIME_STATS + help + This option integrates the object core statistics framework into + the memory blocks. + +endmenu diff --git a/lib/os/mem_blocks.c b/lib/mem_blocks/mem_blocks.c similarity index 100% rename from lib/os/mem_blocks.c rename to lib/mem_blocks/mem_blocks.c diff --git a/lib/os/CMakeLists.txt b/lib/os/CMakeLists.txt index 4f403c2a28..47d4501ca0 100644 --- a/lib/os/CMakeLists.txt +++ b/lib/os/CMakeLists.txt @@ -49,8 +49,6 @@ zephyr_sources_ifdef(CONFIG_REBOOT reboot.c) zephyr_sources_ifdef(CONFIG_UTF8 utf8.c) -zephyr_sources_ifdef(CONFIG_SYS_MEM_BLOCKS mem_blocks.c) - zephyr_sources_ifdef(CONFIG_WINSTREAM winstream.c) zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c) diff --git a/lib/os/Kconfig b/lib/os/Kconfig index 8b41f92f5b..2f67b2da4d 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -169,5 +169,4 @@ config UTF8 rsource "Kconfig.cbprintf" - endmenu