From: anonymix007 <48598263+anonymix007@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:56:56 +0000 (+0300) Subject: boot: Deduplicate efi.h and efi-fundamental.h X-Git-Tag: v258-rc1~1838^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48acd7fe90faf87d8dcb5c3873aadcd8d9444d6c;p=thirdparty%2Fsystemd.git boot: Deduplicate efi.h and efi-fundamental.h These definitions are needed for both userspace and EFI, so keep them in efi-fundamental.h --- diff --git a/src/boot/efi.h b/src/boot/efi.h index e1042635b9c..9cac1720721 100644 --- a/src/boot/efi.h +++ b/src/boot/efi.h @@ -6,6 +6,7 @@ #include #include +#include "efi-fundamental.h" #include "macro-fundamental.h" #if SD_BOOT @@ -118,30 +119,11 @@ typedef uint64_t EFI_PHYSICAL_ADDRESS; #define EFI_IP_ADDRESS_CONFLICT EFIERR(34) #define EFI_HTTP_ERROR EFIERR(35) -typedef struct { - uint32_t Data1; - uint16_t Data2; - uint16_t Data3; - uint8_t Data4[8]; -} EFI_GUID; - -#define GUID_DEF(d1, d2, d3, d4_1, d4_2, d4_3, d4_4, d4_5, d4_6, d4_7, d4_8) \ - { d1, d2, d3, { d4_1, d4_2, d4_3, d4_4, d4_5, d4_6, d4_7, d4_8 } } - -/* Creates a EFI_GUID pointer suitable for EFI APIs. Use of const allows the compiler to merge multiple - * uses (although, currently compilers do that regardless). Most EFI APIs declare their EFI_GUID input - * as non-const, but almost all of them are in fact const. */ -#define MAKE_GUID_PTR(name) ((EFI_GUID *) &(const EFI_GUID) name##_GUID) - /* These allow MAKE_GUID_PTR() to work without requiring an extra _GUID in the passed name. We want to * keep the GUID definitions in line with the UEFI spec. */ #define EFI_GLOBAL_VARIABLE_GUID EFI_GLOBAL_VARIABLE #define EFI_FILE_INFO_GUID EFI_FILE_INFO_ID -#define EFI_GLOBAL_VARIABLE \ - GUID_DEF(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c) -#define EFI_IMAGE_SECURITY_DATABASE_GUID \ - GUID_DEF(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f) #define EFI_CUSTOM_MODE_ENABLE_GUID \ GUID_DEF(0xc076ec0c, 0x7028, 0x4399, 0xa0, 0x72, 0x71, 0xee, 0x5c, 0x44, 0x8b, 0x9f) @@ -238,20 +220,6 @@ typedef enum { EfiResetPlatformSpecific, } EFI_RESET_TYPE; -typedef struct { - uint16_t Year; - uint8_t Month; - uint8_t Day; - uint8_t Hour; - uint8_t Minute; - uint8_t Second; - uint8_t Pad1; - uint32_t Nanosecond; - int16_t TimeZone; - uint8_t Daylight; - uint8_t Pad2; -} EFI_TIME; - typedef struct { uint32_t Resolution; uint32_t Accuracy; diff --git a/src/fundamental/efi-fundamental.h b/src/fundamental/efi-fundamental.h index f6729293a9c..de7ae6cd8a4 100644 --- a/src/fundamental/efi-fundamental.h +++ b/src/fundamental/efi-fundamental.h @@ -1,10 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#if !SD_BOOT -# include -# include -# include +#include /* Matches EFI API definition of the same structure for userspace */ typedef struct { @@ -14,9 +11,13 @@ typedef struct { uint8_t Data4[8]; } EFI_GUID; +#if !SD_BOOT +# include +# include static inline bool efi_guid_equal(const EFI_GUID *a, const EFI_GUID *b) { return memcmp(a, b, sizeof(EFI_GUID)) == 0; } +#endif typedef struct { EFI_GUID SignatureOwner; @@ -66,6 +67,9 @@ typedef struct { #define GUID_DEF(d1, d2, d3, d4_1, d4_2, d4_3, d4_4, d4_5, d4_6, d4_7, d4_8) \ { d1, d2, d3, { d4_1, d4_2, d4_3, d4_4, d4_5, d4_6, d4_7, d4_8 } } +/* Creates a EFI_GUID pointer suitable for EFI APIs. Use of const allows the compiler to merge multiple + * uses (although, currently compilers do that regardless). Most EFI APIs declare their EFI_GUID input + * as non-const, but almost all of them are in fact const. */ #define MAKE_GUID_PTR(name) ((EFI_GUID *) &(const EFI_GUID) name##_GUID) #define EFI_GLOBAL_VARIABLE \ @@ -77,5 +81,3 @@ typedef struct { GUID_DEF(0xa5c059a1, 0x94e4, 0x4aa7, 0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72) #define EFI_CERT_TYPE_PKCS7_GUID \ GUID_DEF(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7) - -#endif