]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
ba7b38a5 | 2 | /* |
62716ebb | 3 | * Copyright (C) 2014-2015, Bin Meng <[email protected]> |
ba7b38a5 BM |
4 | */ |
5 | ||
6 | #include <common.h> | |
7 | #include <command.h> | |
1021af4d | 8 | #include <asm/fsp/fsp_support.h> |
ba7b38a5 BM |
9 | |
10 | DECLARE_GLOBAL_DATA_PTR; | |
11 | ||
12 | static char *hob_type[] = { | |
13 | "reserved", | |
14 | "Hand-off", | |
fd755f08 BM |
15 | "Mem Alloc", |
16 | "Res Desc", | |
17 | "GUID Ext", | |
18 | "FV", | |
ba7b38a5 | 19 | "CPU", |
fd755f08 | 20 | "Mem Pool", |
ba7b38a5 | 21 | "reserved", |
fd755f08 BM |
22 | "FV2", |
23 | "Load PEIM", | |
24 | "Capsule", | |
ba7b38a5 BM |
25 | }; |
26 | ||
010921ae BM |
27 | static 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); | |
b3fd2126 BM |
40 | 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 "); | |
010921ae BM |
50 | 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); | |
b3fd2126 BM |
53 | if (hdr->hdr_rev == FSP_HEADER_REVISION_2) { |
54 | printf("GFX :%ssupported\n", | |
55 | hdr->img_attr & FSP_ATTR_GRAPHICS_SUPPORT ? " " : " un"); | |
56 | } | |
010921ae BM |
57 | 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); | |
b3fd2126 BM |
63 | 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 | } | |
010921ae BM |
71 | |
72 | return 0; | |
73 | } | |
74 | ||
62716ebb | 75 | static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
ba7b38a5 | 76 | { |
949dbc12 | 77 | const struct hob_header *hdr; |
b2439aec | 78 | uint type; |
ba7b38a5 BM |
79 | char *desc; |
80 | int i = 0; | |
81 | ||
949dbc12 | 82 | hdr = gd->arch.hob_list; |
ba7b38a5 | 83 | |
949dbc12 | 84 | printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); |
ba7b38a5 | 85 | |
b325cbb1 BM |
86 | printf("# | Address | Type | Len | "); |
87 | printf("%42s\n", "GUID"); | |
88 | printf("---|----------|-----------|------|-"); | |
89 | printf("------------------------------------------\n"); | |
949dbc12 | 90 | while (!end_of_hob(hdr)) { |
59fb7fbd | 91 | printf("%02x | %08x | ", i, (unsigned int)hdr); |
b2439aec | 92 | type = hdr->type; |
ba7b38a5 BM |
93 | if (type == HOB_TYPE_UNUSED) |
94 | desc = "*Unused*"; | |
95 | else if (type == HOB_TYPE_EOH) | |
fd755f08 | 96 | desc = "*EOH*"; |
ba7b38a5 BM |
97 | else if (type >= 0 && type <= ARRAY_SIZE(hob_type)) |
98 | desc = hob_type[type]; | |
99 | else | |
fd755f08 | 100 | desc = "*Invalid*"; |
59fb7fbd | 101 | printf("%-9s | %04x | ", desc, hdr->len); |
b325cbb1 BM |
102 | |
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"); | |
949dbc12 | 116 | hdr = get_next_hob(hdr); |
ba7b38a5 BM |
117 | i++; |
118 | } | |
119 | ||
120 | return 0; | |
121 | } | |
122 | ||
62716ebb | 123 | static cmd_tbl_t fsp_commands[] = { |
010921ae | 124 | U_BOOT_CMD_MKENT(hdr, 0, 1, do_hdr, "", ""), |
62716ebb BM |
125 | U_BOOT_CMD_MKENT(hob, 0, 1, do_hob, "", ""), |
126 | }; | |
127 | ||
128 | static 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 | ||
ba7b38a5 | 146 | U_BOOT_CMD( |
62716ebb BM |
147 | fsp, 2, 1, do_fsp, |
148 | "Show Intel Firmware Support Package (FSP) related information", | |
010921ae BM |
149 | "hdr - Print FSP header information\n" |
150 | "fsp hob - Print FSP Hand-Off Block (HOB) information" | |
ba7b38a5 | 151 | ); |