From patchwork Fri Dec 12 13:05:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 420469 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 CB0AE14003E for ; Sat, 13 Dec 2014 00:07:50 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8B8D94BA3F; Fri, 12 Dec 2014 14:07:19 +0100 (CET) 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 FPbDQGwMN1aV; Fri, 12 Dec 2014 14:07:19 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C0A954BA64; Fri, 12 Dec 2014 14:07:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F290A4BA1E for ; Fri, 12 Dec 2014 14:07:10 +0100 (CET) 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 ZmJB4LVtt4LF for ; Fri, 12 Dec 2014 14:07:10 +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-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by theia.denx.de (Postfix) with ESMTPS id 899B14BA37 for ; Fri, 12 Dec 2014 14:07:07 +0100 (CET) Received: by mail-pa0-f53.google.com with SMTP id kq14so7206670pab.12 for ; Fri, 12 Dec 2014 05:07:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=bKCvI/zSyPIgtFRUMaePLdKEFMH7eOmgckgSQNSw5OY=; b=ha92RZMvd04WP3TUleusy0QqPRrlCPCrI+bK5ZoXD4rrD7/+5JJTMBuGbibUgek3Hl uPBgFbH76k+TijjceoytaIG2aoJyJ/dHRRdPvQktumaTcnGWUk0QGjW6Jap1dROL0RV7 AGIx4HjiRWP5GPO55mPo0cWm6KsClgqU0QkraIUNABDqG196V59S402C85Fo6slWoP3Z plGGxl5bkbCOsNzTW9Y6QaM7a8ohddPcXxejx+sdcMxgXfO0oT1mIzNiOpTvQYvXYTU2 +WE4gMI1otvatlxvSh5TQbGJZEpJNjigqtzGz9ErFI2DIi9T+h28hhEM+RNjYwmDcQbj ppMA== X-Received: by 10.68.215.100 with SMTP id oh4mr26657178pbc.11.1418389625046; Fri, 12 Dec 2014 05:07:05 -0800 (PST) Received: from localhost ([106.120.101.38]) by mx.google.com with ESMTPSA id cb2sm1584564pac.24.2014.12.12.05.07.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 12 Dec 2014 05:07:04 -0800 (PST) From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Fri, 12 Dec 2014 21:05:29 +0800 Message-Id: <1418389545-11254-12-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1418389545-11254-1-git-send-email-bmeng.cn@gmail.com> References: <1418389545-11254-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v3 11/27] x86: queensbay: Adapt FSP support codes X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 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 Use inline assembly codes to call FspNotify() to make sure parameters are passed on the stack as required by the FSP calling convention. Signed-off-by: Bin Meng --- Changes in v3: - Move license header changes to last commit Changes in v2: - Update the codes to use U-Boot coding style arch/x86/cpu/queensbay/fsp_configs.c | 5 ++- arch/x86/cpu/queensbay/fsp_support.c | 39 ++++++++++++++-------- .../include/asm/arch-queensbay/fsp/fsp_support.h | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/arch/x86/cpu/queensbay/fsp_configs.c b/arch/x86/cpu/queensbay/fsp_configs.c index a7bb314..aef18fc 100644 --- a/arch/x86/cpu/queensbay/fsp_configs.c +++ b/arch/x86/cpu/queensbay/fsp_configs.c @@ -5,9 +5,8 @@ * SPDX-License-Identifier: Intel */ -#include -#include -#include "fsp_support.h" +#include +#include void update_fsp_upd(struct upd_region_t *fsp_upd) { diff --git a/arch/x86/cpu/queensbay/fsp_support.c b/arch/x86/cpu/queensbay/fsp_support.c index 2048030..df3bbd0 100644 --- a/arch/x86/cpu/queensbay/fsp_support.c +++ b/arch/x86/cpu/queensbay/fsp_support.c @@ -5,9 +5,9 @@ * SPDX-License-Identifier: Intel */ -#include -#include -#include "fsp_support.h" +#include +#include +#include /** * Reads a 64-bit value from memory that may be unaligned. @@ -99,13 +99,14 @@ u32 __attribute__((optimize("O0"))) find_fsp_header(void) return (u32)fsp; } -#ifdef __PRE_RAM__ void fsp_continue(struct shared_data_t *shared_data, u32 status, void *hob_list) { u32 stack_len; u32 stack_base; u32 stack_top; + post_code(POST_MRC); + ASSERT(status == 0); /* Get the migrated stack in normal memory */ @@ -121,7 +122,7 @@ void fsp_continue(struct shared_data_t *shared_data, u32 status, void *hob_list) ((u32)shared_data - *(u32 *)stack_top)); /* The boot loader main function entry */ - bl_main_continue(hob_list, shared_data); + fsp_init_done(hob_list); } void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf) @@ -178,6 +179,8 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf) shared_data.fsp_hdr = fsp_hdr; shared_data.stack_top = (u32 *)stack_top; + post_code(POST_PRE_MRC); + /* * Use ASM code to ensure the register value in EAX & ECX * will be passed into BlContinuationFunc @@ -187,11 +190,11 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf) "call *%%eax;" ".global asm_continuation;" "asm_continuation:;" - "popl %%eax;" /* pop out return address */ - "pushl %%ecx;" /* push shared_data pointer */ - "pushl %%eax;" /* push back return address */ + "movl %%ebx, %%eax;" /* shared_data */ + "movl 4(%%esp), %%edx;" /* status */ + "movl 8(%%esp), %%ecx;" /* hob_list */ "jmp fsp_continue;" - : : "m"(params_ptr), "a"(init), "c"(&shared_data) + : : "m"(params_ptr), "a"(init), "b"(&shared_data) ); /* @@ -209,12 +212,11 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf) ASSERT(FALSE); } -#else - u32 fsp_notify(struct fsp_header_t *fsp_hdr, u32 phase) { fsp_notify_f notify; struct fsp_notify_params_t params; + struct fsp_notify_params_t *params_ptr; u32 status; if (!fsp_hdr) @@ -227,13 +229,22 @@ u32 fsp_notify(struct fsp_header_t *fsp_hdr, u32 phase) notify = (fsp_notify_f)(fsp_hdr->img_base + fsp_hdr->fsp_notify); params.phase = phase; - status = notify(¶ms); + params_ptr = ¶ms; + + /* + * Use ASM code to ensure correct parameter is on the stack for + * FspNotify as U-Boot is using different ABI from FSP + */ + asm volatile ( + "pushl %1;" /* push notify phase */ + "call *%%eax;" /* call FspNotify */ + "addl $4, %%esp;" /* clean up the stack */ + : "=a"(status) : "m"(params_ptr), "a"(notify), "m"(*params_ptr) + ); return status; } -#endif /* __PRE_RAM__ */ - u32 get_usable_lowmem_top(const void *hob_list) { union hob_pointers_t hob; diff --git a/arch/x86/include/asm/arch-queensbay/fsp/fsp_support.h b/arch/x86/include/asm/arch-queensbay/fsp/fsp_support.h index 3e53ea1..3296a2b 100644 --- a/arch/x86/include/asm/arch-queensbay/fsp/fsp_support.h +++ b/arch/x86/include/asm/arch-queensbay/fsp/fsp_support.h @@ -26,7 +26,7 @@ struct shared_data_t { void asm_continuation(void); -void bl_main_continue(void *hob_list, struct shared_data_t *shared_data); +void fsp_init_done(void *hob_list); /** * FSP Continuation function