1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
28e18f34cSTom Rini /*
38e18f34cSTom Rini * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com>
48e18f34cSTom Rini */
58e18f34cSTom Rini
68e18f34cSTom Rini #include <common.h>
78e18f34cSTom Rini #include <command.h>
88e18f34cSTom Rini #include <asm/fsp/fsp_support.h>
98e18f34cSTom Rini
108e18f34cSTom Rini DECLARE_GLOBAL_DATA_PTR;
118e18f34cSTom Rini
128e18f34cSTom Rini static char *hob_type[] = {
138e18f34cSTom Rini "reserved",
148e18f34cSTom Rini "Hand-off",
158e18f34cSTom Rini "Mem Alloc",
168e18f34cSTom Rini "Res Desc",
178e18f34cSTom Rini "GUID Ext",
188e18f34cSTom Rini "FV",
198e18f34cSTom Rini "CPU",
208e18f34cSTom Rini "Mem Pool",
218e18f34cSTom Rini "reserved",
228e18f34cSTom Rini "FV2",
238e18f34cSTom Rini "Load PEIM",
248e18f34cSTom Rini "Capsule",
258e18f34cSTom Rini };
268e18f34cSTom Rini
do_hdr(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])278e18f34cSTom Rini static int do_hdr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
288e18f34cSTom Rini {
298e18f34cSTom Rini struct fsp_header *hdr = find_fsp_header();
308e18f34cSTom Rini u32 img_addr = hdr->img_base;
318e18f34cSTom Rini char *sign = (char *)&hdr->sign;
328e18f34cSTom Rini int i;
338e18f34cSTom Rini
348e18f34cSTom Rini printf("FSP : binary 0x%08x, header 0x%08x\n",
358e18f34cSTom Rini CONFIG_FSP_ADDR, (int)hdr);
368e18f34cSTom Rini printf("Header : sign ");
378e18f34cSTom Rini for (i = 0; i < sizeof(hdr->sign); i++)
388e18f34cSTom Rini printf("%c", *sign++);
398e18f34cSTom Rini printf(", size %d, rev %d\n", hdr->hdr_len, hdr->hdr_rev);
408e18f34cSTom Rini printf("Image : rev ");
418e18f34cSTom Rini if (hdr->hdr_rev == FSP_HEADER_REVISION_1) {
428e18f34cSTom Rini printf("%d.%d",
438e18f34cSTom Rini (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff);
448e18f34cSTom Rini } else {
458e18f34cSTom Rini printf("%d.%d.%d.%d",
468e18f34cSTom Rini (hdr->img_rev >> 24) & 0xff, (hdr->img_rev >> 16) & 0xff,
478e18f34cSTom Rini (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff);
488e18f34cSTom Rini }
498e18f34cSTom Rini printf(", id ");
508e18f34cSTom Rini for (i = 0; i < ARRAY_SIZE(hdr->img_id); i++)
518e18f34cSTom Rini printf("%c", hdr->img_id[i]);
528e18f34cSTom Rini printf(", addr 0x%08x, size %d\n", img_addr, hdr->img_size);
538e18f34cSTom Rini if (hdr->hdr_rev == FSP_HEADER_REVISION_2) {
548e18f34cSTom Rini printf("GFX :%ssupported\n",
558e18f34cSTom Rini hdr->img_attr & FSP_ATTR_GRAPHICS_SUPPORT ? " " : " un");
568e18f34cSTom Rini }
578e18f34cSTom Rini printf("VPD : addr 0x%08x, size %d\n",
588e18f34cSTom Rini hdr->cfg_region_off + img_addr, hdr->cfg_region_size);
598e18f34cSTom Rini printf("\nNumber of APIs Supported : %d\n", hdr->api_num);
608e18f34cSTom Rini printf("\tTempRamInit : 0x%08x\n", hdr->fsp_tempram_init + img_addr);
618e18f34cSTom Rini printf("\tFspInit : 0x%08x\n", hdr->fsp_init + img_addr);
628e18f34cSTom Rini printf("\tFspNotify : 0x%08x\n", hdr->fsp_notify + img_addr);
638e18f34cSTom Rini if (hdr->hdr_rev == FSP_HEADER_REVISION_2) {
648e18f34cSTom Rini printf("\tMemoryInit : 0x%08x\n",
658e18f34cSTom Rini hdr->fsp_mem_init + img_addr);
668e18f34cSTom Rini printf("\tTempRamExit : 0x%08x\n",
678e18f34cSTom Rini hdr->fsp_tempram_exit + img_addr);
688e18f34cSTom Rini printf("\tSiliconInit : 0x%08x\n",
698e18f34cSTom Rini hdr->fsp_silicon_init + img_addr);
708e18f34cSTom Rini }
718e18f34cSTom Rini
728e18f34cSTom Rini return 0;
738e18f34cSTom Rini }
748e18f34cSTom Rini
do_hob(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])758e18f34cSTom Rini static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
768e18f34cSTom Rini {
778e18f34cSTom Rini const struct hob_header *hdr;
788e18f34cSTom Rini uint type;
798e18f34cSTom Rini char *desc;
808e18f34cSTom Rini int i = 0;
818e18f34cSTom Rini
828e18f34cSTom Rini hdr = gd->arch.hob_list;
838e18f34cSTom Rini
848e18f34cSTom Rini printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
858e18f34cSTom Rini
868e18f34cSTom Rini printf("# | Address | Type | Len | ");
878e18f34cSTom Rini printf("%42s\n", "GUID");
888e18f34cSTom Rini printf("---|----------|-----------|------|-");
898e18f34cSTom Rini printf("------------------------------------------\n");
908e18f34cSTom Rini while (!end_of_hob(hdr)) {
918e18f34cSTom Rini printf("%02x | %08x | ", i, (unsigned int)hdr);
928e18f34cSTom Rini type = hdr->type;
938e18f34cSTom Rini if (type == HOB_TYPE_UNUSED)
948e18f34cSTom Rini desc = "*Unused*";
958e18f34cSTom Rini else if (type == HOB_TYPE_EOH)
968e18f34cSTom Rini desc = "*EOH*";
978e18f34cSTom Rini else if (type >= 0 && type <= ARRAY_SIZE(hob_type))
988e18f34cSTom Rini desc = hob_type[type];
998e18f34cSTom Rini else
1008e18f34cSTom Rini desc = "*Invalid*";
1018e18f34cSTom Rini printf("%-9s | %04x | ", desc, hdr->len);
1028e18f34cSTom Rini
1038e18f34cSTom Rini if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
1048e18f34cSTom Rini type == HOB_TYPE_GUID_EXT) {
1058e18f34cSTom Rini struct efi_guid *guid = (struct efi_guid *)(hdr + 1);
1068e18f34cSTom Rini int j;
1078e18f34cSTom Rini
1088e18f34cSTom Rini printf("%08x-%04x-%04x", guid->data1,
1098e18f34cSTom Rini guid->data2, guid->data3);
1108e18f34cSTom Rini for (j = 0; j < ARRAY_SIZE(guid->data4); j++)
1118e18f34cSTom Rini printf("-%02x", guid->data4[j]);
1128e18f34cSTom Rini } else {
1138e18f34cSTom Rini printf("%42s", "Not Available");
1148e18f34cSTom Rini }
1158e18f34cSTom Rini printf("\n");
1168e18f34cSTom Rini hdr = get_next_hob(hdr);
1178e18f34cSTom Rini i++;
1188e18f34cSTom Rini }
1198e18f34cSTom Rini
1208e18f34cSTom Rini return 0;
1218e18f34cSTom Rini }
1228e18f34cSTom Rini
1238e18f34cSTom Rini static cmd_tbl_t fsp_commands[] = {
1248e18f34cSTom Rini U_BOOT_CMD_MKENT(hdr, 0, 1, do_hdr, "", ""),
1258e18f34cSTom Rini U_BOOT_CMD_MKENT(hob, 0, 1, do_hob, "", ""),
1268e18f34cSTom Rini };
1278e18f34cSTom Rini
do_fsp(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])1288e18f34cSTom Rini static int do_fsp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
1298e18f34cSTom Rini {
1308e18f34cSTom Rini cmd_tbl_t *fsp_cmd;
1318e18f34cSTom Rini int ret;
1328e18f34cSTom Rini
1338e18f34cSTom Rini if (argc < 2)
1348e18f34cSTom Rini return CMD_RET_USAGE;
1358e18f34cSTom Rini fsp_cmd = find_cmd_tbl(argv[1], fsp_commands, ARRAY_SIZE(fsp_commands));
1368e18f34cSTom Rini argc -= 2;
1378e18f34cSTom Rini argv += 2;
1388e18f34cSTom Rini if (!fsp_cmd || argc > fsp_cmd->maxargs)
1398e18f34cSTom Rini return CMD_RET_USAGE;
1408e18f34cSTom Rini
1418e18f34cSTom Rini ret = fsp_cmd->cmd(fsp_cmd, flag, argc, argv);
1428e18f34cSTom Rini
1438e18f34cSTom Rini return cmd_process_error(fsp_cmd, ret);
1448e18f34cSTom Rini }
1458e18f34cSTom Rini
1468e18f34cSTom Rini U_BOOT_CMD(
1478e18f34cSTom Rini fsp, 2, 1, do_fsp,
1488e18f34cSTom Rini "Show Intel Firmware Support Package (FSP) related information",
1498e18f34cSTom Rini "hdr - Print FSP header information\n"
1508e18f34cSTom Rini "fsp hob - Print FSP Hand-Off Block (HOB) information"
1518e18f34cSTom Rini );
152