blob: 6b1f7bda5b82f7d7052c93574c8e65fe2a5255c2 [file] [log] [blame]
Park, Aiden7165fd52019-08-03 08:30:31 +00001// 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 Glassba06b3c2020-05-10 11:39:52 -06009#include <uuid.h>
Park, Aiden7165fd52019-08-03 08:30:31 +000010#include <asm/hob.h>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14static 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 Glass09140112020-05-10 11:40:03 -060029static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Park, Aiden7165fd52019-08-03 08:30:31 +000030{
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
75U_BOOT_CMD(hob, 1, 1, do_hob,
76 "Print Hand-Off Block (HOB) information",
77 ""
78);