cmd_fsp.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <asm/fsp/fsp_support.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. hdr = gd->arch.hob_list;
  31. printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
  32. printf("# | Address | Type | Len | ");
  33. printf("%42s\n", "GUID");
  34. printf("---|----------|-----------|------|-");
  35. printf("------------------------------------------\n");
  36. while (!end_of_hob(hdr)) {
  37. printf("%-2d | %08x | ", i, (unsigned int)hdr);
  38. type = hdr->type;
  39. if (type == HOB_TYPE_UNUSED)
  40. desc = "*Unused*";
  41. else if (type == HOB_TYPE_EOH)
  42. desc = "*EOH*";
  43. else if (type >= 0 && type <= ARRAY_SIZE(hob_type))
  44. desc = hob_type[type];
  45. else
  46. desc = "*Invalid*";
  47. printf("%-9s | %-4d | ", desc, hdr->len);
  48. if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
  49. type == HOB_TYPE_GUID_EXT) {
  50. struct efi_guid *guid = (struct efi_guid *)(hdr + 1);
  51. int j;
  52. printf("%08x-%04x-%04x", guid->data1,
  53. guid->data2, guid->data3);
  54. for (j = 0; j < ARRAY_SIZE(guid->data4); j++)
  55. printf("-%02x", guid->data4[j]);
  56. } else {
  57. printf("%42s", "Not Available");
  58. }
  59. printf("\n");
  60. hdr = get_next_hob(hdr);
  61. i++;
  62. }
  63. return 0;
  64. }
  65. static cmd_tbl_t fsp_commands[] = {
  66. U_BOOT_CMD_MKENT(hob, 0, 1, do_hob, "", ""),
  67. };
  68. static int do_fsp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  69. {
  70. cmd_tbl_t *fsp_cmd;
  71. int ret;
  72. if (argc < 2)
  73. return CMD_RET_USAGE;
  74. fsp_cmd = find_cmd_tbl(argv[1], fsp_commands, ARRAY_SIZE(fsp_commands));
  75. argc -= 2;
  76. argv += 2;
  77. if (!fsp_cmd || argc > fsp_cmd->maxargs)
  78. return CMD_RET_USAGE;
  79. ret = fsp_cmd->cmd(fsp_cmd, flag, argc, argv);
  80. return cmd_process_error(fsp_cmd, ret);
  81. }
  82. U_BOOT_CMD(
  83. fsp, 2, 1, do_fsp,
  84. "Show Intel Firmware Support Package (FSP) related information",
  85. "hob - Print FSP Hand-Off Block (HOB) information"
  86. );