hob.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <efi.h>
  8. #include <uuid.h>
  9. #include <asm/hob.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. static char *hob_type[] = {
  12. "reserved",
  13. "Hand-off",
  14. "Mem Alloc",
  15. "Res Desc",
  16. "GUID Ext",
  17. "FV",
  18. "CPU",
  19. "Mem Pool",
  20. "reserved",
  21. "FV2",
  22. "Load PEIM",
  23. "Capsule",
  24. };
  25. static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  26. {
  27. const struct hob_header *hdr;
  28. uint type;
  29. char *desc;
  30. int i = 0;
  31. efi_guid_t *guid;
  32. char uuid[UUID_STR_LEN + 1];
  33. hdr = gd->arch.hob_list;
  34. printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
  35. printf("# | Address | Type | Len | ");
  36. printf("%36s\n", "GUID");
  37. printf("---|----------|-----------|------|-");
  38. printf("------------------------------------\n");
  39. while (!end_of_hob(hdr)) {
  40. printf("%02x | %08x | ", i, (unsigned int)hdr);
  41. type = hdr->type;
  42. if (type == HOB_TYPE_UNUSED)
  43. desc = "*Unused*";
  44. else if (type == HOB_TYPE_EOH)
  45. desc = "*EOH*";
  46. else if (type >= 0 && type <= ARRAY_SIZE(hob_type))
  47. desc = hob_type[type];
  48. else
  49. desc = "*Invalid*";
  50. printf("%-9s | %04x | ", desc, hdr->len);
  51. if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
  52. type == HOB_TYPE_GUID_EXT) {
  53. guid = (efi_guid_t *)(hdr + 1);
  54. uuid_bin_to_str(guid->b, uuid, UUID_STR_FORMAT_GUID);
  55. printf("%s", uuid);
  56. } else {
  57. printf("%36s", "Not Available");
  58. }
  59. printf("\n");
  60. hdr = get_next_hob(hdr);
  61. i++;
  62. }
  63. return 0;
  64. }
  65. U_BOOT_CMD(hob, 1, 1, do_hob,
  66. "Print Hand-Off Block (HOB) information",
  67. ""
  68. );