x86: use EFI calling convention for efi_main on x86_64
UEFI specifies the calling convention used in Microsoft compilers; first arguments of a function are passed in (%rcx, %rdx, %r8, %r9). All other compilers use System V ABI by default, passing first integer arguments of a function in (%rdi, %rsi, %rdx, %rcx, %r8, %r9). These ABI also specify different sets of registers that must be preserved across function calls (callee-saved). GCC allows using the Microsoft calling convention by adding the ms_abi attribute to a function declaration. Current EFI implementation in U-Boot specifies EFIAPI for efi_main() in the test apps but uses default calling convention in lib/efi. Save efi_main() arguments in the startup code on x86_64; use EFI calling convention for _relocate() on x86_64; consistently use EFI calling convention for efi_main() everywhere. Signed-off-by: Ivan Gorinov <ivan.gorinov@intel.com> Reviewed-by: Alexander Graf <agraf@suse.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
e3ec0d03bb
commit
9f0b0113c9
@ -3,7 +3,7 @@
|
|||||||
* crt0-efi-x86_64.S - x86_64 EFI startup code.
|
* crt0-efi-x86_64.S - x86_64 EFI startup code.
|
||||||
* Copyright (C) 1999 Hewlett-Packard Co.
|
* Copyright (C) 1999 Hewlett-Packard Co.
|
||||||
* Contributed by David Mosberger <davidm@hpl.hp.com>.
|
* Contributed by David Mosberger <davidm@hpl.hp.com>.
|
||||||
* Copyright (C) 2005 Intel Co.
|
* Copyright (C) 2005 Intel Corporation
|
||||||
* Contributed by Fenghua Yu <fenghua.yu@intel.com>.
|
* Contributed by Fenghua Yu <fenghua.yu@intel.com>.
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -14,26 +14,28 @@
|
|||||||
.globl _start
|
.globl _start
|
||||||
_start:
|
_start:
|
||||||
subq $8, %rsp
|
subq $8, %rsp
|
||||||
|
|
||||||
pushq %rcx
|
pushq %rcx
|
||||||
pushq %rdx
|
pushq %rdx
|
||||||
|
|
||||||
0:
|
mov %rcx, %r8
|
||||||
lea image_base(%rip), %rdi
|
mov %rdx, %r9
|
||||||
lea _DYNAMIC(%rip), %rsi
|
|
||||||
|
lea image_base(%rip), %rcx
|
||||||
|
lea _DYNAMIC(%rip), %rdx
|
||||||
|
|
||||||
popq %rcx
|
|
||||||
popq %rdx
|
|
||||||
pushq %rcx
|
|
||||||
pushq %rdx
|
|
||||||
call _relocate
|
call _relocate
|
||||||
|
|
||||||
popq %rdi
|
popq %rdx
|
||||||
popq %rsi
|
popq %rcx
|
||||||
|
|
||||||
|
testq %rax, %rax
|
||||||
|
jnz .exit
|
||||||
|
|
||||||
call efi_main
|
call efi_main
|
||||||
|
.exit:
|
||||||
addq $8, %rsp
|
addq $8, %rsp
|
||||||
|
|
||||||
.exit:
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -96,7 +96,8 @@ static void free_memory(struct efi_priv *priv)
|
|||||||
* U-Boot. If it returns, EFI will continue. Another way to get back to EFI
|
* U-Boot. If it returns, EFI will continue. Another way to get back to EFI
|
||||||
* is via reset_cpu().
|
* is via reset_cpu().
|
||||||
*/
|
*/
|
||||||
efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
|
efi_status_t EFIAPI efi_main(efi_handle_t image,
|
||||||
|
struct efi_system_table *sys_table)
|
||||||
{
|
{
|
||||||
struct efi_priv local_priv, *priv = &local_priv;
|
struct efi_priv local_priv, *priv = &local_priv;
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
|
@ -268,7 +268,8 @@ static void add_entry_addr(struct efi_priv *priv, enum efi_entry_t type,
|
|||||||
* This function is called by our EFI start-up code. It handles running
|
* This function is called by our EFI start-up code. It handles running
|
||||||
* U-Boot. If it returns, EFI will continue.
|
* U-Boot. If it returns, EFI will continue.
|
||||||
*/
|
*/
|
||||||
efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table)
|
efi_status_t EFIAPI efi_main(efi_handle_t image,
|
||||||
|
struct efi_system_table *sys_table)
|
||||||
{
|
{
|
||||||
struct efi_priv local_priv, *priv = &local_priv;
|
struct efi_priv local_priv, *priv = &local_priv;
|
||||||
struct efi_boot_services *boot = sys_table->boottime;
|
struct efi_boot_services *boot = sys_table->boottime;
|
||||||
|
Loading…
Reference in New Issue
Block a user