1 /* 2 * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com> 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 5 */ 6 7 #include <common.h> 8 #include <command.h> 9 #include <asm/fsp/fsp_support.h> 10 11 DECLARE_GLOBAL_DATA_PTR; 12 13 static char *hob_type[] = { 14 "reserved", 15 "Hand-off", 16 "Mem Alloc", 17 "Res Desc", 18 "GUID Ext", 19 "FV", 20 "CPU", 21 "Mem Pool", 22 "reserved", 23 "FV2", 24 "Load PEIM", 25 "Capsule", 26 }; 27 28 static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 29 { 30 const struct hob_header *hdr; 31 uint type; 32 char *desc; 33 int i = 0; 34 35 hdr = gd->arch.hob_list; 36 37 printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); 38 39 printf("# | Address | Type | Len | "); 40 printf("%42s\n", "GUID"); 41 printf("---|----------|-----------|------|-"); 42 printf("------------------------------------------\n"); 43 while (!end_of_hob(hdr)) { 44 printf("%-2d | %08x | ", i, (unsigned int)hdr); 45 type = hdr->type; 46 if (type == HOB_TYPE_UNUSED) 47 desc = "*Unused*"; 48 else if (type == HOB_TYPE_EOH) 49 desc = "*EOH*"; 50 else if (type >= 0 && type <= ARRAY_SIZE(hob_type)) 51 desc = hob_type[type]; 52 else 53 desc = "*Invalid*"; 54 printf("%-9s | %-4d | ", desc, hdr->len); 55 56 if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC || 57 type == HOB_TYPE_GUID_EXT) { 58 struct efi_guid *guid = (struct efi_guid *)(hdr + 1); 59 int j; 60 61 printf("%08x-%04x-%04x", guid->data1, 62 guid->data2, guid->data3); 63 for (j = 0; j < ARRAY_SIZE(guid->data4); j++) 64 printf("-%02x", guid->data4[j]); 65 } else { 66 printf("%42s", "Not Available"); 67 } 68 printf("\n"); 69 hdr = get_next_hob(hdr); 70 i++; 71 } 72 73 return 0; 74 } 75 76 static cmd_tbl_t fsp_commands[] = { 77 U_BOOT_CMD_MKENT(hob, 0, 1, do_hob, "", ""), 78 }; 79 80 static int do_fsp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 81 { 82 cmd_tbl_t *fsp_cmd; 83 int ret; 84 85 if (argc < 2) 86 return CMD_RET_USAGE; 87 fsp_cmd = find_cmd_tbl(argv[1], fsp_commands, ARRAY_SIZE(fsp_commands)); 88 argc -= 2; 89 argv += 2; 90 if (!fsp_cmd || argc > fsp_cmd->maxargs) 91 return CMD_RET_USAGE; 92 93 ret = fsp_cmd->cmd(fsp_cmd, flag, argc, argv); 94 95 return cmd_process_error(fsp_cmd, ret); 96 } 97 98 U_BOOT_CMD( 99 fsp, 2, 1, do_fsp, 100 "Show Intel Firmware Support Package (FSP) related information", 101 "hob - Print FSP Hand-Off Block (HOB) information" 102 ); 103