Re: [U-Boot] [PATCH] x86: use EFI calling convention for efi_main on x86_64

2018-05-25 Thread Heinrich Schuchardt
On 05/25/2018 11:28 PM, Ivan Gorinov wrote:
> Save the arguments passed in %rcx and %rdx for efi_main() on x86_64;
> consistently use EFI calling convention for efi_main().
> 
> Signed-off-by: Ivan Gorinov 

One big difference between the ms_abi and the sysv_abi calling
convention is the set of volatile registers. So shouldn't _relocate()
also be declared as EFIAPI to ensure that we do not mess up the callers
registers?

Best regards

Heinrich

> ---
>  arch/x86/lib/crt0_x86_64_efi.S | 8 
>  lib/efi/efi_app.c  | 3 ++-
>  lib/efi/efi_stub.c | 3 ++-
>  3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/lib/crt0_x86_64_efi.S b/arch/x86/lib/crt0_x86_64_efi.S
> index 989799f..2d53d1b 100644
> --- a/arch/x86/lib/crt0_x86_64_efi.S
> +++ b/arch/x86/lib/crt0_x86_64_efi.S
> @@ -16,19 +16,19 @@ _start:
>   subq $8, %rsp
>   pushq %rcx
>   pushq %rdx
> + pushq %rsi
> + pushq %rdi
>  
>  0:
>   lea image_base(%rip), %rdi
>   lea _DYNAMIC(%rip), %rsi
>  
> - popq %rcx
> - popq %rdx
> - pushq %rcx
> - pushq %rdx
>   call _relocate
>  
>   popq %rdi
>   popq %rsi
> + popq %rdx
> + popq %rcx
>  
>   call efi_main
>   addq $8, %rsp
> diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
> index c828093..3eb8eeb 100644
> --- a/lib/efi/efi_app.c
> +++ b/lib/efi/efi_app.c
> @@ -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
>   * 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 = _priv;
>   efi_status_t ret;
> diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
> index 3138739..399d16b 100644
> --- a/lib/efi/efi_stub.c
> +++ b/lib/efi/efi_stub.c
> @@ -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
>   * 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 = _priv;
>   struct efi_boot_services *boot = sys_table->boottime;
> 

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] x86: use EFI calling convention for efi_main on x86_64

2018-05-25 Thread Ivan Gorinov
Save the arguments passed in %rcx and %rdx for efi_main() on x86_64;
consistently use EFI calling convention for efi_main().

Signed-off-by: Ivan Gorinov 
---
 arch/x86/lib/crt0_x86_64_efi.S | 8 
 lib/efi/efi_app.c  | 3 ++-
 lib/efi/efi_stub.c | 3 ++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/x86/lib/crt0_x86_64_efi.S b/arch/x86/lib/crt0_x86_64_efi.S
index 989799f..2d53d1b 100644
--- a/arch/x86/lib/crt0_x86_64_efi.S
+++ b/arch/x86/lib/crt0_x86_64_efi.S
@@ -16,19 +16,19 @@ _start:
subq $8, %rsp
pushq %rcx
pushq %rdx
+   pushq %rsi
+   pushq %rdi
 
 0:
lea image_base(%rip), %rdi
lea _DYNAMIC(%rip), %rsi
 
-   popq %rcx
-   popq %rdx
-   pushq %rcx
-   pushq %rdx
call _relocate
 
popq %rdi
popq %rsi
+   popq %rdx
+   popq %rcx
 
call efi_main
addq $8, %rsp
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index c828093..3eb8eeb 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -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
  * 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 = _priv;
efi_status_t ret;
diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c
index 3138739..399d16b 100644
--- a/lib/efi/efi_stub.c
+++ b/lib/efi/efi_stub.c
@@ -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
  * 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 = _priv;
struct efi_boot_services *boot = sys_table->boottime;
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot