From: Jan Janssen Date: Wed, 22 Feb 2023 14:19:14 +0000 (+0100) Subject: boot: Add GUID format helper macro X-Git-Tag: v254-rc1~1184^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea592abfc68c69ab51b3e332c8972d3af7c45e3a;p=thirdparty%2Fsystemd.git boot: Add GUID format helper macro --- diff --git a/src/boot/efi/part-discovery.c b/src/boot/efi/part-discovery.c index 68dcf888720..4769d11bd87 100644 --- a/src/boot/efi/part-discovery.c +++ b/src/boot/efi/part-discovery.c @@ -294,26 +294,7 @@ char16_t *disk_get_part_uuid(EFI_HANDLE *handle) { if (hd.SignatureType != SIGNATURE_TYPE_GUID) continue; - return xasprintf( - "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", - hd.Signature[3], - hd.Signature[2], - hd.Signature[1], - hd.Signature[0], - - hd.Signature[5], - hd.Signature[4], - hd.Signature[7], - hd.Signature[6], - - hd.Signature[8], - hd.Signature[9], - hd.Signature[10], - hd.Signature[11], - hd.Signature[12], - hd.Signature[13], - hd.Signature[14], - hd.Signature[15]); + return xasprintf(GUID_FORMAT_STR, GUID_FORMAT_VAL(hd.SignatureGuid)); } return NULL; diff --git a/src/boot/efi/proto/device-path.h b/src/boot/efi/proto/device-path.h index df7a6a08f9c..0fabae1125c 100644 --- a/src/boot/efi/proto/device-path.h +++ b/src/boot/efi/proto/device-path.h @@ -54,7 +54,10 @@ typedef struct { uint32_t PartitionNumber; uint64_t PartitionStart; uint64_t PartitionSize; - uint8_t Signature[16]; + union { + uint8_t Signature[16]; + EFI_GUID SignatureGuid; + }; uint8_t MBRType; uint8_t SignatureType; } _packed_ HARDDRIVE_DEVICE_PATH; diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index 198e8449716..a28228c4cc1 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -119,6 +119,11 @@ static inline void unload_imagep(EFI_HANDLE *image) { #define LOADER_GUID \ { 0x4a67b082, 0x0a4c, 0x41cf, { 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f } } +/* Note that GUID is evaluated multiple times! */ +#define GUID_FORMAT_STR "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X" +#define GUID_FORMAT_VAL(g) (g).Data1, (g).Data2, (g).Data3, (g).Data4[0], (g).Data4[1], \ + (g).Data4[2], (g).Data4[3], (g).Data4[4], (g).Data4[5], (g).Data4[6], (g).Data4[7] + void print_at(size_t x, size_t y, size_t attr, const char16_t *str); void clear_screen(size_t attr);