From patchwork Tue Aug 20 10:48:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fenghua@phytium.com.cn X-Patchwork-Id: 268439 X-Patchwork-Delegate: albert.aribaud@free.fr 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 6D4092C00F3 for ; Tue, 20 Aug 2013 20:49:50 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 203B54A09D; Tue, 20 Aug 2013 12:49:49 +0200 (CEST) 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 dpHB6Sbs46Vy; Tue, 20 Aug 2013 12:49:48 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D31CA4A09F; Tue, 20 Aug 2013 12:49:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7B98A4A07F for ; Tue, 20 Aug 2013 12:49:29 +0200 (CEST) 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 nJzg32vQ566V for ; Tue, 20 Aug 2013 12:49:29 +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 mail.corpease.net (app64.corpease.net [61.145.121.64]) by theia.denx.de (Postfix) with ESMTP id 24A584A087 for ; Tue, 20 Aug 2013 12:49:26 +0200 (CEST) Received: from localhost (unknown [222.244.86.152]) by app9 (Coremail) with SMTP id QAGowHCLz6tzSRNSeHoAAA--.217S2; Tue, 20 Aug 2013 18:48:19 +0800 (CST) From: fenghua@phytium.com.cn To: u-boot@lists.denx.de Date: Tue, 20 Aug 2013 18:48:01 +0800 Message-Id: <1376995682-51646-4-git-send-email-fenghua@phytium.com.cn> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1376995682-51646-1-git-send-email-fenghua@phytium.com.cn> References: <1376995682-51646-1-git-send-email-fenghua@phytium.com.cn> X-CM-TRANSID: QAGowHCLz6tzSRNSeHoAAA--.217S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Ar1ruF4xKFykWF4rCFy3urg_yoW8KF1Up3 4xWFy5Cr4Fq3y7Kwn7Za4S9rW3ArZ5trZ2qr47KF95Cwn5Gws3Zws3Kw12kFy7Xrs8Jan5 ZF1v9a1Du3W8ZrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWUJVW8JwA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4kE6xkI j40Ew7xC0wCY02Avz4vE14v_Gw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvj4RJUUUUUUUU X-Originating-IP: [222.244.86.152] X-CM-SenderInfo: pihqwxdxd61x51wl3zoofrzhdfq/ Cc: trini@ti.com, David Feng Subject: [U-Boot] [PATCH v4 3/4] generic board patch of manual reloc and zero gd_t 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: David Feng 1. function board_init_f in board_f.c should firstly zero gd_t structure before it call initcall_run_list, otherwise the debug print will go run if DEBUG is defined. Because the printf function will use global data to determine whether serial port is initialized and could be written. 2. function board_init_r in board_r.c should firstly relocate init_sequence_r table before it call initcall_run_list. Command table also should be relocated. Signed-off-by: David Feng --- common/board_f.c | 6 ++++++ common/board_r.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/common/board_f.c b/common/board_f.c index 5e738fb..f437bcb 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -1009,6 +1009,12 @@ void board_init_f(ulong boot_flags) gd = &data; #endif + /* + * Zero gd_t first, otherwise the debug print in initcall_run_list + * function before zero_global_data is called will go wrong. + */ + memset((void *)gd, 0, sizeof(gd_t)); + gd->flags = boot_flags; if (initcall_run_list(init_sequence_f)) diff --git a/common/board_r.c b/common/board_r.c index 86ca1cb..1b4bdd2 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -157,6 +157,13 @@ static int initr_reloc_global_data(void) */ gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE; #endif +#ifdef CONFIG_NEEDS_MANUAL_RELOC + /* + * We have to relocate the command table manually + */ + fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd), + ll_entry_count(cmd_tbl_t, cmd)); +#endif /* CONFIG_NEEDS_MANUAL_RELOC */ return 0; } @@ -899,6 +906,7 @@ init_fnc_t init_sequence_r[] = { initr_modem, #endif run_main_loop, + NULL, }; void board_init_r(gd_t *new_gd, ulong dest_addr) @@ -906,6 +914,15 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) #ifndef CONFIG_X86 gd = new_gd; #endif +#ifdef CONFIG_NEEDS_MANUAL_RELOC + /* + * We have to relocate the init_sequence_r table manually + */ + init_fnc_t *init_fnc_ptr; + for (init_fnc_ptr = init_sequence_r; *init_fnc_ptr; ++init_fnc_ptr) + *init_fnc_ptr = (init_fnc_t *)((unsigned long)(*init_fnc_ptr) + gd->reloc_off); +#endif /* CONFIG_NEEDS_MANUAL_RELOC */ + if (initcall_run_list(init_sequence_r)) hang();