Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 1 | /* |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 2 | * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
Simon Glass | 1021af4 | 2015-01-27 22:13:36 -0700 | [diff] [blame] | 9 | #include <asm/fsp/fsp_support.h> |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 10 | |
| 11 | DECLARE_GLOBAL_DATA_PTR; |
| 12 | |
| 13 | static char *hob_type[] = { |
| 14 | "reserved", |
| 15 | "Hand-off", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 16 | "Mem Alloc", |
| 17 | "Res Desc", |
| 18 | "GUID Ext", |
| 19 | "FV", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 20 | "CPU", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 21 | "Mem Pool", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 22 | "reserved", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 23 | "FV2", |
| 24 | "Load PEIM", |
| 25 | "Capsule", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 26 | }; |
| 27 | |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 28 | static 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); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 41 | printf("Image : rev "); |
| 42 | if (hdr->hdr_rev == FSP_HEADER_REVISION_1) { |
| 43 | printf("%d.%d", |
| 44 | (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff); |
| 45 | } else { |
| 46 | printf("%d.%d.%d.%d", |
| 47 | (hdr->img_rev >> 24) & 0xff, (hdr->img_rev >> 16) & 0xff, |
| 48 | (hdr->img_rev >> 8) & 0xff, hdr->img_rev & 0xff); |
| 49 | } |
| 50 | printf(", id "); |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 51 | for (i = 0; i < ARRAY_SIZE(hdr->img_id); i++) |
| 52 | printf("%c", hdr->img_id[i]); |
| 53 | printf(", addr 0x%08x, size %d\n", img_addr, hdr->img_size); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 54 | if (hdr->hdr_rev == FSP_HEADER_REVISION_2) { |
| 55 | printf("GFX :%ssupported\n", |
| 56 | hdr->img_attr & FSP_ATTR_GRAPHICS_SUPPORT ? " " : " un"); |
| 57 | } |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 58 | printf("VPD : addr 0x%08x, size %d\n", |
| 59 | hdr->cfg_region_off + img_addr, hdr->cfg_region_size); |
| 60 | printf("\nNumber of APIs Supported : %d\n", hdr->api_num); |
| 61 | printf("\tTempRamInit : 0x%08x\n", hdr->fsp_tempram_init + img_addr); |
| 62 | printf("\tFspInit : 0x%08x\n", hdr->fsp_init + img_addr); |
| 63 | printf("\tFspNotify : 0x%08x\n", hdr->fsp_notify + img_addr); |
Bin Meng | b3fd212 | 2017-08-15 22:41:57 -0700 | [diff] [blame] | 64 | if (hdr->hdr_rev == FSP_HEADER_REVISION_2) { |
| 65 | printf("\tMemoryInit : 0x%08x\n", |
| 66 | hdr->fsp_mem_init + img_addr); |
| 67 | printf("\tTempRamExit : 0x%08x\n", |
| 68 | hdr->fsp_tempram_exit + img_addr); |
| 69 | printf("\tSiliconInit : 0x%08x\n", |
| 70 | hdr->fsp_silicon_init + img_addr); |
| 71 | } |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 76 | 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] | 77 | { |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 78 | const struct hob_header *hdr; |
Bin Meng | b2439ae | 2015-01-06 14:04:36 +0800 | [diff] [blame] | 79 | uint type; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 80 | char *desc; |
| 81 | int i = 0; |
| 82 | |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 83 | hdr = gd->arch.hob_list; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 84 | |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 85 | printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 86 | |
Bin Meng | b325cbb | 2015-10-10 01:47:57 -0700 | [diff] [blame] | 87 | printf("# | Address | Type | Len | "); |
| 88 | printf("%42s\n", "GUID"); |
| 89 | printf("---|----------|-----------|------|-"); |
| 90 | printf("------------------------------------------\n"); |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 91 | while (!end_of_hob(hdr)) { |
Bin Meng | 59fb7fb | 2015-12-11 02:55:51 -0800 | [diff] [blame] | 92 | printf("%02x | %08x | ", i, (unsigned int)hdr); |
Bin Meng | b2439ae | 2015-01-06 14:04:36 +0800 | [diff] [blame] | 93 | type = hdr->type; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 94 | if (type == HOB_TYPE_UNUSED) |
| 95 | desc = "*Unused*"; |
| 96 | else if (type == HOB_TYPE_EOH) |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 97 | desc = "*EOH*"; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 98 | else if (type >= 0 && type <= ARRAY_SIZE(hob_type)) |
| 99 | desc = hob_type[type]; |
| 100 | else |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 101 | desc = "*Invalid*"; |
Bin Meng | 59fb7fb | 2015-12-11 02:55:51 -0800 | [diff] [blame] | 102 | printf("%-9s | %04x | ", desc, hdr->len); |
Bin Meng | b325cbb | 2015-10-10 01:47:57 -0700 | [diff] [blame] | 103 | |
| 104 | if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC || |
| 105 | type == HOB_TYPE_GUID_EXT) { |
| 106 | struct efi_guid *guid = (struct efi_guid *)(hdr + 1); |
| 107 | int j; |
| 108 | |
| 109 | printf("%08x-%04x-%04x", guid->data1, |
| 110 | guid->data2, guid->data3); |
| 111 | for (j = 0; j < ARRAY_SIZE(guid->data4); j++) |
| 112 | printf("-%02x", guid->data4[j]); |
| 113 | } else { |
| 114 | printf("%42s", "Not Available"); |
| 115 | } |
| 116 | printf("\n"); |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 117 | hdr = get_next_hob(hdr); |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 118 | i++; |
| 119 | } |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 124 | static cmd_tbl_t fsp_commands[] = { |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 125 | U_BOOT_CMD_MKENT(hdr, 0, 1, do_hdr, "", ""), |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 126 | U_BOOT_CMD_MKENT(hob, 0, 1, do_hob, "", ""), |
| 127 | }; |
| 128 | |
| 129 | static int do_fsp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 130 | { |
| 131 | cmd_tbl_t *fsp_cmd; |
| 132 | int ret; |
| 133 | |
| 134 | if (argc < 2) |
| 135 | return CMD_RET_USAGE; |
| 136 | fsp_cmd = find_cmd_tbl(argv[1], fsp_commands, ARRAY_SIZE(fsp_commands)); |
| 137 | argc -= 2; |
| 138 | argv += 2; |
| 139 | if (!fsp_cmd || argc > fsp_cmd->maxargs) |
| 140 | return CMD_RET_USAGE; |
| 141 | |
| 142 | ret = fsp_cmd->cmd(fsp_cmd, flag, argc, argv); |
| 143 | |
| 144 | return cmd_process_error(fsp_cmd, ret); |
| 145 | } |
| 146 | |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 147 | U_BOOT_CMD( |
Bin Meng | 62716eb | 2015-10-10 01:47:58 -0700 | [diff] [blame] | 148 | fsp, 2, 1, do_fsp, |
| 149 | "Show Intel Firmware Support Package (FSP) related information", |
Bin Meng | 010921a | 2015-10-10 01:47:59 -0700 | [diff] [blame] | 150 | "hdr - Print FSP header information\n" |
| 151 | "fsp hob - Print FSP Hand-Off Block (HOB) information" |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 152 | ); |