From: Michael Brown Date: Tue, 11 Nov 2025 14:38:59 +0000 (+0000) Subject: [efi] Skip including the EDK2 ProcessorBind.h header for 32-bit RISC-V X-Git-Tag: rolling/bin~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=360aa7064f9b8ab734ceeaf11d36f6d0ff59b9fa;p=thirdparty%2Fipxe.git [efi] Skip including the EDK2 ProcessorBind.h header for 32-bit RISC-V We currently include the EDK2 RiscV64/ProcessorBind.h header when building for 32-bit RISC-V, as a placeholder since there is no support for 32-bit RISC-V in upstream EDK2. This causes errors when attempting to use the EDK2 VA_START() et al macros, since RiscV64/ProcessorBind.h ends up defining UINTN with a size different from the size of a pointer. Fix by falling back to the generic definitions for UINTN etc (as used for EFI_HOSTONLY) whenever we don't have an architecture-specific ProcessorBind.h header available. Signed-off-by: Michael Brown --- diff --git a/src/include/ipxe/efi/ProcessorBind.h b/src/include/ipxe/efi/ProcessorBind.h index 08854c84f..21b873163 100644 --- a/src/include/ipxe/efi/ProcessorBind.h +++ b/src/include/ipxe/efi/ProcessorBind.h @@ -10,13 +10,43 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); * - mcb30 */ -#ifdef EFI_HOSTONLY +/* Determine EFI architecture name (if existent) */ +#if defined ( __i386__ ) +#define EFIARCH Ia32 +#endif +#if defined ( __x86_64__ ) +#define EFIARCH X64 +#endif +#if defined ( __arm__ ) +#define EFIARCH Arm +#endif +#if defined ( __aarch64__ ) +#define EFIARCH AArch64 +#endif +#if defined ( __loongarch__ ) +#define EFIARCH LoongArch64 +#endif +#if defined ( __riscv ) && ( _riscv_xlen == 64 ) +#define EFIARCH RiscV64 +#endif + +/* Determine architecture-specific ProcessorBind.h path */ +#define PROCESSORBIND(_arch) /* - * We cannot rely on the EDK2 ProcessorBind.h headers when compiling a - * binary for execution on the build host itself, since the host's CPU - * architecture may not even be supported by EDK2. + * We do not want to use any EFI-specific calling conventions etc when + * compiling a binary for execution on the build host itself. */ +#ifdef EFI_HOSTONLY +#undef EFIARCH +#endif + +#if defined ( EFIARCH ) + +/* Include architecture-specific ProcessorBind.h if existent */ +#include PROCESSORBIND(EFIARCH) + +#else /* EFIARCH */ /* Define the basic integer types in terms of the host's */ #include @@ -30,8 +60,8 @@ typedef uint16_t UINT16; typedef uint32_t UINT32; typedef uint64_t UINT64; typedef unsigned long UINTN; -typedef int8_t CHAR8; -typedef int16_t CHAR16; +typedef char CHAR8; +typedef uint16_t CHAR16; typedef uint8_t BOOLEAN; /* Define EFIAPI as whatever API the host uses by default */ @@ -40,35 +70,12 @@ typedef uint8_t BOOLEAN; /* Define an architecture-neutral MDE_CPU macro to prevent build errors */ #define MDE_CPU_EBC +/* Define a dummy boot file name to prevent build errors */ +#define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTNONE.EFI" + /* Define MAX_BIT in terms of UINTN */ #define MAX_BIT ( ( ( UINTN ) 1U ) << ( ( 8 * sizeof ( UINTN ) ) - 1 ) ) -#else /* EFI_HOSTONLY */ - -#ifdef __i386__ -#include -#endif - -#ifdef __x86_64__ -#include -#endif - -#ifdef __arm__ -#include -#endif - -#ifdef __aarch64__ -#include -#endif - -#ifdef __loongarch__ -#include -#endif - -#ifdef __riscv -#include -#endif - -#endif /* EFI_HOSTONLY */ +#endif /* EFIARCH */ #endif /* _IPXE_EFI_PROCESSOR_BIND_H */