From patchwork Mon Aug 17 16:08:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 508016 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7D4C31402B7 for ; Tue, 18 Aug 2015 02:08:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4B2A14B8CD; Mon, 17 Aug 2015 18:08:52 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FHZM0KFT4kne; Mon, 17 Aug 2015 18:08:52 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 431B64B8CE; Mon, 17 Aug 2015 18:08:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 98D334B7BA for ; Mon, 17 Aug 2015 18:08:35 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J0L9PNUg6foJ for ; Mon, 17 Aug 2015 18:08:35 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 36E294B7C7 for ; Mon, 17 Aug 2015 18:08:32 +0200 (CEST) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 36D2AA305D; Mon, 17 Aug 2015 16:08:31 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-6-253.ams2.redhat.com [10.36.6.253]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7HG8RHT020664; Mon, 17 Aug 2015 12:08:29 -0400 From: Hans de Goede To: Ian Campbell , Simon Glass , Tom Rini Date: Mon, 17 Aug 2015 18:08:24 +0200 Message-Id: <1439827706-1748-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1439827706-1748-1-git-send-email-hdegoede@redhat.com> References: <1439827706-1748-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 1/3] malloc_simple: Allow malloc_simple to be used with non stack RAM X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Reviewed-by: Simon Glass --- arch/arm/lib/crt0.S | 2 +- common/board_f.c | 4 ++++ common/dlmalloc.c | 4 ++++ common/spl/spl.c | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S index afd4f10..5e6619f 100644 --- a/arch/arm/lib/crt0.S +++ b/arch/arm/lib/crt0.S @@ -96,7 +96,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 c959774..7f3b96f 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -1050,9 +1050,13 @@ ulong board_init_f_mem(ulong top) arch_setup_gd(gd_ptr); #ifdef CONFIG_SYS_MALLOC_F_LEN +#if defined(CONFIG_SYS_MALLOC_F_BASE) + gd->malloc_base = CONFIG_SYS_MALLOC_F_BASE; +#else top -= CONFIG_SYS_MALLOC_F_LEN; gd->malloc_base = top; #endif +#endif return top; } diff --git a/common/dlmalloc.c b/common/dlmalloc.c index b5bb051..9b14033 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -3264,7 +3264,11 @@ int mALLOPt(param_number, value) int param_number; int value; 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 = CONFIG_SYS_MALLOC_F_LEN; gd->malloc_ptr = 0; #endif diff --git a/common/spl/spl.c b/common/spl/spl.c index 94b01da..811452b 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -156,6 +156,9 @@ int spl_init(void) #if defined(CONFIG_SYS_MALLOC_F_LEN) gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN; gd->malloc_ptr = 0; +#if defined(CONFIG_SYS_MALLOC_F_BASE) + gd->malloc_base = CONFIG_SYS_MALLOC_F_BASE; +#endif #endif if (IS_ENABLED(CONFIG_OF_CONTROL) && !IS_ENABLED(CONFIG_SPL_DISABLE_OF_CONTROL)) {