diff mbox series

[U-Boot,v7,2/9] x86: lib: fsp: Use EFI_GUID and efi_guid_t

Message ID A1484485FD99714DB2AB2C5EF81E7AC2AA75B68B@ORSMSX116.amr.corp.intel.com
State Superseded
Delegated to: Bin Meng
Headers show
Series x86: Add basic Slim Bootloader payload support | expand

Commit Message

Park, Aiden July 29, 2019, 4:35 a.m. UTC
Use existing EFI_GUID and efi_guid_t instead of struct efi_guid.
This is pre-work before making a common HOB library.
- Change 'struct efi_guid' to efi_guit_t
- Remove 'struct efi_guid'
- Define GUIDs with EFI_GUID() macro
- Use guidcmp() instead of compare_guid()
- Remove compare_guid()

Signed-off-by: Aiden Park <aiden.park@intel.com>
---

Changes in v7:
  * Split HOB library into EFI_GUID pre-work and making a common library

 arch/x86/include/asm/fsp/fsp_ffs.h     |  4 +-
 arch/x86/include/asm/fsp/fsp_fv.h      |  4 +-
 arch/x86/include/asm/fsp/fsp_hob.h     | 76 +++++++++++++------------
 arch/x86/include/asm/fsp/fsp_support.h |  6 +-
 arch/x86/include/asm/fsp/fsp_types.h   |  8 ---
 arch/x86/lib/fsp/fsp_support.c         | 78 ++++++++++----------------
 cmd/x86/fsp.c                          | 10 ++--
 7 files changed, 81 insertions(+), 105 deletions(-)

Comments

