From patchwork Sat Aug 24 01:06:27 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: 269602 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 416122C0090 for ; Sat, 24 Aug 2013 11:11:39 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EB1AD4A0E6; Sat, 24 Aug 2013 03:08:26 +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 SPSXi1xVVXGh; Sat, 24 Aug 2013 03:08:26 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 083814A0E9; Sat, 24 Aug 2013 03:08:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 532674A0A6 for ; Sat, 24 Aug 2013 03:08:11 +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 NefmONlSq8lT for ; Sat, 24 Aug 2013 03:08:11 +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 APP8.CORPEASE.NET (APP8.CORPEASE.NET [61.145.121.10]) by theia.denx.de (Postfix) with ESMTP id B97754A097 for ; Sat, 24 Aug 2013 03:07:48 +0200 (CEST) Received: from localhost (unknown [220.202.152.31]) by app8.corpease.net (Coremail) with SMTP id CgGowHDbiwZeBxhSPuUGAA--.3672S3; Sat, 24 Aug 2013 09:07:43 +0800 (CST) From: fenghua@phytium.com.cn To: u-boot@lists.denx.de Date: Sat, 24 Aug 2013 09:06:27 +0800 Message-Id: <1377306389-25369-8-git-send-email-fenghua@phytium.com.cn> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1377306389-25369-1-git-send-email-fenghua@phytium.com.cn> References: <1377306389-25369-1-git-send-email-fenghua@phytium.com.cn> X-CM-TRANSID: CgGowHDbiwZeBxhSPuUGAA--.3672S3 X-Coremail-Antispam: 1UD129KBjvJXoWxJw1xKF48Kw1rCw4kAr48Xrb_yoWrJry3pr yxGF15Cr4rt3y7t3yxZasa9r9xArs5trWvqr47Gr95Aw1kCw4fXrn7tw1ayFy2grs8Xa18 XFyvgws8u3WUuw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvlb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWUJVW8JwA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r126r1DMcIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4kE6xkI j40Ew7xC0wCY02Avz4vE14v_KwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x0zRUUUUUUUUU= X-Originating-IP: [220.202.152.31] X-CM-SenderInfo: pihqwxdxd61x51wl3zoofrzhdfq/ Cc: trini@ti.com, David Feng Subject: [U-Boot] [PATCH v5 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 --- Changes for v4: - fix the generic board_f.c, remove zero_global_data from init_sequence_f array and move it to board_init_f() function with CONFIG_X86 switch. The previous fixup is inaccurate. common/board_f.c | 19 +++++++++++++------ common/board_r.c | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index 0ada1af..98e24c3 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -458,7 +458,11 @@ static int reserve_round_4k(void) static int reserve_mmu(void) { /* reserve TLB table */ +#ifndef CONFIG_ARMV8 gd->arch.tlb_size = 4096 * 4; +#else + gd->arch.tlb_size = 0x10000; +#endif gd->relocaddr -= gd->arch.tlb_size; /* round down to next 64 kB limit */ @@ -610,7 +614,7 @@ static int reserve_stacks(void) * TODO(sjg@chromium.org): Perhaps create arch_reserve_stack() * to handle this and put in arch/xxx/lib/stack.c */ -# ifdef CONFIG_ARM +# if defined(CONFIG_ARM) && !defined(CONFIG_ARMV8) # ifdef CONFIG_USE_IRQ gd->start_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ); debug("Reserving %zu Bytes for IRQ stack at: %08lx\n", @@ -807,11 +811,6 @@ static int mark_bootstage(void) } static init_fnc_t init_sequence_f[] = { -#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC512X) && \ - !defined(CONFIG_MPC83xx) && !defined(CONFIG_MPC85xx) && \ - !defined(CONFIG_MPC86xx) && !defined(CONFIG_X86) - zero_global_data, -#endif #ifdef CONFIG_SANDBOX setup_ram_buf, #endif @@ -1005,6 +1004,14 @@ 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. + */ +#ifndef CONFIG_X86 + zero_global_data(); +#endif + 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();