Park, Aiden | 7165fd5 | 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 | ba06b3c | 2020-05-10 11:39:52 -0600 | [diff] [blame] | 9 | #include <uuid.h> |
Park, Aiden | 7165fd5 | 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 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 29 | static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Park, Aiden | 7165fd5 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 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]; |
Simon Glass | d11544df | 2020-09-22 14:54:48 -0600 | [diff] [blame^] | 37 | int seq = -1; /* Show all by default */ |
Park, Aiden | 7165fd5 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 38 | |
Simon Glass | d11544df | 2020-09-22 14:54:48 -0600 | [diff] [blame^] | 39 | argc--; |
| 40 | argv++; |
| 41 | if (argc) |
| 42 | seq = simple_strtol(*argv, NULL, 16); |
Park, Aiden | 7165fd5 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 43 | hdr = gd->arch.hob_list; |
| 44 | |
| 45 | printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); |
| 46 | |
| 47 | printf("# | Address | Type | Len | "); |
| 48 | printf("%36s\n", "GUID"); |
| 49 | printf("---|----------|-----------|------|-"); |
| 50 | printf("------------------------------------\n"); |
Simon Glass | d11544df | 2020-09-22 14:54:48 -0600 | [diff] [blame^] | 51 | for (i = 0; !end_of_hob(hdr); i++, hdr = get_next_hob(hdr)) { |
| 52 | if (seq != -1 && seq != i) |
| 53 | continue; |
Park, Aiden | 7165fd5 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 54 | printf("%02x | %08x | ", i, (unsigned int)hdr); |
| 55 | type = hdr->type; |
| 56 | if (type == HOB_TYPE_UNUSED) |
| 57 | desc = "*Unused*"; |
| 58 | else if (type == HOB_TYPE_EOH) |
| 59 | desc = "*EOH*"; |
| 60 | else if (type >= 0 && type <= ARRAY_SIZE(hob_type)) |
| 61 | desc = hob_type[type]; |
| 62 | else |
| 63 | desc = "*Invalid*"; |
| 64 | printf("%-9s | %04x | ", desc, hdr->len); |
| 65 | |
| 66 | if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC || |
| 67 | type == HOB_TYPE_GUID_EXT) { |
| 68 | guid = (efi_guid_t *)(hdr + 1); |
| 69 | uuid_bin_to_str(guid->b, uuid, UUID_STR_FORMAT_GUID); |
| 70 | printf("%s", uuid); |
| 71 | } else { |
| 72 | printf("%36s", "Not Available"); |
| 73 | } |
| 74 | printf("\n"); |
Park, Aiden | 7165fd5 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
Simon Glass | d11544df | 2020-09-22 14:54:48 -0600 | [diff] [blame^] | 80 | U_BOOT_CMD(hob, 2, 1, do_hob, |
| 81 | "[seq] Print Hand-Off Block (HOB) information" |
| 82 | " seq - Record # to show (all by default)", |
Park, Aiden | 7165fd5 | 2019-08-03 08:30:31 +0000 | [diff] [blame] | 83 | "" |
| 84 | ); |