Park, Aiden | 538aec9 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2014-2015, Bin Meng <bmeng.cn@gmail.com> |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <command.h> |
| 8 | #include <efi.h> |
Simon Glass | 6f04498 | 2020-05-10 11:39:52 -0600 | [diff] [blame] | 9 | #include <uuid.h> |
Park, Aiden | 538aec9 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 10 | #include <asm/hob.h> |
| 11 | |
| 12 | DECLARE_GLOBAL_DATA_PTR; |
| 13 | |
| 14 | static char *hob_type[] = { |
| 15 | "reserved", |
| 16 | "Hand-off", |
| 17 | "Mem Alloc", |
| 18 | "Res Desc", |
| 19 | "GUID Ext", |
| 20 | "FV", |
| 21 | "CPU", |
| 22 | "Mem Pool", |
| 23 | "reserved", |
| 24 | "FV2", |
| 25 | "Load PEIM", |
| 26 | "Capsule", |
| 27 | }; |
| 28 | |
| 29 | static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 30 | { |
| 31 | const struct hob_header *hdr; |
| 32 | uint type; |
| 33 | char *desc; |
| 34 | int i = 0; |
| 35 | efi_guid_t *guid; |
| 36 | char uuid[UUID_STR_LEN + 1]; |
| 37 | |
| 38 | hdr = gd->arch.hob_list; |
| 39 | |
| 40 | printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); |
| 41 | |
| 42 | printf("# | Address | Type | Len | "); |
| 43 | printf("%36s\n", "GUID"); |
| 44 | printf("---|----------|-----------|------|-"); |
| 45 | printf("------------------------------------\n"); |
| 46 | while (!end_of_hob(hdr)) { |
| 47 | printf("%02x | %08x | ", i, (unsigned int)hdr); |
| 48 | type = hdr->type; |
| 49 | if (type == HOB_TYPE_UNUSED) |
| 50 | desc = "*Unused*"; |
| 51 | else if (type == HOB_TYPE_EOH) |
| 52 | desc = "*EOH*"; |
| 53 | else if (type >= 0 && type <= ARRAY_SIZE(hob_type)) |
| 54 | desc = hob_type[type]; |
| 55 | else |
| 56 | desc = "*Invalid*"; |
| 57 | printf("%-9s | %04x | ", desc, hdr->len); |
| 58 | |
| 59 | if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC || |
| 60 | type == HOB_TYPE_GUID_EXT) { |
| 61 | guid = (efi_guid_t *)(hdr + 1); |
| 62 | uuid_bin_to_str(guid->b, uuid, UUID_STR_FORMAT_GUID); |
| 63 | printf("%s", uuid); |
| 64 | } else { |
| 65 | printf("%36s", "Not Available"); |
| 66 | } |
| 67 | printf("\n"); |
| 68 | hdr = get_next_hob(hdr); |
| 69 | i++; |
| 70 | } |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | U_BOOT_CMD(hob, 1, 1, do_hob, |
| 76 | "Print Hand-Off Block (HOB) information", |
| 77 | "" |
| 78 | ); |