blob: 4959edf11bb2aa0d7af1435746d897b5ff64e301 [file] [log] [blame]
Bin Meng90699df2014-12-12 21:05:32 +08001/*
Bin Meng3f56d452015-10-10 01:47:58 -07002 * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com>
Bin Meng90699df2014-12-12 21:05:32 +08003 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <command.h>
Simon Glassb93abfc2015-01-27 22:13:36 -07009#include <asm/fsp/fsp_support.h>
Bin Meng90699df2014-12-12 21:05:32 +080010
11DECLARE_GLOBAL_DATA_PTR;
12
13static char *hob_type[] = {
14 "reserved",
15 "Hand-off",
Bin Meng4f2f0052015-10-10 01:47:56 -070016 "Mem Alloc",
17 "Res Desc",
18 "GUID Ext",
19 "FV",
Bin Meng90699df2014-12-12 21:05:32 +080020 "CPU",
Bin Meng4f2f0052015-10-10 01:47:56 -070021 "Mem Pool",
Bin Meng90699df2014-12-12 21:05:32 +080022 "reserved",
Bin Meng4f2f0052015-10-10 01:47:56 -070023 "FV2",
24 "Load PEIM",
25 "Capsule",
Bin Meng90699df2014-12-12 21:05:32 +080026};
27
Bin Meng8938dbd2015-10-10 01:47:59 -070028static int do_hdr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
29{
30 struct fsp_header *hdr = find_fsp_header();
31 u32 img_addr = hdr->img_base;
32 char *sign = (char *)&hdr->sign;
33 int i;
34
35 printf("FSP : binary 0x%08x, header 0x%08x\n",
36 CONFIG_FSP_ADDR, (int)hdr);
37 printf("Header : sign ");
38 for (i = 0; i < sizeof(hdr->sign); i++)
39 printf("%c", *sign++);
40 printf(", size %d, rev %d\n", hdr->hdr_len, hdr->hdr_rev);
41 printf("Image : rev %d.%d, id ",
42 (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff);
43 for (i = 0; i < ARRAY_SIZE(hdr->img_id); i++)
44 printf("%c", hdr->img_id[i]);
45 printf(", addr 0x%08x, size %d\n", img_addr, hdr->img_size);
46 printf("VPD : addr 0x%08x, size %d\n",
47 hdr->cfg_region_off + img_addr, hdr->cfg_region_size);
48 printf("\nNumber of APIs Supported : %d\n", hdr->api_num);
49 printf("\tTempRamInit : 0x%08x\n", hdr->fsp_tempram_init + img_addr);
50 printf("\tFspInit : 0x%08x\n", hdr->fsp_init + img_addr);
51 printf("\tFspNotify : 0x%08x\n", hdr->fsp_notify + img_addr);
52
53 return 0;
54}
55
Bin Meng3f56d452015-10-10 01:47:58 -070056static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Bin Meng90699df2014-12-12 21:05:32 +080057{
Bin Meng2b215982014-12-30 16:02:05 +080058 const struct hob_header *hdr;
Bin Meng2f848bc2015-01-06 14:04:36 +080059 uint type;
Bin Meng90699df2014-12-12 21:05:32 +080060 char *desc;
61 int i = 0;
62
Bin Meng2b215982014-12-30 16:02:05 +080063 hdr = gd->arch.hob_list;
Bin Meng90699df2014-12-12 21:05:32 +080064
Bin Meng2b215982014-12-30 16:02:05 +080065 printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
Bin Meng90699df2014-12-12 21:05:32 +080066
Bin Menga0ecbe22015-10-10 01:47:57 -070067 printf("# | Address | Type | Len | ");
68 printf("%42s\n", "GUID");
69 printf("---|----------|-----------|------|-");
70 printf("------------------------------------------\n");
Bin Meng2b215982014-12-30 16:02:05 +080071 while (!end_of_hob(hdr)) {
Bin Meng4f2f0052015-10-10 01:47:56 -070072 printf("%-2d | %08x | ", i, (unsigned int)hdr);
Bin Meng2f848bc2015-01-06 14:04:36 +080073 type = hdr->type;
Bin Meng90699df2014-12-12 21:05:32 +080074 if (type == HOB_TYPE_UNUSED)
75 desc = "*Unused*";
76 else if (type == HOB_TYPE_EOH)
Bin Meng4f2f0052015-10-10 01:47:56 -070077 desc = "*EOH*";
Bin Meng90699df2014-12-12 21:05:32 +080078 else if (type >= 0 && type <= ARRAY_SIZE(hob_type))
79 desc = hob_type[type];
80 else
Bin Meng4f2f0052015-10-10 01:47:56 -070081 desc = "*Invalid*";
Bin Menga0ecbe22015-10-10 01:47:57 -070082 printf("%-9s | %-4d | ", desc, hdr->len);
83
84 if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
85 type == HOB_TYPE_GUID_EXT) {
86 struct efi_guid *guid = (struct efi_guid *)(hdr + 1);
87 int j;
88
89 printf("%08x-%04x-%04x", guid->data1,
90 guid->data2, guid->data3);
91 for (j = 0; j < ARRAY_SIZE(guid->data4); j++)
92 printf("-%02x", guid->data4[j]);
93 } else {
94 printf("%42s", "Not Available");
95 }
96 printf("\n");
Bin Meng2b215982014-12-30 16:02:05 +080097 hdr = get_next_hob(hdr);
Bin Meng90699df2014-12-12 21:05:32 +080098 i++;
99 }
100
101 return 0;
102}
103
Bin Meng3f56d452015-10-10 01:47:58 -0700104static cmd_tbl_t fsp_commands[] = {
Bin Meng8938dbd2015-10-10 01:47:59 -0700105 U_BOOT_CMD_MKENT(hdr, 0, 1, do_hdr, "", ""),
Bin Meng3f56d452015-10-10 01:47:58 -0700106 U_BOOT_CMD_MKENT(hob, 0, 1, do_hob, "", ""),
107};
108
109static int do_fsp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
110{
111 cmd_tbl_t *fsp_cmd;
112 int ret;
113
114 if (argc < 2)
115 return CMD_RET_USAGE;
116 fsp_cmd = find_cmd_tbl(argv[1], fsp_commands, ARRAY_SIZE(fsp_commands));
117 argc -= 2;
118 argv += 2;
119 if (!fsp_cmd || argc > fsp_cmd->maxargs)
120 return CMD_RET_USAGE;
121
122 ret = fsp_cmd->cmd(fsp_cmd, flag, argc, argv);
123
124 return cmd_process_error(fsp_cmd, ret);
125}
126
Bin Meng90699df2014-12-12 21:05:32 +0800127U_BOOT_CMD(
Bin Meng3f56d452015-10-10 01:47:58 -0700128 fsp, 2, 1, do_fsp,
129 "Show Intel Firmware Support Package (FSP) related information",
Bin Meng8938dbd2015-10-10 01:47:59 -0700130 "hdr - Print FSP header information\n"
131 "fsp hob - Print FSP Hand-Off Block (HOB) information"
Bin Meng90699df2014-12-12 21:05:32 +0800132);