From: Simon Glass Date: Fri, 27 Feb 2015 22:06:36 -0700 Subject: [U-Boot] [PATCH 12/29] Move initf_malloc() to a common place In-Reply-To: <1425100013-4796-1-git-send-email-sjg@chromium.org> References: <1425100013-4796-1-git-send-email-sjg@chromium.org> Message-ID: <1425100013-4796-13-git-send-email-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de To allow this function to be used from SPL, move it to the malloc() code. Signed-off-by: Simon Glass --- common/board_f.c | 12 +----------- common/dlmalloc.c | 11 +++++++++++ include/malloc.h | 3 +++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index eab0050..82b8a66 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -23,6 +23,7 @@ #include #include #include +#include /* TODO: Can we move these into arch/ headers? */ #ifdef CONFIG_8xx @@ -692,17 +693,6 @@ static int mark_bootstage(void) return 0; } -static int initf_malloc(void) -{ -#ifdef CONFIG_SYS_MALLOC_F_LEN - assert(gd->malloc_base); /* Set up by crt0.S */ - gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN; - gd->malloc_ptr = 0; -#endif - - return 0; -} - static int initf_dm(void) { #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 6453ee9..741215b 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -3257,6 +3257,17 @@ int mALLOPt(param_number, value) int param_number; int value; } } +int initf_malloc(void) +{ +#ifdef CONFIG_SYS_MALLOC_F_LEN + assert(gd->malloc_base); /* Set up by crt0.S */ + gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN; + gd->malloc_ptr = 0; +#endif + + return 0; +} + /* History: diff --git a/include/malloc.h b/include/malloc.h index 5df6348..f4da9e6 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -906,6 +906,9 @@ void *realloc_simple(void *ptr, size_t size); #endif +/* Set up pre-relocation malloc() ready for use */ +int initf_malloc(void); + /* Public routines */ /* Simple versions which can be used when space is tight */ -- 2.2.0.rc0.207.ga3a616c