diff options
author | Subrata Banik <subratabanik@google.com> | 2024-05-09 11:25:22 +0000 |
---|---|---|
committer | Subrata Banik <subratabanik@google.com> | 2024-05-11 08:28:17 +0000 |
commit | cf5fc2312aa21d6a9cc9dea6fe3bb905a2f64086 (patch) | |
tree | 0c8c9cc5e1219991148e87ef1e56aca6bb49dcb8 /src/include | |
parent | f5be5e49993732b02221cd1935bdc12de1a38ac6 (diff) |
include/efi: Override EFIAPI macro for x86_64
This commit overrides the EFIAPI macro definition when using FSP on
x86_64 to ensure the correct calling convention is used.
On i386, there is no side-effect since the C calling convention used
by coreboot and FSP are the same. However, on x86_64, FSP/UEFI uses
the Microsoft x64 calling convention while coreboot uses the System
V AMD64 ABI.
This change resolves this incompatibility by setting EFIAPI to
attribute((ms_abi)) on x86_64 when using FSP.
TEST=Able to build google/rex0 in 32-bit and 64-bit mode.
Change-Id: Ifae910be66d550af04cce5136d186a7e9dd085b3
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/82266
Reviewed-by: Ronak Kanabar <ronak.kanabar@intel.com>
Reviewed-by: Eric Lai <ericllai@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/efi/efi_datatype.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/include/efi/efi_datatype.h b/src/include/efi/efi_datatype.h index 0333a84a4e..d4152af754 100644 --- a/src/include/efi/efi_datatype.h +++ b/src/include/efi/efi_datatype.h @@ -3,6 +3,22 @@ /* Create EFI equivalent datatype in coreboot based on UEFI specification */ #ifndef __EFI_DATATYPE_H__ #define __EFI_DATATYPE_H__ + +/* + * EDK2 EFIAPI macro definition relies on compiler flags such as __GNUC__ which + * is not working well when included by coreboot. While it has no side-effect on + * i386 because the C calling convention used by coreboot and FSP are the same, + * it breaks on x86_64 because FSP/UEFI uses the Microsoft x64 calling + * convention while coreboot uses the System V AMD64 ABI. + * + * Fortunately, EDK2 header allows to override EFIAPI. + */ +#if CONFIG(PLATFORM_USES_FSP2_X86_32) +#define EFIAPI __attribute__((regparm(0))) +#else +#define EFIAPI __attribute__((__ms_abi__)) +#endif + #include <Base.h> #include <Uefi/UefiBaseType.h> |