From patchwork Wed Mar 6 00:39:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 225228 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 4A8FC2C0369 for ; Wed, 6 Mar 2013 11:45:07 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D40EA4A1C7; Wed, 6 Mar 2013 01:44:02 +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 EcpBqOx9miyH; Wed, 6 Mar 2013 01:44:02 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 137AD4A24E; Wed, 6 Mar 2013 01:41:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 170514A20C for ; Wed, 6 Mar 2013 01:41:25 +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 G9h+HjJV9x5B for ; Wed, 6 Mar 2013 01:41:23 +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 mail-ye0-f201.google.com (mail-ye0-f201.google.com [209.85.213.201]) by theia.denx.de (Postfix) with ESMTPS id 5B9CD4A1E2 for ; Wed, 6 Mar 2013 01:41:02 +0100 (CET) Received: by mail-ye0-f201.google.com with SMTP id m12so807198yen.0 for ; Tue, 05 Mar 2013 16:41:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=BIJa1JEOOXy5ozOyWXri1nML/RzBregXLaKMMwjgnj0=; b=lSPzoAWJT9OFMIHY9+DXHxUTNHr4moZsBlTn7vFlVrS0/u8a05MfbW1h8cUsYOP26d qnmbTqrjSNJx1C7e+XnY6R39CYJtIb+yVqO6GPRI2MLASAQWreF4sQI5zJsCMwzDLBWH oahzkc26bh+b1ABQbTkTjksyy5jI5FdxcsU4xC0+eX9fz1/l5VfMl29UAQxN10s1GJvZ Gy6+8dJY/uoNcJdjVQLEyFv67Xm6382B2D4t3HIZY5DvYq3EPCk4R8WqJ6IvHZ0XMeXC Kzca4GTZnRRDTs+zEEQsh0rhHZCxW1THQZW182kKY0JgW7dqIMED9V3VibR3zvlf599H lmWg== X-Received: by 10.236.181.34 with SMTP id k22mr16472425yhm.7.1362530461665; Tue, 05 Mar 2013 16:41:01 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id u21si445516yhj.0.2013.03.05.16.41.01 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 05 Mar 2013 16:41:01 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 6EEA95A4253; Tue, 5 Mar 2013 16:41:01 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 4FFA31607C8; Tue, 5 Mar 2013 16:41:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Tue, 5 Mar 2013 16:39:52 -0800 Message-Id: <1362530405-10824-19-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1362530405-10824-1-git-send-email-sjg@chromium.org> References: <1362530405-10824-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmqWRU+61CvR0Cse0TUS4PXxtkUqnN3ljir9SZgaZ2ILZM6R9CUvic6rhsK16Wa6GXius6PJ1UnwEqPcMmuNA6aKnvDZQE70oCEZWBosa3RbpTYQoFTbGE0IcqXzfkJzGyPijsXKNKLFb6055HLvfgBCEBJv1j9EniAsxP3PzEIraNGDgju0KNJCELmCLtHvOMp0QnS Cc: Graeme Russ , Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v6 18/31] x86: Adjust board_f.c for x86 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 For x86, things have adjusted somewhat since this series was originally written. It has its own way of running through initcalls which is actually nicer than others archs. Unfortunately this does introduce exceptions. We will soon require use of generic board on x86, but until then we need to fit in with what is there, and treat x86 as a special case. Signed-off-by: Simon Glass --- Changes in v6: None Changes in v5: - Add new patch to adjust board_f.c for x86 Changes in v4: None Changes in v3: None Changes in v2: None common/board_f.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index c73677b..0d88a96 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -57,6 +57,10 @@ #include #endif #include +#ifdef CONFIG_X86 +#include +#include +#endif #include /* @@ -423,7 +427,7 @@ static int reserve_lcd(void) #endif /* CONFIG_LCD */ #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) \ - && !defined(CONFIG_ARM) + && !defined(CONFIG_ARM) && !defined(CONFIG_X86) static int reserve_video(void) { /* reserve memory for video display (always full pages) */ @@ -717,7 +721,25 @@ static int setup_reloc(void) static int jump_to_copy(void) { + /* + * x86 is special, but in a nice way. It uses a trampoline which + * enables the dcache if possible. + * + * For now, other archs use relocate_code(), which is implemented + * similarly for all archs. When we do generic relocation, hopefully + * we can make all archs enable the dcache prior to relocation. + */ +#ifdef CONFIG_X86 + /* + * SDRAM and console are now initialised. The final stack can now + * be setup in SDRAM. Code execution will continue in Flash, but + * with the stack in SDRAM and Global Data in temporary memory + * (CPU cache) + */ + board_init_f_r_trampoline(gd->start_addr_sp); +#else relocate_code(gd->dest_addr_sp, gd->new_gd, gd->dest_addr); +#endif return 0; } @@ -744,6 +766,12 @@ static init_fnc_t init_sequence_f[] = { probecpu, #endif arch_cpu_init, /* basic arch cpu dependent setup */ +#ifdef CONFIG_X86 + cpu_init_f, /* TODO(sjg@chromium.org): remove */ +# ifdef CONFIG_OF_CONTROL + find_fdt, /* TODO(sjg@chromium.org): remove */ +# endif +#endif mark_bootstage, #ifdef CONFIG_OF_CONTROL fdtdec_check_fdt, @@ -792,6 +820,9 @@ static init_fnc_t init_sequence_f[] = { init_baud_rate, /* initialze baudrate settings */ serial_init, /* serial communications setup */ console_init_f, /* stage 1 init of console */ +#if defined(CONFIG_X86) && defined(CONFIG_OF_CONTROL) + prepare_fdt, /* TODO(sjg@chromium.org): remove */ +#endif display_options, /* say that we are here */ display_text_info, /* show debugging info if required */ #if defined(CONFIG_8260) @@ -829,6 +860,8 @@ static init_fnc_t init_sequence_f[] = { #endif #ifdef CONFIG_X86 dram_init_f, /* configure available RAM banks */ + /* x86 would prefer that this happens after relocation */ + dram_init, #endif announce_dram_init, /* TODO: unify all these dram functions? */ @@ -880,7 +913,7 @@ static init_fnc_t init_sequence_f[] = { #endif /* TODO: Why the dependency on CONFIG_8xx? */ #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) \ - && !defined(CONFIG_ARM) + && !defined(CONFIG_ARM) && !defined(CONFIG_X86) reserve_video, #endif reserve_uboot, @@ -915,9 +948,11 @@ static init_fnc_t init_sequence_f[] = { void board_init_f(ulong boot_flags) { +#ifndef CONFIG_X86 gd_t data; gd = &data; +#endif gd->flags = boot_flags; @@ -930,6 +965,50 @@ void board_init_f(ulong boot_flags) #endif } +#ifdef CONFIG_X86 +/* + * For now this code is only used on x86. + * + * init_sequence_f_r is the list of init functions which are run when + * U-Boot is executing from Flash with a semi-limited 'C' environment. + * The following limitations must be considered when implementing an + * '_f_r' function: + * - 'static' variables are read-only + * - Global Data (gd->xxx) is read/write + * + * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if + * supported). It _should_, if possible, copy global data to RAM and + * initialise the CPU caches (to speed up the relocation process) + * + * NOTE: At present only x86 uses this route, but it is intended that + * all archs will move to this when generic relocation is implemented. + */ +static init_fnc_t init_sequence_f_r[] = { + init_cache_f_r, + copy_uboot_to_ram, + clear_bss, + do_elf_reloc_fixups, + + NULL, +}; + +void board_init_f_r(void) +{ + if (initcall_run_list(init_sequence_f_r)) + hang(); + + /* + * U-Boot has been copied into SDRAM, the BSS has been cleared etc. + * Transfer execution from Flash to RAM by calculating the address + * of the in-RAM copy of board_init_r() and calling it + */ + (board_init_r + gd->reloc_off)(gd, gd->relocaddr); + + /* NOTREACHED - board_init_r() does not return */ + hang(); +} +#endif /* CONFIG_X86 */ + void hang(void) { puts("### ERROR ### Please RESET the board ###\n");