hob.c 1.6 KB

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