From patchwork Fri Feb 8 15:12:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 219178 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 DC4F82C0085 for ; Sat, 9 Feb 2013 02:15:16 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 737E54A126; Fri, 8 Feb 2013 16:15:03 +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 lK3EZs60HNki; Fri, 8 Feb 2013 16:15:03 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C5464A12F; Fri, 8 Feb 2013 16:14:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 31D374A120 for ; Fri, 8 Feb 2013 16:13:59 +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 tRwom5rM2KFr for ; Fri, 8 Feb 2013 16:13:56 +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-ea0-f201.google.com (mail-ea0-f201.google.com [209.85.215.201]) by theia.denx.de (Postfix) with ESMTPS id 044F24A0C7 for ; Fri, 8 Feb 2013 16:13:52 +0100 (CET) Received: by mail-ea0-f201.google.com with SMTP id l13so265380eaa.0 for ; Fri, 08 Feb 2013 07:13:52 -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=sX2dHEtb+meZUUlDq8K8LsKuNOPp5/HBO2CPrJbwzIw=; b=ciH7ayRKyhyBf2ZFWkqNskv/TvWXASwoT7ANKXHfOqx8tgiQrD07XOAzNK5z8Tbron SdUudLQzn1iux5CTd1LSyOR8XB9h4R2Y2xRhI2a65R8aaZW/c1C8yriO+yBfEyKNwreE UX75O3op4H/ZHEsbE5w1qiEqjaV36GRZ2tCVXGB3ssxPm3d64jfwF+TYHEM1mm5+hXv1 QN1/y4pPcf0sm0kGBK9wS4CTowEqkJP63hwC2qK8JOHZh2tu7jPypftAAaZY48bjce+z vcl3BM4LuUq47zwQrC0ftF0+mG9Dy12mAtErq6I7+GVVTHcxFELKW5meOR/67RuU4Ch7 fkaQ== X-Received: by 10.14.0.196 with SMTP id 44mr4011183eeb.4.1360336432425; Fri, 08 Feb 2013 07:13:52 -0800 (PST) Received: from corp2gmr1-1.eem.corp.google.com (corp2gmr1-1.eem.corp.google.com [172.25.138.99]) by gmr-mx.google.com with ESMTPS id m6si7541065een.1.2013.02.08.07.13.52 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Fri, 08 Feb 2013 07:13:52 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-1.eem.corp.google.com (Postfix) with ESMTP id 0789C1CA23E; Fri, 8 Feb 2013 07:13:52 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id B72E5160B1F; Fri, 8 Feb 2013 07:13:51 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Fri, 8 Feb 2013 07:12:15 -0800 Message-Id: <1360336339-10703-20-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1360336339-10703-1-git-send-email-sjg@chromium.org> References: <1360336339-10703-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQlzcJTZK+E5bX6s0ZRqSsTwL4WNvgNmyDFEWn6AU6rasW49RvL0G+rzZJaVmsZvVJ7Ob8s9rvlWP8qaAm/k6K739sE1NjITImOi+Khlzrb4uGLNMeg6CyL8jxNz2rwEKXErwRuaj6pWQ60SljupJ6jJaVVvbIDFwp9xnEy9UPEcReZuMLM+cXlqaOqqlMKXl666Tv+V Cc: Graeme Russ , Tom Rini , Vadim Bendebury Subject: [U-Boot] [PATCH v5 19/23] 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 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 4dfac6e..ab24c57 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) */ @@ -716,7 +720,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; } @@ -743,6 +765,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, @@ -791,6 +819,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) @@ -828,6 +859,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? */ @@ -883,7 +916,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, @@ -920,9 +953,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; @@ -935,6 +970,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");