]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: mkeficapsule: use u-boot UUID library
authorCaleb Connolly <caleb.connolly@linaro.org>
Fri, 30 Aug 2024 12:34:38 +0000 (13:34 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 12 Sep 2024 15:35:37 +0000 (17:35 +0200)
Replace the use of libuuid with U-Boot's own UUID library. This prepares
us to add support for generating v5 GUIDs.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
tools/Makefile
tools/mkeficapsule.c

index 6a4280e3668ffa03f9291dfdfe070d31035282df..ee08a9675df883efbad6d6e665011354c3f32a71 100644 (file)
@@ -246,12 +246,12 @@ HOSTCFLAGS_asn1_compiler.o = -idirafter $(srctree)/include
 
 HOSTCFLAGS_mkeficapsule.o += \
        $(shell pkg-config --cflags gnutls 2> /dev/null || echo "")
-HOSTCFLAGS_mkeficapsule.o += \
-       $(shell pkg-config --cflags uuid 2> /dev/null || echo "")
 HOSTLDLIBS_mkeficapsule += \
        $(shell pkg-config --libs gnutls 2> /dev/null || echo "-lgnutls")
-HOSTLDLIBS_mkeficapsule += \
-       $(shell pkg-config --libs uuid 2> /dev/null || echo "-luuid")
+mkeficapsule-objs := generated/lib/uuid.o \
+       generated/lib/sha1.o \
+       $(LIBFDT_OBJS) \
+       mkeficapsule.o
 hostprogs-$(CONFIG_TOOLS_MKEFICAPSULE) += mkeficapsule
 
 mkfwumdata-objs := mkfwumdata.o generated/lib/crc32.o
index 1b53151d41a5f061145df14bb7845e67c411cb57..ede9de2bef799e22cb1e2a1dbe5a086a521f337c 100644 (file)
 
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <uuid/uuid.h>
 
 #include <gnutls/gnutls.h>
 #include <gnutls/pkcs7.h>
 #include <gnutls/abstract.h>
 
 #include <version.h>
+#include <u-boot/uuid.h>
 
 #include "eficapsule.h"
 
@@ -578,37 +578,6 @@ err:
        return ret;
 }
 
-/**
- * convert_uuid_to_guid() - convert UUID to GUID
- * @buf:       UUID binary
- *
- * UUID and GUID have the same data structure, but their binary
- * formats are different due to the endianness. See lib/uuid.c.
- * Since uuid_parse() can handle only UUID, this function must
- * be called to get correct data for GUID when parsing a string.
- *
- * The correct data will be returned in @buf.
- */
-void convert_uuid_to_guid(unsigned char *buf)
-{
-       unsigned char c;
-
-       c = buf[0];
-       buf[0] = buf[3];
-       buf[3] = c;
-       c = buf[1];
-       buf[1] = buf[2];
-       buf[2] = c;
-
-       c = buf[4];
-       buf[4] = buf[5];
-       buf[5] = c;
-
-       c = buf[6];
-       buf[6] = buf[7];
-       buf[7] = c;
-}
-
 static int create_empty_capsule(char *path, efi_guid_t *guid, bool fw_accept)
 {
        struct efi_capsule_header header = { 0 };
@@ -654,20 +623,10 @@ err:
 
 static void print_guid(void *ptr)
 {
-       int i;
-       efi_guid_t *guid = ptr;
-       const uint8_t seq[] = {
-               3, 2, 1, 0, '-', 5, 4, '-', 7, 6,
-               '-', 8, 9, '-', 10, 11, 12, 13, 14, 15 };
-
-       for (i = 0; i < ARRAY_SIZE(seq); i++) {
-               if (seq[i] == '-')
-                       putchar(seq[i]);
-               else
-                       printf("%02X", guid->b[seq[i]]);
-       }
+       static char buf[37] = { 0 };
 
-       printf("\n");
+       uuid_bin_to_str(ptr, buf, UUID_STR_FORMAT_GUID | UUID_STR_UPPER_CASE);
+       printf("%s\n", buf);
 }
 
 static uint32_t dump_fmp_payload_header(
@@ -907,11 +866,10 @@ int main(int argc, char **argv)
                                        "Image type already specified\n");
                                exit(EXIT_FAILURE);
                        }
-                       if (uuid_parse(optarg, uuid_buf)) {
+                       if (uuid_str_to_bin(optarg, uuid_buf, UUID_STR_FORMAT_GUID)) {
                                fprintf(stderr, "Wrong guid format\n");
                                exit(EXIT_FAILURE);
                        }
-                       convert_uuid_to_guid(uuid_buf);
                        guid = (efi_guid_t *)uuid_buf;
                        break;
                case 'i':