blob: 9f94ca9876c3e2ae6a4553464be34d2c6ff37b11 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Bin Mengba7b38a2014-12-12 21:05:32 +08002/*
Bin Meng62716eb2015-10-10 01:47:58 -07003 * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com>
Bin Mengba7b38a2014-12-12 21:05:32 +08004 */
5
6#include <common.h>
7#include <command.h>
Simon Glass1021af42015-01-27 22:13:36 -07008#include <asm/fsp/fsp_support.h>
Bin Mengba7b38a2014-12-12 21:05:32 +08009
10DECLARE_GLOBAL_DATA_PTR;
11
12static char *hob_type[] = {
13 "reserved",
14 "Hand-off",
Bin Mengfd755f02015-10-10 01:47:56 -070015 "Mem Alloc",
16 "Res Desc",
17 "GUID Ext",
18 "FV",
Bin Mengba7b38a2014-12-12 21:05:32 +080019 "CPU",
Bin Mengfd755f02015-10-10 01:47:56 -070020 "Mem Pool",
Bin Mengba7b38a2014-12-12 21:05:32 +080021 "reserved",
Bin Mengfd755f02015-10-10 01:47:56 -070022 "FV2",
23 "Load PEIM",
24 "Capsule",
Bin Mengba7b38a2014-12-12 21:05:32 +080025};
26
Bin Meng010921a2015-10-10 01:47:59 -070027static int do_hdr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
28{
29 struct fsp_header *hdr = find_fsp_header();
30 u32 img_addr = hdr->img_base;
31 char *sign = (char *)&hdr->sign;
32 int i;
33
34 printf("FSP : binary 0x%08x, header 0x%08x\n",
35 CONFIG_FSP_ADDR, (int)hdr);
36 printf("Header : sign ");
37 for (i = 0; i < sizeof(hdr->sign); i++)
38 printf("%c", *sign++);
39 printf(", size %d, rev %d\n", hdr->hdr_len, hdr->hdr_rev);
Bin Mengb3fd2122017-08-15 22:41:57 -070040 printf("Image : rev ");
41 if (hdr->hdr_rev == FSP_HEADER_REVISION_1) {
42 printf("%d.%d",
43 (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff);
44 } else {
45 printf("%d.%d.%d.%d",
46 (hdr->img_rev >> 24) & 0xff, (hdr->img_rev >> 16) & 0xff,
47 (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff);
48 }
49 printf(", id ");
Bin Meng010921a2015-10-10 01:47:59 -070050 for (i = 0; i < ARRAY_SIZE(hdr->img_id); i++)
51 printf("%c", hdr->img_id[i]);
52 printf(", addr 0x%08x, size %d\n", img_addr, hdr->img_size);
Bin Mengb3fd2122017-08-15 22:41:57 -070053 if (hdr->hdr_rev == FSP_HEADER_REVISION_2) {
54 printf("GFX :%ssupported\n",
55 hdr->img_attr & FSP_ATTR_GRAPHICS_SUPPORT ? " " : " un");
56 }
Bin Meng010921a2015-10-10 01:47:59 -070057 printf("VPD : addr 0x%08x, size %d\n",
58 hdr->cfg_region_off + img_addr, hdr->cfg_region_size);
59 printf("\nNumber of APIs Supported : %d\n", hdr->api_num);
60 printf("\tTempRamInit : 0x%08x\n", hdr->fsp_tempram_init + img_addr);
61 printf("\tFspInit : 0x%08x\n", hdr->fsp_init + img_addr);
62 printf("\tFspNotify : 0x%08x\n", hdr->fsp_notify + img_addr);
Bin Mengb3fd2122017-08-15 22:41:57 -070063 if (hdr->hdr_rev == FSP_HEADER_REVISION_2) {
64 printf("\tMemoryInit : 0x%08x\n",
65 hdr->fsp_mem_init + img_addr);
66 printf("\tTempRamExit : 0x%08x\n",
67 hdr->fsp_tempram_exit + img_addr);
68 printf("\tSiliconInit : 0x%08x\n",
69 hdr->fsp_silicon_init + img_addr);
70 }
Bin Meng010921a2015-10-10 01:47:59 -070071
72 return 0;
73}
74
Bin Meng62716eb2015-10-10 01:47:58 -070075static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Bin Mengba7b38a2014-12-12 21:05:32 +080076{
Bin Meng949dbc12014-12-30 16:02:05 +080077 const struct hob_header *hdr;
Bin Mengb2439ae2015-01-06 14:04:36 +080078 uint type;
Bin Mengba7b38a2014-12-12 21:05:32 +080079 char *desc;
80 int i = 0;
81
Bin Meng949dbc12014-12-30 16:02:05 +080082 hdr = gd->arch.hob_list;
Bin Mengba7b38a2014-12-12 21:05:32 +080083
Bin Meng949dbc12014-12-30 16:02:05 +080084 printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
Bin Mengba7b38a2014-12-12 21:05:32 +080085
Bin Mengb325cbb2015-10-10 01:47:57 -070086 printf("# | Address | Type | Len | ");
87 printf("%42s\n", "GUID");
88 printf("---|----------|-----------|------|-");
89 printf("------------------------------------------\n");
Bin Meng949dbc12014-12-30 16:02:05 +080090 while (!end_of_hob(hdr)) {
Bin Meng59fb7fb2015-12-11 02:55:51 -080091 printf("%02x | %08x | ", i, (unsigned int)hdr);
Bin Mengb2439ae2015-01-06 14:04:36 +080092 type = hdr->type;
Bin Mengba7b38a2014-12-12 21:05:32 +080093 if (type == HOB_TYPE_UNUSED)
94 desc = "*Unused*";
95 else if (type == HOB_TYPE_EOH)
Bin Mengfd755f02015-10-10 01:47:56 -070096 desc = "*EOH*";
Bin Mengba7b38a2014-12-12 21:05:32 +080097 else if (type >= 0 && type <= ARRAY_SIZE(hob_type))
98 desc = hob_type[type];
99 else
Bin Mengfd755f02015-10-10 01:47:56 -0700100 desc = "*Invalid*";
Bin Meng59fb7fb2015-12-11 02:55:51 -0800101 printf("%-9s | %04x | ", desc, hdr->len);
Bin Mengb325cbb2015-10-10 01:47:57 -0700102
103 if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
104 type == HOB_TYPE_GUID_EXT) {
105 struct efi_guid *guid = (struct efi_guid *)(hdr + 1);
106 int j;
107
108 printf("%08x-%04x-%04x", guid->data1,
109 guid->data2, guid->data3);
110 for (j = 0; j < ARRAY_SIZE(guid->data4); j++)
111 printf("-%02x", guid->data4[j]);
112 } else {
113 printf("%42s", "Not Available");
114 }
115 printf("\n");
Bin Meng949dbc12014-12-30 16:02:05 +0800116 hdr = get_next_hob(hdr);
Bin Mengba7b38a2014-12-12 21:05:32 +0800117 i++;
118 }
119
120 return 0;
121}
122
Bin Meng62716eb2015-10-10 01:47:58 -0700123static cmd_tbl_t fsp_commands[] = {
Bin Meng010921a2015-10-10 01:47:59 -0700124 U_BOOT_CMD_MKENT(hdr, 0, 1, do_hdr, "", ""),
Bin Meng62716eb2015-10-10 01:47:58 -0700125 U_BOOT_CMD_MKENT(hob, 0, 1, do_hob, "", ""),
126};
127
128static int do_fsp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
129{
130 cmd_tbl_t *fsp_cmd;
131 int ret;
132
133 if (argc < 2)
134 return CMD_RET_USAGE;
135 fsp_cmd = find_cmd_tbl(argv[1], fsp_commands, ARRAY_SIZE(fsp_commands));
136 argc -= 2;
137 argv += 2;
138 if (!fsp_cmd || argc > fsp_cmd->maxargs)
139 return CMD_RET_USAGE;
140
141 ret = fsp_cmd->cmd(fsp_cmd, flag, argc, argv);
142
143 return cmd_process_error(fsp_cmd, ret);
144}
145
Bin Mengba7b38a2014-12-12 21:05:32 +0800146U_BOOT_CMD(
Bin Meng62716eb2015-10-10 01:47:58 -0700147 fsp, 2, 1, do_fsp,
148 "Show Intel Firmware Support Package (FSP) related information",
Bin Meng010921a2015-10-10 01:47:59 -0700149 "hdr - Print FSP header information\n"
150 "fsp hob - Print FSP Hand-Off Block (HOB) information"
Bin Mengba7b38a2014-12-12 21:05:32 +0800151);