From patchwork Tue Jan 22 07:10:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gabor Juhos X-Patchwork-Id: 214352 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 6CE3F2C007B for ; Tue, 22 Jan 2013 18:10:53 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 67CF34A0FE; Tue, 22 Jan 2013 08:10:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 5CYtsF1pyhdi; Tue, 22 Jan 2013 08:10:50 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9FF7B4A0F5; Tue, 22 Jan 2013 08:10:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DF6B64A0F5 for ; Tue, 22 Jan 2013 08:10:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 IHB6XJhGWWRU for ; Tue, 22 Jan 2013 08:10:45 +0100 (CET) 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 arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) by theia.denx.de (Postfix) with ESMTPS id F11A24A0F3 for ; Tue, 22 Jan 2013 08:10:43 +0100 (CET) Received: from arrakis.dune.hu ([127.0.0.1]) by localhost (arrakis.dune.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FXs-aCuQsKj7; Tue, 22 Jan 2013 08:09:31 +0100 (CET) Received: from localhost.localdomain (catvpool-576570d8.szarvasnet.hu [87.101.112.216]) by arrakis.dune.hu (Postfix) with ESMTPSA id 487E6280392; Tue, 22 Jan 2013 08:09:31 +0100 (CET) From: Gabor Juhos To: u-boot@lists.denx.de Date: Tue, 22 Jan 2013 08:10:38 +0100 Message-Id: <1358838638-18236-1-git-send-email-juhosg@openwrt.org> X-Mailer: git-send-email 1.7.10 MIME-Version: 1.0 Cc: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= , Macpaul Lin , Jason Jin Subject: [U-Boot] [PATCH] malloc: make malloc_bin_reloc static X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de On architectures where manual relocation is needed, the 'malloc_bin_reloc' function must be called after 'mem_malloc_init'. Make the 'malloc_bin_reloc' function static and call it directly from 'mem_malloc_init' instead of calling that from board_init_{r,f} functions of the affected architectures. Signed-off-by: Gabor Juhos Cc: Wolfgang Denk Cc: Andreas Bießmann Cc: Jason Jin Cc: Macpaul Lin Cc: Daniel Hellstrom Cc: Daniel Schwierzeck --- arch/avr32/lib/board.c | 1 - arch/m68k/lib/board.c | 1 - arch/mips/lib/board.c | 1 - arch/nds32/lib/board.c | 1 - arch/sparc/lib/board.c | 1 - common/dlmalloc.c | 6 +++++- include/malloc.h | 1 - 7 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c index e3287c4..76cbea5 100644 --- a/arch/avr32/lib/board.c +++ b/arch/avr32/lib/board.c @@ -286,7 +286,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) /* The malloc area is right below the monitor image in RAM */ mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN); - malloc_bin_reloc(); dma_alloc_init(); enable_interrupts(); diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c index e934cb6..64f096a 100644 --- a/arch/m68k/lib/board.c +++ b/arch/m68k/lib/board.c @@ -449,7 +449,6 @@ void board_init_r (gd_t *id, ulong dest_addr) /* The Malloc area is immediately below the monitor copy in DRAM */ mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off - TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN); - malloc_bin_reloc (); #if !defined(CONFIG_SYS_NO_FLASH) puts ("Flash: "); diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c index d79e183..51c08dd 100644 --- a/arch/mips/lib/board.c +++ b/arch/mips/lib/board.c @@ -283,7 +283,6 @@ void board_init_r(gd_t *id, ulong dest_addr) /* The Malloc area is immediately below the monitor copy in DRAM */ mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off - TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN); - malloc_bin_reloc(); #ifndef CONFIG_SYS_NO_FLASH /* configure available FLASH banks */ diff --git a/arch/nds32/lib/board.c b/arch/nds32/lib/board.c index 91395ca..dbfb468 100644 --- a/arch/nds32/lib/board.c +++ b/arch/nds32/lib/board.c @@ -331,7 +331,6 @@ void board_init_r(gd_t *id, ulong dest_addr) /* The Malloc area is immediately below the monitor copy in DRAM */ malloc_start = dest_addr - TOTAL_MALLOC_LEN; mem_malloc_init(malloc_start, TOTAL_MALLOC_LEN); - malloc_bin_reloc(); #ifndef CONFIG_SYS_NO_FLASH /* configure available FLASH banks */ diff --git a/arch/sparc/lib/board.c b/arch/sparc/lib/board.c index 1b5e995..79fb4c8 100644 --- a/arch/sparc/lib/board.c +++ b/arch/sparc/lib/board.c @@ -271,7 +271,6 @@ void board_init_f(ulong bootflag) /* The Malloc area is immediately below the monitor copy in RAM */ mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_END - CONFIG_SYS_MALLOC_BASE); - malloc_bin_reloc(); #if !defined(CONFIG_SYS_NO_FLASH) puts("Flash: "); diff --git a/common/dlmalloc.c b/common/dlmalloc.c index b2f0a1a..2a9d169 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1485,7 +1485,7 @@ static mbinptr av_[NAV * 2 + 2] = { }; #ifdef CONFIG_NEEDS_MANUAL_RELOC -void malloc_bin_reloc (void) +static void malloc_bin_reloc(void) { mbinptr *p = &av_[2]; size_t i; @@ -1493,6 +1493,8 @@ void malloc_bin_reloc (void) for (i = 2; i < ARRAY_SIZE(av_); ++i, ++p) *p = (mbinptr)((ulong)*p + gd->reloc_off); } +#else +static inline void malloc_bin_reloc(void) {} #endif ulong mem_malloc_start = 0; @@ -1526,6 +1528,8 @@ void mem_malloc_init(ulong start, ulong size) mem_malloc_brk = start; memset((void *)mem_malloc_start, 0, size); + + malloc_bin_reloc(); } /* field-extraction macros */ diff --git a/include/malloc.h b/include/malloc.h index 84ecf79..6295929 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -937,7 +937,6 @@ extern ulong mem_malloc_end; extern ulong mem_malloc_brk; void mem_malloc_init(ulong start, ulong size); -void malloc_bin_reloc(void); #ifdef __cplusplus }; /* end of extern "C" */