From patchwork Fri Dec 31 07:13:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 77048 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 420B6B70A4 for ; Fri, 31 Dec 2010 18:13:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DB0FC281C5; Fri, 31 Dec 2010 08:13:31 +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 yhyt2mGRPiJL; Fri, 31 Dec 2010 08:13:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 919C52809E; Fri, 31 Dec 2010 08:13:30 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1E6812826B for ; Fri, 31 Dec 2010 08:13:29 +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 IrS2NQtZmuQw for ; Fri, 31 Dec 2010 08:13:27 +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 ATCPCS06.andestech.com (59-124-160-117.HINET-IP.hinet.net [59.124.160.117]) by theia.denx.de (Postfix) with ESMTP id 0546428252 for ; Fri, 31 Dec 2010 08:13:24 +0100 (CET) Received: from app01.andestech.com ([10.0.4.31]) by ATCPCS06.andestech.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 31 Dec 2010 15:13:52 +0800 From: Macpaul Lin To: Mike Frysinger , u-boot@lists.denx.de, Wolfgang Denk , Doug Lea Date: Fri, 31 Dec 2010 15:13:48 +0800 Message-Id: <1293779628-9804-1-git-send-email-macpaul@andestech.com> X-Mailer: git-send-email 1.7.3.2 X-OriginalArrivalTime: 31 Dec 2010 07:13:52.0267 (UTC) FILETIME=[473BB5B0:01CBA8BA] Cc: Macpaul Lin Subject: [U-Boot] [PATCH] common/dlmalloc: support reinit bin for fast reset X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de There are several way to reset the u-boot. Some platform will use watchdog timeout to reset the system. Some platfrom will jump to 0x0 to reload the u-boot. Some platform will jump to CONFIG_SYS_TEXT_BASE to do fast reset. This patch fixed the problem of static varible didn't cleared on the platforms which "CONFIG_SKIP_LOWLEVEL_INIT" is enabled and do software reset by simply jump to the address "CONFIG_SYS_TEXT_BASE". This patch also introduce a new define named "CONFIG_FAST_RESET" for developer to distinguish this method from other reset methods. Signed-off-by: Macpaul Lin --- README | 10 ++++++++++ common/dlmalloc.c | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/README b/README index 1acf9a3..ec00294 100644 --- a/README +++ b/README @@ -2846,6 +2846,16 @@ Low Level (hardware related) configuration options: other boot loader or by a debugger which performs these initializations itself. +- CONFIG_FAST_RESET + If both CONFIG_SKIP_LOWLEVEL_INIT and this varible is defined, + the system could use do fast software reset by simply reinit + dlmalloc module then jump to the starting address + "CONFIG_SYS_TEXT_BASE". + + To use this feature, the extern function "reinit_malloc_pool()" + in dlmalloc.c should be called inside + reset_cpu(CONFIG_SYS_TEXT_BASE). + - CONFIG_PRELOADER Modifies the behaviour of start.S when compiling a loader that is executed before the actual U-Boot. E.g. when diff --git a/common/dlmalloc.c b/common/dlmalloc.c index e9bab09..97849a5 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -3233,6 +3233,30 @@ int mALLOPt(param_number, value) int param_number; int value; } } +#if defined(CONFIG_FAST_RESET) || defined(CONFIG_SKIP_LOWLEVEL_INIT) +void reinit_bin() +{ + int i = 0; + + av_[0] = 0; + av_[1] = 0; + + for (i = 0; i < NAV ; i++) { + av_[i*2+2] = bin_at(i); + av_[i*2+2+1] = bin_at(i); + } +} + +extern void reinit_malloc_pool() +{ + /* fast reset sbrk_base */ + sbrk_base = (char *)(-1); + + /* re-initial bin */ + reinit_bin(); +} +#endif + /* History: