From patchwork Mon Jun 1 12:31:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 478944 X-Patchwork-Delegate: sjg@chromium.org 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 4C5DF140E5E for ; Mon, 1 Jun 2015 22:31:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=JtT7cU8I; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 502E44B786; Mon, 1 Jun 2015 14:31:41 +0200 (CEST) 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 zJEiudKF-JRa; Mon, 1 Jun 2015 14:31:41 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D13274B76D; Mon, 1 Jun 2015 14:31:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 88D244B760 for ; Mon, 1 Jun 2015 14:31:35 +0200 (CEST) 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 7W5tpT8nNy0b for ; Mon, 1 Jun 2015 14:31:35 +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-qk0-f171.google.com (mail-qk0-f171.google.com [209.85.220.171]) by theia.denx.de (Postfix) with ESMTPS id 41E054B755 for ; Mon, 1 Jun 2015 14:31:31 +0200 (CEST) Received: by qkx62 with SMTP id 62so82527904qkx.3 for ; Mon, 01 Jun 2015 05:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date:in-reply-to:references :mime-version:content-type; bh=iQcd2yWgDMS/1WGrSmV1+AaD5dOedyfAAWlas6ai3CQ=; b=JtT7cU8ITdMDGGtpcguf5Uvni+Unly7TUBYZmFnSUTNIIYzMb4x+zPrOMsp8oEODOn /3KI2OUizXMOJH2i8PIZvJ2kvDQbJ4ZTmmH1FvZ9OFm33KyhdmAJFuTxIeH/f9UfITbM EMIkmgm4hvdoqWyG/frORgg4lW5sMIxJuFiOqNPjMqrDTubV/OooxwaWdGgncCM0zhA8 oOwAA2wYRF+7ORYi8mb92ghsywjfc0bvCBdcWuJSlQJKMUnWNvd2qFi+BQzkOxdsYZBT Ehyl2fJaF43445/lNZxP/9HjUIM4EmP3QL0RIeVbjC/ExS5/rh36d0HEJPzhpTQsRdHM tJ0g== X-Received: by 10.55.19.12 with SMTP id d12mr38827380qkh.89.1433161889987; Mon, 01 Jun 2015 05:31:29 -0700 (PDT) Received: from mail.hotmail.com (blu004-wss1s1.hotmail.com. [134.170.2.216]) by mx.google.com with ESMTPSA id p59sm1785394qga.1.2015.06.01.05.31.29 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 05:31:29 -0700 (PDT) Received: from BLU436-SMTP217 ([134.170.2.215]) by BLU004-WSS1S1.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751); Mon, 1 Jun 2015 05:31:28 -0700 X-TMN: [Dswnndmd/H8Tr1Hj4KhYHtEIY/Fbd796] Message-ID: From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Mon, 1 Jun 2015 20:31:14 +0800 X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1433161874-28857-1-git-send-email-bmeng.cn@gmail.com> References: <1433161874-28857-1-git-send-email-bmeng.cn@gmail.com> X-OriginalArrivalTime: 01 Jun 2015 12:31:27.0573 (UTC) FILETIME=[E1636850:01D09C66] MIME-Version: 1.0 Cc: Andrew Bradford Subject: [U-Boot] [RFC PATCH 2/2] x86: fsp: Move FspInitEntry call to board_init_f() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The call to FspInitEntry is done in arch/x86/lib/fsp/fsp_car.S so far. It worked pretty well but looks not that good. Apart from doing too much work than just enabling CAR, it cannot read the configuration data from device tree at that time. Now we want to move it a little bit later as part of init_sequence_f[] being called by board_init_f(). This way it looks and works better in the U-Boot initialization path. Due to FSP's design, after calling FspInitEntry it will not return to its caller, instead it jumps to a continuation function which is given by bootloader with a new stack in system memory. The original stack in the CAR is gone, but its content is perserved by FSP and described by a bootloader temporary memory HOB. Technically we can recover anything we had before in the previous stack, but that is way too complicated. To make life much easier, in the FSP continuation routine we just simply call fsp_init_done() and jump back to car_init_ret() to redo the whole board_init_f() initialization, but this time with a non-zero HOB list pointer saved in U-Boot's global data so that we can bypass the FspInitEntry for the second time. Signed-off-by: Bin Meng Tested-by: Andrew Bradford Acked-by: Simon Glass --- arch/x86/cpu/start.S | 6 +++++- arch/x86/include/asm/u-boot-x86.h | 4 ++++ arch/x86/lib/fsp/fsp_car.S | 26 +++++--------------------- arch/x86/lib/fsp/fsp_common.c | 8 ++++++++ common/board_f.c | 3 +++ 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index 2e5f9da..00e585e 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -116,12 +116,16 @@ car_init_ret: rep stosb #ifdef CONFIG_HAVE_FSP + test %esi, %esi + jz skip_hob + /* Store HOB list */ movl %esp, %edx addl $GD_HOB_LIST, %edx movl %esi, (%edx) -#endif +skip_hob: +#endif /* Setup first parameter to setup_gdt, pointer to global_data */ movl %esp, %eax diff --git a/arch/x86/include/asm/u-boot-x86.h b/arch/x86/include/asm/u-boot-x86.h index faa5182..9ee4104 100644 --- a/arch/x86/include/asm/u-boot-x86.h +++ b/arch/x86/include/asm/u-boot-x86.h @@ -54,6 +54,10 @@ u32 isa_map_rom(u32 bus_addr, int size); /* arch/x86/lib/... */ int video_bios_init(void); +#ifdef CONFIG_HAVE_FSP +int x86_fsp_init(void); +#endif + void board_init_f_r_trampoline(ulong) __attribute__ ((noreturn)); void board_init_f_r(void) __attribute__ ((noreturn)); diff --git a/arch/x86/lib/fsp/fsp_car.S b/arch/x86/lib/fsp/fsp_car.S index 5e09568..afbf3f9 100644 --- a/arch/x86/lib/fsp/fsp_car.S +++ b/arch/x86/lib/fsp/fsp_car.S @@ -56,28 +56,10 @@ temp_ram_init_ret: /* stack grows down from top of CAR */ movl %edx, %esp + subl $4, %esp - /* - * TODO: - * - * According to FSP architecture spec, the fsp_init() will not return - * to its caller, instead it requires the bootloader to provide a - * so-called continuation function to pass into the FSP as a parameter - * of fsp_init, and fsp_init() will call that continuation function - * directly. - * - * The call to fsp_init() may need to be moved out of the car_init() - * to cpu_init_f() with the help of some inline assembly codes. - * Note there is another issue that fsp_init() will setup another stack - * using the fsp_init parameter stack_top after DRAM is initialized, - * which means any data on the previous stack (on the CAR) gets lost - * (ie: U-Boot global_data). FSP is supposed to support such scenario, - * however it does not work. This should be revisited in the future. - */ - movl $CONFIG_FSP_TEMP_RAM_ADDR, %eax - xorl %edx, %edx - xorl %ecx, %ecx - call fsp_init + xor %esi, %esi + jmp car_init_done .global fsp_init_done fsp_init_done: @@ -86,6 +68,8 @@ fsp_init_done: * Save eax to esi temporarily. */ movl %eax, %esi + +car_init_done: /* * Re-initialize the ebp (BIST) to zero, as we already reach here * which means we passed BIST testing before. diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c index 001494d..5b25632 100644 --- a/arch/x86/lib/fsp/fsp_common.c +++ b/arch/x86/lib/fsp/fsp_common.c @@ -46,3 +46,11 @@ void board_final_cleanup(void) return; } + +int x86_fsp_init(void) +{ + if (!gd->arch.hob_list) + fsp_init(CONFIG_FSP_TEMP_RAM_ADDR, BOOT_FULL_CONFIG, NULL); + + return 0; +} diff --git a/common/board_f.c b/common/board_f.c index fbbad1b..21be26f 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -753,6 +753,9 @@ static init_fnc_t init_sequence_f[] = { #ifdef CONFIG_OF_CONTROL fdtdec_setup, #endif +#if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP) + x86_fsp_init, +#endif #ifdef CONFIG_TRACE trace_early_init, #endif