Andy Shevchenko July 29, 2019, 9:02 a.m. UTC | #1
On Mon, Jul 29, 2019 at 7:35 AM Park, Aiden <aiden.park@intel.com> wrote:
>
> Use existing EFI_GUID and efi_guid_t instead of struct efi_guid.
> This is pre-work before making a common HOB library.
> - Change 'struct efi_guid' to efi_guit_t
> - Remove 'struct efi_guid'
> - Define GUIDs with EFI_GUID() macro
> - Use guidcmp() instead of compare_guid()
> - Remove compare_guid()
>

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>
> Changes in v7:
>   * Split HOB library into EFI_GUID pre-work and making a common library
>
>  arch/x86/include/asm/fsp/fsp_ffs.h     |  4 +-
>  arch/x86/include/asm/fsp/fsp_fv.h      |  4 +-
>  arch/x86/include/asm/fsp/fsp_hob.h     | 76 +++++++++++++------------
>  arch/x86/include/asm/fsp/fsp_support.h |  6 +-
>  arch/x86/include/asm/fsp/fsp_types.h   |  8 ---
>  arch/x86/lib/fsp/fsp_support.c         | 78 ++++++++++----------------
>  cmd/x86/fsp.c                          | 10 ++--
>  7 files changed, 81 insertions(+), 105 deletions(-)
>
> diff --git a/arch/x86/include/asm/fsp/fsp_ffs.h b/arch/x86/include/asm/fsp/fsp_ffs.h
> index 61ce63c08e..b7558e5a17 100644
> --- a/arch/x86/include/asm/fsp/fsp_ffs.h
> +++ b/arch/x86/include/asm/fsp/fsp_ffs.h
> @@ -45,7 +45,7 @@ struct __packed ffs_file_header {
>          * This GUID is the file name.
>          * It is used to uniquely identify the file.
>          */
> -       struct efi_guid         name;
> +       efi_guid_t              name;
>         /* Used to verify the integrity of the file */
>         union ffs_integrity     integrity;
>         /* Identifies the type of file */
> @@ -68,7 +68,7 @@ struct __packed ffs_file_header2 {
>          * Name in any given firmware volume, except if the file type is
>          * EFI_FV_FILE_TYPE_FFS_PAD.
>          */
> -       struct efi_guid         name;
> +       efi_guid_t              name;
>         /* Used to verify the integrity of the file */
>         union ffs_integrity     integrity;
>         /* Identifies the type of file */
> diff --git a/arch/x86/include/asm/fsp/fsp_fv.h b/arch/x86/include/asm/fsp/fsp_fv.h
> index 190aedcf44..511dfb78b8 100644
> --- a/arch/x86/include/asm/fsp/fsp_fv.h
> +++ b/arch/x86/include/asm/fsp/fsp_fv.h
> @@ -80,7 +80,7 @@ struct fv_header {
>          * Declares the file system with which the firmware volume
>          * is formatted.
>          */
> -       struct efi_guid         fs_guid;
> +       efi_guid_t              fs_guid;
>         /*
>          * Length in bytes of the complete firmware volume, including
>          * the header.
> @@ -128,7 +128,7 @@ struct fv_header {
>  /* Extension header pointed by ExtHeaderOffset of volume header */
>  struct fv_ext_header {
>         /* firmware volume name */
> -       struct efi_guid         fv_name;
> +       efi_guid_t              fv_name;
>         /* Size of the rest of the extension header including this structure */
>         u32                     ext_hdr_size;
>  };
> diff --git a/arch/x86/include/asm/fsp/fsp_hob.h b/arch/x86/include/asm/fsp/fsp_hob.h
> index 00657b62c7..843d7b513b 100644
> --- a/arch/x86/include/asm/fsp/fsp_hob.h
> +++ b/arch/x86/include/asm/fsp/fsp_hob.h
> @@ -8,6 +8,7 @@
>  #define __FSP_HOB_H__
>
>  #include <efi.h>
> +#include <efi_loader.h>
>
>  /* Type of HOB Header */
>  #define HOB_TYPE_MEM_ALLOC     0x0002
> @@ -40,7 +41,7 @@ struct hob_mem_alloc {
>          * present for the memory allocation HOB. Type efi_guid is defined in
>          * InstallProtocolInterface() in the UEFI 2.0 specification.
>          */
> -       struct efi_guid         name;
> +       efi_guid_t              name;
>         /*
>          * The base address of memory allocated by this HOB.
>          * Type phys_addr_t is defined in AllocatePages() in the UEFI 2.0
> @@ -106,7 +107,7 @@ struct hob_res_desc {
>          * used by HOB consumer phase components to correlate device
>          * ownership of a resource.
>          */
> -       struct efi_guid         owner;
> +       efi_guid_t              owner;
>         u32                     type;
>         u32                     attr;
>         /* The physical start address of the resource region */
> @@ -122,7 +123,7 @@ struct hob_res_desc {
>  struct hob_guid {
>         struct hob_header       hdr;
>         /* A GUID that defines the contents of this HOB */
> -       struct efi_guid         name;
> +       efi_guid_t              name;
>         /* GUID specific data goes here */
>  };
>
> @@ -223,56 +224,57 @@ static inline u16 get_guid_hob_data_size(const struct hob_header *hdr)
>  #define FSP_GUID_DATA4_6       0x3f
>  #define FSP_GUID_DATA4_7       0x0c
>
> +#define FSP_GUID_BYTE0         0xbe
> +#define FSP_GUID_BYTE1         0x40
> +#define FSP_GUID_BYTE2         0x27
> +#define FSP_GUID_BYTE3         0x91
> +#define FSP_GUID_BYTE4         0x84
> +#define FSP_GUID_BYTE5         0x22
> +#define FSP_GUID_BYTE6         0x34
> +#define FSP_GUID_BYTE7         0x47
> +#define FSP_GUID_BYTE8         FSP_GUID_DATA4_0
> +#define FSP_GUID_BYTE9         FSP_GUID_DATA4_1
> +#define FSP_GUID_BYTE10                FSP_GUID_DATA4_2
> +#define FSP_GUID_BYTE11                FSP_GUID_DATA4_3
> +#define FSP_GUID_BYTE12                FSP_GUID_DATA4_4
> +#define FSP_GUID_BYTE13                FSP_GUID_DATA4_5
> +#define FSP_GUID_BYTE14                FSP_GUID_DATA4_6
> +#define FSP_GUID_BYTE15                FSP_GUID_DATA4_7
> +
>  #define FSP_HEADER_GUID \
> -       { \
> -       FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
> -       { FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
> -         FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
> -         FSP_GUID_DATA4_6, FSP_GUID_DATA4_7 } \
> -       }
> +       EFI_GUID(FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
> +               FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
> +               FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
> +               FSP_GUID_DATA4_6, FSP_GUID_DATA4_7)
>
>  #define FSP_NON_VOLATILE_STORAGE_HOB_GUID \
> -       { \
> -       0x721acf02, 0x4d77, 0x4c2a, \
> -       { 0xb3, 0xdc, 0x27, 0xb, 0x7b, 0xa9, 0xe4, 0xb0 } \
> -       }
> +       EFI_GUID(0x721acf02, 0x4d77, 0x4c2a, \
> +               0xb3, 0xdc, 0x27, 0x0b, 0x7b, 0xa9, 0xe4, 0xb0)
>
>  #define FSP_BOOTLOADER_TEMP_MEM_HOB_GUID \
> -       { \
> -       0xbbcff46c, 0xc8d3, 0x4113, \
> -       { 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e } \
> -       }
> +       EFI_GUID(0xbbcff46c, 0xc8d3, 0x4113, \
> +               0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e)
>
>  #define FSP_HOB_RESOURCE_OWNER_FSP_GUID \
> -       { \
> -       0x69a79759, 0x1373, 0x4367, \
> -       { 0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e } \
> -       }
> +       EFI_GUID(0x69a79759, 0x1373, 0x4367, \
> +               0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e)
>
>  #define FSP_HOB_RESOURCE_OWNER_TSEG_GUID \
> -       { \
> -       0xd038747c, 0xd00c, 0x4980, \
> -       { 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55 } \
> -       }
> +       EFI_GUID(0xd038747c, 0xd00c, 0x4980, \
> +               0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55)
>
>  #define FSP_HOB_RESOURCE_OWNER_GRAPHICS_GUID \
> -       { \
> -       0x9c7c3aa7, 0x5332, 0x4917, \
> -       { 0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07 } \
> -       }
> +       EFI_GUID(0x9c7c3aa7, 0x5332, 0x4917, \
> +               0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07)
>
>  /* The following GUIDs are newly introduced in FSP spec 1.1 */
>
>  #define FSP_HOB_RESOURCE_OWNER_BOOTLOADER_TOLUM_GUID \
> -       { \
> -       0x73ff4f56, 0xaa8e, 0x4451, \
> -       { 0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44 } \
> -       }
> +       EFI_GUID(0x73ff4f56, 0xaa8e, 0x4451, \
> +               0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44)
>
>  #define FSP_GRAPHICS_INFO_HOB_GUID \
> -       { \
> -       0x39f62cce, 0x6825, 0x4669, \
> -       { 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 } \
> -       }
> +       EFI_GUID(0x39f62cce, 0x6825, 0x4669, \
> +               0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07)
>
>  #endif
> diff --git a/arch/x86/include/asm/fsp/fsp_support.h b/arch/x86/include/asm/fsp/fsp_support.h
> index 7e51f24b12..0cca948184 100644
> --- a/arch/x86/include/asm/fsp/fsp_support.h
> +++ b/arch/x86/include/asm/fsp/fsp_support.h
> @@ -106,7 +106,7 @@ u64 fsp_get_usable_highmem_top(const void *hob_list);
>   *            0 if this region does not exist.
>   */
>  u64 fsp_get_reserved_mem_from_guid(const void *hob_list,
> -                                  u64 *len, struct efi_guid *guid);
> +                                  u64 *len, const efi_guid_t *guid);
>
>  /**
>   * This function retrieves the FSP reserved normal memory.
> @@ -149,7 +149,7 @@ const struct hob_header *fsp_get_next_hob(uint type, const void *hob_list);
>   *
>   * @retval:   A HOB object with matching GUID; Otherwise NULL.
>   */
> -const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
> +const struct hob_header *fsp_get_next_guid_hob(const efi_guid_t *guid,
>                                                const void *hob_list);
>
>  /**
> @@ -164,7 +164,7 @@ const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
>   * @retval others: GUID HOB data buffer pointer.
>   */
>  void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
> -                           struct efi_guid *guid);
> +                           const efi_guid_t *guid);
>
>  /**
>   * This function retrieves FSP Non-volatile Storage HOB buffer and size.
> diff --git a/arch/x86/include/asm/fsp/fsp_types.h b/arch/x86/include/asm/fsp/fsp_types.h
> index 5247102f75..3d5b17ecf1 100644
> --- a/arch/x86/include/asm/fsp/fsp_types.h
> +++ b/arch/x86/include/asm/fsp/fsp_types.h
> @@ -7,14 +7,6 @@
>  #ifndef __FSP_TYPES_H__
>  #define __FSP_TYPES_H__
>
> -/* 128 bit buffer containing a unique identifier value */
> -struct efi_guid {
> -       u32     data1;
> -       u16     data2;
> -       u16     data3;
> -       u8      data4[8];
> -};
> -
>  /**
>   * Returns a 16-bit signature built from 2 ASCII characters.
>   *
> diff --git a/arch/x86/lib/fsp/fsp_support.c b/arch/x86/lib/fsp/fsp_support.c
> index 90e4e7db26..0d1bb35186 100644
> --- a/arch/x86/lib/fsp/fsp_support.c
> +++ b/arch/x86/lib/fsp/fsp_support.c
> @@ -8,27 +8,6 @@
>  #include <asm/fsp/fsp_support.h>
>  #include <asm/post.h>
>
> -/**
> - * Compares two GUIDs
> - *
> - * If the GUIDs are identical then true is returned.
> - * If there are any bit differences in the two GUIDs, then false is returned.
> - *
> - * @guid1:        A pointer to a 128 bit GUID.
> - * @guid2:        A pointer to a 128 bit GUID.
> - *
> - * @retval true:  guid1 and guid2 are identical.
> - * @retval false: guid1 and guid2 are not identical.
> - */
> -static bool compare_guid(const struct efi_guid *guid1,
> -                        const struct efi_guid *guid2)
> -{
> -       if (memcmp(guid1, guid2, sizeof(struct efi_guid)) == 0)
> -               return true;
> -       else
> -               return false;
> -}
> -
>  struct fsp_header *__attribute__((optimize("O0"))) find_fsp_header(void)
>  {
>         /*
> @@ -58,17 +37,22 @@ struct fsp_header *__attribute__((optimize("O0"))) find_fsp_header(void)
>
>         /* Check the FFS GUID */
>         if (fsp &&
> -           ((struct ffs_file_header *)fsp)->name.data1 == FSP_GUID_DATA1 &&
> -           ((struct ffs_file_header *)fsp)->name.data2 == FSP_GUID_DATA2 &&
> -           ((struct ffs_file_header *)fsp)->name.data3 == FSP_GUID_DATA3 &&
> -           ((struct ffs_file_header *)fsp)->name.data4[0] == FSP_GUID_DATA4_0 &&
> -           ((struct ffs_file_header *)fsp)->name.data4[1] == FSP_GUID_DATA4_1 &&
> -           ((struct ffs_file_header *)fsp)->name.data4[2] == FSP_GUID_DATA4_2 &&
> -           ((struct ffs_file_header *)fsp)->name.data4[3] == FSP_GUID_DATA4_3 &&
> -           ((struct ffs_file_header *)fsp)->name.data4[4] == FSP_GUID_DATA4_4 &&
> -           ((struct ffs_file_header *)fsp)->name.data4[5] == FSP_GUID_DATA4_5 &&
> -           ((struct ffs_file_header *)fsp)->name.data4[6] == FSP_GUID_DATA4_6 &&
> -           ((struct ffs_file_header *)fsp)->name.data4[7] == FSP_GUID_DATA4_7) {
> +           ((struct ffs_file_header *)fsp)->name.b[0] == FSP_GUID_BYTE0 &&
> +           ((struct ffs_file_header *)fsp)->name.b[1] == FSP_GUID_BYTE1 &&
> +           ((struct ffs_file_header *)fsp)->name.b[2] == FSP_GUID_BYTE2 &&
> +           ((struct ffs_file_header *)fsp)->name.b[3] == FSP_GUID_BYTE3 &&
> +           ((struct ffs_file_header *)fsp)->name.b[4] == FSP_GUID_BYTE4 &&
> +           ((struct ffs_file_header *)fsp)->name.b[5] == FSP_GUID_BYTE5 &&
> +           ((struct ffs_file_header *)fsp)->name.b[6] == FSP_GUID_BYTE6 &&
> +           ((struct ffs_file_header *)fsp)->name.b[7] == FSP_GUID_BYTE7 &&
> +           ((struct ffs_file_header *)fsp)->name.b[8] == FSP_GUID_BYTE8 &&
> +           ((struct ffs_file_header *)fsp)->name.b[9] == FSP_GUID_BYTE9 &&
> +           ((struct ffs_file_header *)fsp)->name.b[10] == FSP_GUID_BYTE10 &&
> +           ((struct ffs_file_header *)fsp)->name.b[11] == FSP_GUID_BYTE11 &&
> +           ((struct ffs_file_header *)fsp)->name.b[12] == FSP_GUID_BYTE12 &&
> +           ((struct ffs_file_header *)fsp)->name.b[13] == FSP_GUID_BYTE13 &&
> +           ((struct ffs_file_header *)fsp)->name.b[14] == FSP_GUID_BYTE14 &&
> +           ((struct ffs_file_header *)fsp)->name.b[15] == FSP_GUID_BYTE15) {
>                 /* Add the FFS header size to find the raw section header */
>                 fsp += sizeof(struct ffs_file_header);
>         } else {
> @@ -305,7 +289,7 @@ u64 fsp_get_usable_highmem_top(const void *hob_list)
>  }
>
>  u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
> -                                  struct efi_guid *guid)
> +                                  const efi_guid_t *guid)
>  {
>         const struct hob_header *hdr;
>         struct hob_res_desc *res_desc;
> @@ -318,7 +302,7 @@ u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
>                 if (hdr->type == HOB_TYPE_RES_DESC) {
>                         res_desc = (struct hob_res_desc *)hdr;
>                         if (res_desc->type == RES_MEM_RESERVED) {
> -                               if (compare_guid(&res_desc->owner, guid)) {
> +                               if (!guidcmp(&res_desc->owner, guid)) {
>                                         if (len)
>                                                 *len = (u32)(res_desc->len);
>
> @@ -334,12 +318,12 @@ u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
>
>  u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len)
>  {
> -       const struct efi_guid guid = FSP_HOB_RESOURCE_OWNER_FSP_GUID;
> +       const efi_guid_t guid = FSP_HOB_RESOURCE_OWNER_FSP_GUID;
>         u64 length;
>         u32 base;
>
>         base = (u32)fsp_get_reserved_mem_from_guid(hob_list,
> -                       &length, (struct efi_guid *)&guid);
> +                       &length, &guid);
>         if ((len != 0) && (base != 0))
>                 *len = (u32)length;
>
> @@ -348,12 +332,12 @@ u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len)
>
>  u32 fsp_get_tseg_reserved_mem(const void *hob_list, u32 *len)
>  {
> -       const struct efi_guid guid = FSP_HOB_RESOURCE_OWNER_TSEG_GUID;
> +       const efi_guid_t guid = FSP_HOB_RESOURCE_OWNER_TSEG_GUID;
>         u64 length;
>         u32 base;
>
>         base = (u32)fsp_get_reserved_mem_from_guid(hob_list,
> -                       &length, (struct efi_guid *)&guid);
> +                       &length, &guid);
>         if ((len != 0) && (base != 0))
>                 *len = (u32)length;
>
> @@ -377,7 +361,7 @@ const struct hob_header *fsp_get_next_hob(uint type, const void *hob_list)
>         return NULL;
>  }
>
> -const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
> +const struct hob_header *fsp_get_next_guid_hob(const efi_guid_t *guid,
>                                                const void *hob_list)
>  {
>         const struct hob_header *hdr;
> @@ -387,7 +371,7 @@ const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
>         while ((hdr = fsp_get_next_hob(HOB_TYPE_GUID_EXT,
>                         hdr)) != NULL) {
>                 guid_hob = (struct hob_guid *)hdr;
> -               if (compare_guid(guid, &(guid_hob->name)))
> +               if (!guidcmp(guid, &(guid_hob->name)))
>                         break;
>                 hdr = get_next_hob(hdr);
>         }
> @@ -396,7 +380,7 @@ const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
>  }
>
>  void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
> -                           struct efi_guid *guid)
> +                           const efi_guid_t *guid)
>  {
>         const struct hob_header *guid_hob;
>
> @@ -413,21 +397,21 @@ void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
>
>  void *fsp_get_nvs_data(const void *hob_list, u32 *len)
>  {
> -       const struct efi_guid guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID;
> +       const efi_guid_t guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID;
>
> -       return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
> +       return fsp_get_guid_hob_data(hob_list, len, &guid);
>  }
>
>  void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len)
>  {
> -       const struct efi_guid guid = FSP_BOOTLOADER_TEMP_MEM_HOB_GUID;
> +       const efi_guid_t guid = FSP_BOOTLOADER_TEMP_MEM_HOB_GUID;
>
> -       return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
> +       return fsp_get_guid_hob_data(hob_list, len, &guid);
>  }
>
>  void *fsp_get_graphics_info(const void *hob_list, u32 *len)
>  {
> -       const struct efi_guid guid = FSP_GRAPHICS_INFO_HOB_GUID;
> +       const efi_guid_t guid = FSP_GRAPHICS_INFO_HOB_GUID;
>
> -       return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
> +       return fsp_get_guid_hob_data(hob_list, len, &guid);
>  }
> diff --git a/cmd/x86/fsp.c b/cmd/x86/fsp.c
> index 9f94ca9876..1b4c0207ce 100644
> --- a/cmd/x86/fsp.c
> +++ b/cmd/x86/fsp.c
> @@ -78,6 +78,7 @@ static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         uint type;
>         char *desc;
>         int i = 0;
> +       char uuid[UUID_STR_LEN + 1];
>
>         hdr = gd->arch.hob_list;
>
> @@ -102,13 +103,10 @@ static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>
>                 if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
>                     type == HOB_TYPE_GUID_EXT) {
> -                       struct efi_guid *guid = (struct efi_guid *)(hdr + 1);
> -                       int j;
> +                       efi_guid_t *guid = (efi_guid_t *)(hdr + 1);
>
> -                       printf("%08x-%04x-%04x", guid->data1,
> -                              guid->data2, guid->data3);
> -                       for (j = 0; j < ARRAY_SIZE(guid->data4); j++)
> -                               printf("-%02x", guid->data4[j]);
> +                       uuid_bin_to_str(guid->b, uuid, UUID_STR_FORMAT_GUID);
> +                       printf("%s", uuid);
>                 } else {
>                         printf("%42s", "Not Available");
>                 }
> --
> 2.20.1
>
Bin Meng Aug. 1, 2019, 5:55 a.m. UTC | #2
On Mon, Jul 29, 2019 at 12:35 PM Park, Aiden <aiden.park@intel.com> wrote:
>
> Use existing EFI_GUID and efi_guid_t instead of struct efi_guid.
> This is pre-work before making a common HOB library.
> - Change 'struct efi_guid' to efi_guit_t
> - Remove 'struct efi_guid'
> - Define GUIDs with EFI_GUID() macro
> - Use guidcmp() instead of compare_guid()
> - Remove compare_guid()
>
> Signed-off-by: Aiden Park <aiden.park@intel.com>
> ---
>
> Changes in v7:
>   * Split HOB library into EFI_GUID pre-work and making a common library
>
>  arch/x86/include/asm/fsp/fsp_ffs.h     |  4 +-
>  arch/x86/include/asm/fsp/fsp_fv.h      |  4 +-
>  arch/x86/include/asm/fsp/fsp_hob.h     | 76 +++++++++++++------------
>  arch/x86/include/asm/fsp/fsp_support.h |  6 +-
>  arch/x86/include/asm/fsp/fsp_types.h   |  8 ---
>  arch/x86/lib/fsp/fsp_support.c         | 78 ++++++++++----------------
>  cmd/x86/fsp.c                          | 10 ++--
>  7 files changed, 81 insertions(+), 105 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Tested on MinnowMax
Tested-by: Bin Meng <bmeng.cn@gmail.com>
diff mbox series

Patch

diff --git a/arch/x86/include/asm/fsp/fsp_ffs.h b/arch/x86/include/asm/fsp/fsp_ffs.h
index 61ce63c08e..b7558e5a17 100644
--- a/arch/x86/include/asm/fsp/fsp_ffs.h
+++ b/arch/x86/include/asm/fsp/fsp_ffs.h
@@ -45,7 +45,7 @@  struct __packed ffs_file_header {
 	 * This GUID is the file name.
 	 * It is used to uniquely identify the file.
 	 */
-	struct efi_guid		name;
+	efi_guid_t		name;
 	/* Used to verify the integrity of the file */
 	union ffs_integrity	integrity;
 	/* Identifies the type of file */
@@ -68,7 +68,7 @@  struct __packed ffs_file_header2 {
 	 * Name in any given firmware volume, except if the file type is
 	 * EFI_FV_FILE_TYPE_FFS_PAD.
 	 */
-	struct efi_guid		name;
+	efi_guid_t		name;
 	/* Used to verify the integrity of the file */
 	union ffs_integrity	integrity;
 	/* Identifies the type of file */
diff --git a/arch/x86/include/asm/fsp/fsp_fv.h b/arch/x86/include/asm/fsp/fsp_fv.h
index 190aedcf44..511dfb78b8 100644
--- a/arch/x86/include/asm/fsp/fsp_fv.h
+++ b/arch/x86/include/asm/fsp/fsp_fv.h
@@ -80,7 +80,7 @@  struct fv_header {
 	 * Declares the file system with which the firmware volume
 	 * is formatted.
 	 */
-	struct efi_guid		fs_guid;
+	efi_guid_t		fs_guid;
 	/*
 	 * Length in bytes of the complete firmware volume, including
 	 * the header.
@@ -128,7 +128,7 @@  struct fv_header {
 /* Extension header pointed by ExtHeaderOffset of volume header */
 struct fv_ext_header {
 	/* firmware volume name */
-	struct efi_guid		fv_name;
+	efi_guid_t		fv_name;
 	/* Size of the rest of the extension header including this structure */
 	u32			ext_hdr_size;
 };
diff --git a/arch/x86/include/asm/fsp/fsp_hob.h b/arch/x86/include/asm/fsp/fsp_hob.h
index 00657b62c7..843d7b513b 100644
--- a/arch/x86/include/asm/fsp/fsp_hob.h
+++ b/arch/x86/include/asm/fsp/fsp_hob.h
@@ -8,6 +8,7 @@ 
 #define __FSP_HOB_H__
 
 #include <efi.h>
+#include <efi_loader.h>
 
 /* Type of HOB Header */
 #define HOB_TYPE_MEM_ALLOC	0x0002
@@ -40,7 +41,7 @@  struct hob_mem_alloc {
 	 * present for the memory allocation HOB. Type efi_guid is defined in
 	 * InstallProtocolInterface() in the UEFI 2.0 specification.
 	 */
-	struct efi_guid		name;
+	efi_guid_t		name;
 	/*
 	 * The base address of memory allocated by this HOB.
 	 * Type phys_addr_t is defined in AllocatePages() in the UEFI 2.0
@@ -106,7 +107,7 @@  struct hob_res_desc {
 	 * used by HOB consumer phase components to correlate device
 	 * ownership of a resource.
 	 */
-	struct efi_guid		owner;
+	efi_guid_t		owner;
 	u32			type;
 	u32			attr;
 	/* The physical start address of the resource region */
@@ -122,7 +123,7 @@  struct hob_res_desc {
 struct hob_guid {
 	struct hob_header	hdr;
 	/* A GUID that defines the contents of this HOB */
-	struct efi_guid		name;
+	efi_guid_t		name;
 	/* GUID specific data goes here */
 };
 
@@ -223,56 +224,57 @@  static inline u16 get_guid_hob_data_size(const struct hob_header *hdr)
 #define FSP_GUID_DATA4_6	0x3f
 #define FSP_GUID_DATA4_7	0x0c
 
+#define FSP_GUID_BYTE0		0xbe
+#define FSP_GUID_BYTE1		0x40
+#define FSP_GUID_BYTE2		0x27
+#define FSP_GUID_BYTE3		0x91
+#define FSP_GUID_BYTE4		0x84
+#define FSP_GUID_BYTE5		0x22
+#define FSP_GUID_BYTE6		0x34
+#define FSP_GUID_BYTE7		0x47
+#define FSP_GUID_BYTE8		FSP_GUID_DATA4_0
+#define FSP_GUID_BYTE9		FSP_GUID_DATA4_1
+#define FSP_GUID_BYTE10		FSP_GUID_DATA4_2
+#define FSP_GUID_BYTE11		FSP_GUID_DATA4_3
+#define FSP_GUID_BYTE12		FSP_GUID_DATA4_4
+#define FSP_GUID_BYTE13		FSP_GUID_DATA4_5
+#define FSP_GUID_BYTE14		FSP_GUID_DATA4_6
+#define FSP_GUID_BYTE15		FSP_GUID_DATA4_7
+
 #define FSP_HEADER_GUID \
-	{ \
-	FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
-	{ FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
-	  FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
-	  FSP_GUID_DATA4_6, FSP_GUID_DATA4_7 } \
-	}
+	EFI_GUID(FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
+		FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
+		FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
+		FSP_GUID_DATA4_6, FSP_GUID_DATA4_7)
 
 #define FSP_NON_VOLATILE_STORAGE_HOB_GUID \
-	{ \
-	0x721acf02, 0x4d77, 0x4c2a, \
-	{ 0xb3, 0xdc, 0x27, 0xb, 0x7b, 0xa9, 0xe4, 0xb0 } \
-	}
+	EFI_GUID(0x721acf02, 0x4d77, 0x4c2a, \
+		0xb3, 0xdc, 0x27, 0x0b, 0x7b, 0xa9, 0xe4, 0xb0)
 
 #define FSP_BOOTLOADER_TEMP_MEM_HOB_GUID \
-	{ \
-	0xbbcff46c, 0xc8d3, 0x4113, \
-	{ 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e } \
-	}
+	EFI_GUID(0xbbcff46c, 0xc8d3, 0x4113, \
+		0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e)
 
 #define FSP_HOB_RESOURCE_OWNER_FSP_GUID \
-	{ \
-	0x69a79759, 0x1373, 0x4367, \
-	{ 0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e } \
-	}
+	EFI_GUID(0x69a79759, 0x1373, 0x4367, \
+		0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e)
 
 #define FSP_HOB_RESOURCE_OWNER_TSEG_GUID \
-	{ \
-	0xd038747c, 0xd00c, 0x4980, \
-	{ 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55 } \
-	}
+	EFI_GUID(0xd038747c, 0xd00c, 0x4980, \
+		0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55)
 
 #define FSP_HOB_RESOURCE_OWNER_GRAPHICS_GUID \
-	{ \
-	0x9c7c3aa7, 0x5332, 0x4917, \
-	{ 0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07 } \
-	}
+	EFI_GUID(0x9c7c3aa7, 0x5332, 0x4917, \
+		0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07)
 
 /* The following GUIDs are newly introduced in FSP spec 1.1 */
 
 #define FSP_HOB_RESOURCE_OWNER_BOOTLOADER_TOLUM_GUID \
-	{ \
-	0x73ff4f56, 0xaa8e, 0x4451, \
-	{ 0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44 } \
-	}
+	EFI_GUID(0x73ff4f56, 0xaa8e, 0x4451, \
+		0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44)
 
 #define FSP_GRAPHICS_INFO_HOB_GUID \
-	{ \
-	0x39f62cce, 0x6825, 0x4669, \
-	{ 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 } \
-	}
+	EFI_GUID(0x39f62cce, 0x6825, 0x4669, \
+		0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07)
 
 #endif
diff --git a/arch/x86/include/asm/fsp/fsp_support.h b/arch/x86/include/asm/fsp/fsp_support.h
index 7e51f24b12..0cca948184 100644
--- a/arch/x86/include/asm/fsp/fsp_support.h
+++ b/arch/x86/include/asm/fsp/fsp_support.h
@@ -106,7 +106,7 @@  u64 fsp_get_usable_highmem_top(const void *hob_list);
  *            0 if this region does not exist.
  */
 u64 fsp_get_reserved_mem_from_guid(const void *hob_list,
-				   u64 *len, struct efi_guid *guid);
+				   u64 *len, const efi_guid_t *guid);
 
 /**
  * This function retrieves the FSP reserved normal memory.
@@ -149,7 +149,7 @@  const struct hob_header *fsp_get_next_hob(uint type, const void *hob_list);
  *
  * @retval:   A HOB object with matching GUID; Otherwise NULL.
  */
-const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
+const struct hob_header *fsp_get_next_guid_hob(const efi_guid_t *guid,
 					       const void *hob_list);
 
 /**
@@ -164,7 +164,7 @@  const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
  * @retval others: GUID HOB data buffer pointer.
  */
 void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
-			    struct efi_guid *guid);
+			    const efi_guid_t *guid);
 
 /**
  * This function retrieves FSP Non-volatile Storage HOB buffer and size.
diff --git a/arch/x86/include/asm/fsp/fsp_types.h b/arch/x86/include/asm/fsp/fsp_types.h
index 5247102f75..3d5b17ecf1 100644
--- a/arch/x86/include/asm/fsp/fsp_types.h
+++ b/arch/x86/include/asm/fsp/fsp_types.h
@@ -7,14 +7,6 @@ 
 #ifndef __FSP_TYPES_H__
 #define __FSP_TYPES_H__
 
-/* 128 bit buffer containing a unique identifier value */
-struct efi_guid {
-	u32	data1;
-	u16	data2;
-	u16	data3;
-	u8	data4[8];
-};
-
 /**
  * Returns a 16-bit signature built from 2 ASCII characters.
  *
diff --git a/arch/x86/lib/fsp/fsp_support.c b/arch/x86/lib/fsp/fsp_support.c
index 90e4e7db26..0d1bb35186 100644
--- a/arch/x86/lib/fsp/fsp_support.c
+++ b/arch/x86/lib/fsp/fsp_support.c
@@ -8,27 +8,6 @@ 
 #include <asm/fsp/fsp_support.h>
 #include <asm/post.h>
 
-/**
- * Compares two GUIDs
- *
- * If the GUIDs are identical then true is returned.
- * If there are any bit differences in the two GUIDs, then false is returned.
- *
- * @guid1:        A pointer to a 128 bit GUID.
- * @guid2:        A pointer to a 128 bit GUID.
- *
- * @retval true:  guid1 and guid2 are identical.
- * @retval false: guid1 and guid2 are not identical.
- */
-static bool compare_guid(const struct efi_guid *guid1,
-			 const struct efi_guid *guid2)
-{
-	if (memcmp(guid1, guid2, sizeof(struct efi_guid)) == 0)
-		return true;
-	else
-		return false;
-}
-
 struct fsp_header *__attribute__((optimize("O0"))) find_fsp_header(void)
 {
 	/*
@@ -58,17 +37,22 @@  struct fsp_header *__attribute__((optimize("O0"))) find_fsp_header(void)
 
 	/* Check the FFS GUID */
 	if (fsp &&
-	    ((struct ffs_file_header *)fsp)->name.data1 == FSP_GUID_DATA1 &&
-	    ((struct ffs_file_header *)fsp)->name.data2 == FSP_GUID_DATA2 &&
-	    ((struct ffs_file_header *)fsp)->name.data3 == FSP_GUID_DATA3 &&
-	    ((struct ffs_file_header *)fsp)->name.data4[0] == FSP_GUID_DATA4_0 &&
-	    ((struct ffs_file_header *)fsp)->name.data4[1] == FSP_GUID_DATA4_1 &&
-	    ((struct ffs_file_header *)fsp)->name.data4[2] == FSP_GUID_DATA4_2 &&
-	    ((struct ffs_file_header *)fsp)->name.data4[3] == FSP_GUID_DATA4_3 &&
-	    ((struct ffs_file_header *)fsp)->name.data4[4] == FSP_GUID_DATA4_4 &&
-	    ((struct ffs_file_header *)fsp)->name.data4[5] == FSP_GUID_DATA4_5 &&
-	    ((struct ffs_file_header *)fsp)->name.data4[6] == FSP_GUID_DATA4_6 &&
-	    ((struct ffs_file_header *)fsp)->name.data4[7] == FSP_GUID_DATA4_7) {
+	    ((struct ffs_file_header *)fsp)->name.b[0] == FSP_GUID_BYTE0 &&
+	    ((struct ffs_file_header *)fsp)->name.b[1] == FSP_GUID_BYTE1 &&
+	    ((struct ffs_file_header *)fsp)->name.b[2] == FSP_GUID_BYTE2 &&
+	    ((struct ffs_file_header *)fsp)->name.b[3] == FSP_GUID_BYTE3 &&
+	    ((struct ffs_file_header *)fsp)->name.b[4] == FSP_GUID_BYTE4 &&
+	    ((struct ffs_file_header *)fsp)->name.b[5] == FSP_GUID_BYTE5 &&
+	    ((struct ffs_file_header *)fsp)->name.b[6] == FSP_GUID_BYTE6 &&
+	    ((struct ffs_file_header *)fsp)->name.b[7] == FSP_GUID_BYTE7 &&
+	    ((struct ffs_file_header *)fsp)->name.b[8] == FSP_GUID_BYTE8 &&
+	    ((struct ffs_file_header *)fsp)->name.b[9] == FSP_GUID_BYTE9 &&
+	    ((struct ffs_file_header *)fsp)->name.b[10] == FSP_GUID_BYTE10 &&
+	    ((struct ffs_file_header *)fsp)->name.b[11] == FSP_GUID_BYTE11 &&
+	    ((struct ffs_file_header *)fsp)->name.b[12] == FSP_GUID_BYTE12 &&
+	    ((struct ffs_file_header *)fsp)->name.b[13] == FSP_GUID_BYTE13 &&
+	    ((struct ffs_file_header *)fsp)->name.b[14] == FSP_GUID_BYTE14 &&
+	    ((struct ffs_file_header *)fsp)->name.b[15] == FSP_GUID_BYTE15) {
 		/* Add the FFS header size to find the raw section header */
 		fsp += sizeof(struct ffs_file_header);
 	} else {
@@ -305,7 +289,7 @@  u64 fsp_get_usable_highmem_top(const void *hob_list)
 }
 
 u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
-				   struct efi_guid *guid)
+				   const efi_guid_t *guid)
 {
 	const struct hob_header *hdr;
 	struct hob_res_desc *res_desc;
@@ -318,7 +302,7 @@  u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
 		if (hdr->type == HOB_TYPE_RES_DESC) {
 			res_desc = (struct hob_res_desc *)hdr;
 			if (res_desc->type == RES_MEM_RESERVED) {
-				if (compare_guid(&res_desc->owner, guid)) {
+				if (!guidcmp(&res_desc->owner, guid)) {
 					if (len)
 						*len = (u32)(res_desc->len);
 
@@ -334,12 +318,12 @@  u64 fsp_get_reserved_mem_from_guid(const void *hob_list, u64 *len,
 
 u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len)
 {
-	const struct efi_guid guid = FSP_HOB_RESOURCE_OWNER_FSP_GUID;
+	const efi_guid_t guid = FSP_HOB_RESOURCE_OWNER_FSP_GUID;
 	u64 length;
 	u32 base;
 
 	base = (u32)fsp_get_reserved_mem_from_guid(hob_list,
-			&length, (struct efi_guid *)&guid);
+			&length, &guid);
 	if ((len != 0) && (base != 0))
 		*len = (u32)length;
 
@@ -348,12 +332,12 @@  u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len)
 
 u32 fsp_get_tseg_reserved_mem(const void *hob_list, u32 *len)
 {
-	const struct efi_guid guid = FSP_HOB_RESOURCE_OWNER_TSEG_GUID;
+	const efi_guid_t guid = FSP_HOB_RESOURCE_OWNER_TSEG_GUID;
 	u64 length;
 	u32 base;
 
 	base = (u32)fsp_get_reserved_mem_from_guid(hob_list,
-			&length, (struct efi_guid *)&guid);
+			&length, &guid);
 	if ((len != 0) && (base != 0))
 		*len = (u32)length;
 
@@ -377,7 +361,7 @@  const struct hob_header *fsp_get_next_hob(uint type, const void *hob_list)
 	return NULL;
 }
 
-const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
+const struct hob_header *fsp_get_next_guid_hob(const efi_guid_t *guid,
 					       const void *hob_list)
 {
 	const struct hob_header *hdr;
@@ -387,7 +371,7 @@  const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
 	while ((hdr = fsp_get_next_hob(HOB_TYPE_GUID_EXT,
 			hdr)) != NULL) {
 		guid_hob = (struct hob_guid *)hdr;
-		if (compare_guid(guid, &(guid_hob->name)))
+		if (!guidcmp(guid, &(guid_hob->name)))
 			break;
 		hdr = get_next_hob(hdr);
 	}
@@ -396,7 +380,7 @@  const struct hob_header *fsp_get_next_guid_hob(const struct efi_guid *guid,
 }
 
 void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
-			    struct efi_guid *guid)
+			    const efi_guid_t *guid)
 {
 	const struct hob_header *guid_hob;
 
@@ -413,21 +397,21 @@  void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
 
 void *fsp_get_nvs_data(const void *hob_list, u32 *len)
 {
-	const struct efi_guid guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID;
+	const efi_guid_t guid = FSP_NON_VOLATILE_STORAGE_HOB_GUID;
 
-	return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
+	return fsp_get_guid_hob_data(hob_list, len, &guid);
 }
 
 void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len)
 {
-	const struct efi_guid guid = FSP_BOOTLOADER_TEMP_MEM_HOB_GUID;
+	const efi_guid_t guid = FSP_BOOTLOADER_TEMP_MEM_HOB_GUID;
 
-	return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
+	return fsp_get_guid_hob_data(hob_list, len, &guid);
 }
 
 void *fsp_get_graphics_info(const void *hob_list, u32 *len)
 {
-	const struct efi_guid guid = FSP_GRAPHICS_INFO_HOB_GUID;
+	const efi_guid_t guid = FSP_GRAPHICS_INFO_HOB_GUID;
 
-	return fsp_get_guid_hob_data(hob_list, len, (struct efi_guid *)&guid);
+	return fsp_get_guid_hob_data(hob_list, len, &guid);
 }
diff --git a/cmd/x86/fsp.c b/cmd/x86/fsp.c
index 9f94ca9876..1b4c0207ce 100644
--- a/cmd/x86/fsp.c
+++ b/cmd/x86/fsp.c
@@ -78,6 +78,7 @@  static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	uint type;
 	char *desc;
 	int i = 0;
+	char uuid[UUID_STR_LEN + 1];
 
 	hdr = gd->arch.hob_list;
 
@@ -102,13 +103,10 @@  static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 		if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
 		    type == HOB_TYPE_GUID_EXT) {
-			struct efi_guid *guid = (struct efi_guid *)(hdr + 1);
-			int j;
+			efi_guid_t *guid = (efi_guid_t *)(hdr + 1);
 
-			printf("%08x-%04x-%04x", guid->data1,
-			       guid->data2, guid->data3);
-			for (j = 0; j < ARRAY_SIZE(guid->data4); j++)
-				printf("-%02x", guid->data4[j]);
+			uuid_bin_to_str(guid->b, uuid, UUID_STR_FORMAT_GUID);
+			printf("%s", uuid);
 		} else {
 			printf("%42s", "Not Available");
 		}