From: Tom Rini Date: Fri, 1 May 2020 17:57:40 -0400 Subject: [PATCH v3] malloc: dlmalloc: add an ability for the malloc to be re-init/init multiple times In-Reply-To: <20200429162307.3685-1-marek.bykowski@gmail.com> References: <20200429123848.17418-1-marek.bykowski@gmail.com> <20200429162307.3685-1-marek.bykowski@gmail.com> Message-ID: <20200501215740.GZ12564@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, Apr 29, 2020 at 06:23:07PM +0200, marek.bykowski at gmail.com wrote: > From: Marek Bykowski > > 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//common/spl.c:board_init_f() > 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//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 Applied to u-boot/master, thanks! -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: