Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 2 | /* |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 3 | * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <command.h> |
Simon Glass | 1021af4 | 2015-01-27 22:13:36 -0700 | [diff] [blame] | 8 | #include <asm/fsp/fsp_support.h> |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 9 | |
| 10 | DECLARE_GLOBAL_DATA_PTR; |
| 11 | |
| 12 | static char *hob_type[] = { |
| 13 | "reserved", |
| 14 | "Hand-off", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 15 | "Mem Alloc", |
| 16 | "Res Desc", |
| 17 | "GUID Ext", |
| 18 | "FV", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 19 | "CPU", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 20 | "Mem Pool", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 21 | "reserved", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 22 | "FV2", |
| 23 | "Load PEIM", |
| 24 | "Capsule", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 25 | }; |
| 26 | |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 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); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 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 "); |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 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); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 53 | if (hdr->hdr_rev == FSP_HEADER_REVISION_2) { |
| 54 | printf("GFX :%ssupported\n", |
| 55 | hdr->img_attr & FSP_ATTR_GRAPHICS_SUPPORT ? " " : " un"); |
| 56 | } |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 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); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 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 | } |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 75 | static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 76 | { |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 77 | const struct hob_header *hdr; |
Bin Meng | b2439ae | 2015-01-06 14:04:36 +0800 | [diff] [blame] | 78 | uint type; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 79 | char *desc; |
| 80 | int i = 0; |
| 81 | |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 82 | hdr = gd->arch.hob_list; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 83 | |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 84 | printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 85 | |
Bin Meng | b325cbb | 2015-10-10 01:47:57 -0700 | [diff] [blame] | 86 | printf("# | Address | Type | Len | "); |
| 87 | printf("%42s\n", "GUID"); |
| 88 | printf("---|----------|-----------|------|-"); |
| 89 | printf("------------------------------------------\n"); |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 90 | while (!end_of_hob(hdr)) { |
Bin Meng | 59fb7fb | 2015-12-11 02:55:51 -0800 | [diff] [blame] | 91 | printf("%02x | %08x | ", i, (unsigned int)hdr); |
Bin Meng | b2439ae | 2015-01-06 14:04:36 +0800 | [diff] [blame] | 92 | type = hdr->type; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 93 | if (type == HOB_TYPE_UNUSED) |
| 94 | desc = "*Unused*"; |
| 95 | else if (type == HOB_TYPE_EOH) |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 96 | desc = "*EOH*"; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 97 | else if (type >= 0 && type <= ARRAY_SIZE(hob_type)) |
| 98 | desc = hob_type[type]; |
| 99 | else |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 100 | desc = "*Invalid*"; |
Bin Meng | 59fb7fb | 2015-12-11 02:55:51 -0800 | [diff] [blame] | 101 | printf("%-9s | %04x | ", desc, hdr->len); |
Bin Meng | b325cbb | 2015-10-10 01:47:57 -0700 | [diff] [blame] | 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"); |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 116 | hdr = get_next_hob(hdr); |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 117 | i++; |
| 118 | } |
| 119 | |
| 120 | return 0; |
| 121 | } |
| 122 | |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 123 | static cmd_tbl_t fsp_commands[] = { |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 124 | U_BOOT_CMD_MKENT(hdr, 0, 1, do_hdr, "", ""), |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 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 | |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 146 | U_BOOT_CMD( |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 147 | fsp, 2, 1, do_fsp, |
| 148 | "Show Intel Firmware Support Package (FSP) related information", |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 149 | "hdr - Print FSP header information\n" |
| 150 | "fsp hob - Print FSP Hand-Off Block (HOB) information" |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 151 | ); |