From: Hans de Goede Date: Wed, 4 Feb 2015 13:05:49 +0100 Subject: [U-Boot] [PATCH 2/4] malloc_simple: Allow malloc_simple to be used with non stack RAM In-Reply-To: <1423051551-948-1-git-send-email-hdegoede@redhat.com> References: <1423051551-948-1-git-send-email-hdegoede@redhat.com> Message-ID: <1423051551-948-3-git-send-email-hdegoede@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Before this patch malloc_simple would always allocate a chunk of RAM from the stack. This commit adds a CONFIG_SYS_MALLOC_F_BASE define, which when set directly specifies the memory address to use for the heap with malloc_simple. Signed-off-by: Hans de Goede --- arch/arm/lib/crt0.S | 2 +- common/board_f.c | 4 ++++ common/spl/spl.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S index 22df3e5..a80dbf7 100644 --- a/arch/arm/lib/crt0.S +++ b/arch/arm/lib/crt0.S @@ -78,7 +78,7 @@ clr_gd: strlo r0, [r1] /* clear 32-bit GD word */ addlo r1, r1, #4 /* move to next */ blo clr_gd -#if defined(CONFIG_SYS_MALLOC_F_LEN) +#if defined(CONFIG_SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_MALLOC_F_BASE) sub sp, sp, #CONFIG_SYS_MALLOC_F_LEN str sp, [r9, #GD_MALLOC_BASE] #endif diff --git a/common/board_f.c b/common/board_f.c index 7953137..504dc1c 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -786,7 +786,11 @@ static int mark_bootstage(void) static int initf_malloc(void) { #ifdef CONFIG_SYS_MALLOC_F_LEN +#if defined(CONFIG_SYS_MALLOC_F_BASE) + gd->malloc_base = CONFIG_SYS_MALLOC_F_BASE; +#else assert(gd->malloc_base); /* Set up by crt0.S */ +#endif gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN; gd->malloc_ptr = 0; #endif diff --git a/common/spl/spl.c b/common/spl/spl.c index daaeb50..f751fcc 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -146,6 +146,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) CONFIG_SYS_SPL_MALLOC_SIZE); gd->flags |= GD_FLG_FULL_MALLOC_INIT; #elif defined(CONFIG_SYS_MALLOC_F_LEN) +#if defined(CONFIG_SYS_MALLOC_F_BASE) + gd->malloc_base = CONFIG_SYS_MALLOC_F_BASE; +#endif gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN; gd->malloc_ptr = 0; #endif -- 2.1.0