From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rob Clark Date: Fri, 4 Aug 2017 15:31:53 -0400 Subject: [U-Boot] [PATCH v0 11/20] efi_loader: add guidstr helper In-Reply-To: <20170804193205.24669-1-robdclark@gmail.com> References: <20170804193205.24669-1-robdclark@gmail.com> Message-ID: <20170804193205.24669-12-robdclark@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de There are a couple places where we'll need GUID -> string. So add a helper. Signed-off-by: Rob Clark --- include/efi_loader.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/efi_loader.h b/include/efi_loader.h index 1028bfb75d..e6c46f713e 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -239,6 +239,21 @@ static inline int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2) return memcmp(g1, g2, sizeof(efi_guid_t)); } +static inline int guidstr(char *s, const efi_guid_t *g) +{ + /* unpacked-guid, otherwise we have to have to consider endianess */ + struct { + uint32_t data1; + uint16_t data2; + uint16_t data3; + uint8_t data4[8]; + } *ug = (void *)g; + return sprintf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + ug->data1, ug->data2, ug->data3, ug->data4[0], + ug->data4[1], ug->data4[2], ug->data4[3], ug->data4[4], + ug->data4[5], ug->data4[6], ug->data4[7]); +} + /* * Use these to indicate that your code / data should go into the EFI runtime * section and thus still be available when the OS is running -- 2.13.0