From: Caleb Connolly Date: Fri, 30 Aug 2024 12:34:38 +0000 (+0100) Subject: tools: mkeficapsule: use u-boot UUID library X-Git-Url: http://git.dujemihanovic.xyz/img/static/git-logo.png?a=commitdiff_plain;h=f102e0d08d53098dd171de773a5742ab7b66348c;p=u-boot.git tools: mkeficapsule: use u-boot UUID library 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 --- diff --git a/tools/Makefile b/tools/Makefile index 6a4280e366..ee08a9675d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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 diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index 1b53151d41..ede9de2bef 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -16,13 +16,13 @@ #include #include -#include #include #include #include #include +#include #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':