1 // SPDX-License-Identifier: GPL-2.0+
11 #include <asm/fsp/fsp_hob.h>
13 DECLARE_GLOBAL_DATA_PTR;
15 static char *hob_type[] = {
30 static char *res_type[] = {
35 "Memory-mapped I/O port",
40 static struct guid_name {
44 { FSP_HOB_RESOURCE_OWNER_TSEG_GUID, "TSEG" },
45 { FSP_HOB_RESOURCE_OWNER_FSP_GUID, "FSP" },
46 { FSP_HOB_RESOURCE_OWNER_SMM_PEI_SMRAM_GUID, "SMM PEI SMRAM" },
47 { FSP_NON_VOLATILE_STORAGE_HOB_GUID, "NVS" },
48 { FSP_VARIABLE_NV_DATA_HOB_GUID, "Variable NVS" },
49 { FSP_GRAPHICS_INFO_HOB_GUID, "Graphics info" },
50 { FSP_HOB_RESOURCE_OWNER_PCD_DATABASE_GUID1, "PCD database ea" },
51 { FSP_HOB_RESOURCE_OWNER_PCD_DATABASE_GUID2, "PCD database 9b" },
52 { FSP_HOB_RESOURCE_OWNER_PEIM_DXE_GUID, "PEIM Init DXE" },
53 { FSP_HOB_RESOURCE_OWNER_ALLOC_STACK_GUID, "Alloc stack" },
54 { FSP_HOB_RESOURCE_OWNER_SMBIOS_MEMORY_GUID, "SMBIOS memory" },
59 static const char *guid_to_name(const efi_guid_t *guid)
61 struct guid_name *entry;
63 for (entry = guid_name; entry->name; entry++) {
64 if (!guidcmp(guid, &entry->guid))
71 static void show_hob_details(const struct hob_header *hdr)
73 const void *ptr = hdr;
76 case HOB_TYPE_RES_DESC: {
77 const struct hob_res_desc *res = ptr;
80 typename = res->type > 0 && res->type <= RES_MAX_MEM_TYPE ?
81 res_type[res->type] : "unknown";
83 printf(" base = %08llx, len = %08llx, end = %08llx, type = %d (%s)\n\n",
84 res->phys_start, res->len, res->phys_start + res->len,
91 static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
93 const struct hob_header *hdr;
98 char uuid[UUID_STR_LEN + 1];
100 int seq = -1; /* Show all by default */
105 if (!strcmp("-v", *argv)) {
111 seq = simple_strtol(*argv, NULL, 16);
113 hdr = gd->arch.hob_list;
115 printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
117 printf("# | Address | Type | Len | ");
118 printf("%36s\n", "GUID");
119 printf("---|----------|-----------|------|-");
120 printf("------------------------------------\n");
121 for (i = 0; !end_of_hob(hdr); i++, hdr = get_next_hob(hdr)) {
122 if (seq != -1 && seq != i)
124 printf("%02x | %08x | ", i, (unsigned int)hdr);
126 if (type == HOB_TYPE_UNUSED)
128 else if (type == HOB_TYPE_EOH)
130 else if (type >= 0 && type <= ARRAY_SIZE(hob_type))
131 desc = hob_type[type];
134 printf("%-9s | %04x | ", desc, hdr->len);
136 if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
137 type == HOB_TYPE_GUID_EXT) {
140 guid = (efi_guid_t *)(hdr + 1);
141 name = guid_to_name(guid);
143 uuid_bin_to_str(guid->b, uuid,
144 UUID_STR_FORMAT_GUID);
147 printf("%36s", name);
149 printf("%36s", "Not Available");
153 show_hob_details(hdr);
159 U_BOOT_CMD(hob, 3, 1, do_hob,
160 "[-v] [seq] Print Hand-Off Block (HOB) information"
161 " -v - Show detailed HOB information where available"
162 " seq - Record # to show (all by default)",