Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
| 9 | #include <linux/compiler.h> |
Simon Glass | 1021af4 | 2015-01-27 22:13:36 -0700 | [diff] [blame] | 10 | #include <asm/fsp/fsp_support.h> |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 11 | |
| 12 | DECLARE_GLOBAL_DATA_PTR; |
| 13 | |
| 14 | static char *hob_type[] = { |
| 15 | "reserved", |
| 16 | "Hand-off", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 17 | "Mem Alloc", |
| 18 | "Res Desc", |
| 19 | "GUID Ext", |
| 20 | "FV", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 21 | "CPU", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 22 | "Mem Pool", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 23 | "reserved", |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 24 | "FV2", |
| 25 | "Load PEIM", |
| 26 | "Capsule", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 30 | { |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 31 | const struct hob_header *hdr; |
Bin Meng | b2439ae | 2015-01-06 14:04:36 +0800 | [diff] [blame] | 32 | uint type; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 33 | char *desc; |
| 34 | int i = 0; |
| 35 | |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 36 | hdr = gd->arch.hob_list; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 37 | |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 38 | printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 39 | |
Bin Meng | b325cbb | 2015-10-10 01:47:57 -0700 | [diff] [blame^] | 40 | printf("# | Address | Type | Len | "); |
| 41 | printf("%42s\n", "GUID"); |
| 42 | printf("---|----------|-----------|------|-"); |
| 43 | printf("------------------------------------------\n"); |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 44 | while (!end_of_hob(hdr)) { |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 45 | printf("%-2d | %08x | ", i, (unsigned int)hdr); |
Bin Meng | b2439ae | 2015-01-06 14:04:36 +0800 | [diff] [blame] | 46 | type = hdr->type; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 47 | if (type == HOB_TYPE_UNUSED) |
| 48 | desc = "*Unused*"; |
| 49 | else if (type == HOB_TYPE_EOH) |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 50 | desc = "*EOH*"; |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 51 | else if (type >= 0 && type <= ARRAY_SIZE(hob_type)) |
| 52 | desc = hob_type[type]; |
| 53 | else |
Bin Meng | fd755f0 | 2015-10-10 01:47:56 -0700 | [diff] [blame] | 54 | desc = "*Invalid*"; |
Bin Meng | b325cbb | 2015-10-10 01:47:57 -0700 | [diff] [blame^] | 55 | printf("%-9s | %-4d | ", desc, hdr->len); |
| 56 | |
| 57 | if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC || |
| 58 | type == HOB_TYPE_GUID_EXT) { |
| 59 | struct efi_guid *guid = (struct efi_guid *)(hdr + 1); |
| 60 | int j; |
| 61 | |
| 62 | printf("%08x-%04x-%04x", guid->data1, |
| 63 | guid->data2, guid->data3); |
| 64 | for (j = 0; j < ARRAY_SIZE(guid->data4); j++) |
| 65 | printf("-%02x", guid->data4[j]); |
| 66 | } else { |
| 67 | printf("%42s", "Not Available"); |
| 68 | } |
| 69 | printf("\n"); |
Bin Meng | 949dbc1 | 2014-12-30 16:02:05 +0800 | [diff] [blame] | 70 | hdr = get_next_hob(hdr); |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 71 | i++; |
| 72 | } |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 77 | U_BOOT_CMD( |
| 78 | hob, 1, 1, do_hob, |
Bin Meng | 255fd5c | 2014-12-17 15:50:49 +0800 | [diff] [blame] | 79 | "print Firmware Support Package (FSP) Hand-Off Block information", |
Bin Meng | ba7b38a | 2014-12-12 21:05:32 +0800 | [diff] [blame] | 80 | "" |
| 81 | ); |