summaryrefslogtreecommitdiff
path: root/Kconfig
diff options
context:
space:
mode:
authorMarek Bykowski <marek.bykowski@gmail.com>2020-04-29 18:23:07 +0200
committerTom Rini <trini@konsulko.com>2020-05-01 11:34:01 -0400
commit9297e366d6a847f7ac64f4ec7102b236d8ebe1f4 (patch)
treed4ed060b643f88bbe8de6de8a55fb1aabe4098b5 /Kconfig
parentc522949a29d44d728517cc2579ed719747da3e5d (diff)
malloc: dlmalloc: add an ability for the malloc to be re-init/init multiple times
Malloc gets initialized with a call to mem_malloc_init() with the address the allocation starts to and its size. Currently it is not possible to move the malloc from one memory area to another as the malloc would eventually fail. This patch adds in the ability to re-init the malloc with the updated start address and the size. One of the use cases of this feature is SPL U-Boot running from within the static memory and calling to malloc init from within board_init_f(): arch/arm/cpu/armv8/start.S:reset vector arch/arm/cpu/armv8/start.S:main() arch/arm/lib/crt0_64.S:board_init_f() board/<my_board>/common/spl.c:board_init_f() board/<my_board>/common/spl.c:mem_malloc_init((ulong)CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE); Shortly after the DDR (main) memory is init and ready we call to malloc init again but this time with the start address in the DDR memory and a much greater size for moving the allocation off the static to the DDR memory: board/<my_board>/common/spl.c:mem_malloc_init((ulong)CONFIG_SPL_MALLOC_OFFSET, CONFIG_SPL_MALLOC_SIZE); Where CONFIG_SYS_SPL_MALLOC_START and CONFIG_SPL_MALLOC_OFFSET are the start addresses of the malloc in the static and DDR memories respectively and CONFIG_SYS_SPL_MALLOC_SIZE=SZ_16K and CONFIG_SPL_MALLOC_SIZE=SZ_2M are the sizes of the mallocs in these memories. Note, now we have a much greater memory, enlarging from 16K to 2M, available for allocation. There is an alternative approach already existing in U-Boot with the use of an early (simplified) malloc and the proper (dlamalloc) malloc however necessitating managing the two mallocs whereas this approach proposes using a single dlmalloc. Signed-off-by: Marek Bykowski <marek.bykowski@gmail.com>
Diffstat (limited to 'Kconfig')
-rw-r--r--Kconfig14
1 files changed, 14 insertions, 0 deletions
diff --git a/Kconfig b/Kconfig
index 9a5e600753..15f1a75c61 100644
--- a/Kconfig
+++ b/Kconfig
@@ -209,6 +209,20 @@ if EXPERT
When disabling this, please check if malloc calls, maybe
should be replaced by calloc - if one expects zeroed memory.
+config SYS_MALLOC_DEFAULT_TO_INIT
+ bool "Default malloc to init while reserving the memory for it"
+ default n
+ help
+ It may happen that one needs to move the dynamic allocation
+ from one to another memory range, eg. when moving the malloc
+ from the limited static to a potentially large dynamic (DDR)
+ memory.
+
+ If so then on top of setting the updated memory aside one
+ needs to bring the malloc init.
+
+ If such a scenario is sought choose yes.
+
config TOOLS_DEBUG
bool "Enable debug information for tools"
help