blob: e3f512beee88e4d9b132b4b1944900d3496d7a54 [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];
Simon Glassd11544df2020-09-22 14:54:48 -060037 int seq = -1; /* Show all by default */
Park, Aiden7165fd52019-08-03 08:30:31 +000038
Simon Glassd11544df2020-09-22 14:54:48 -060039 argc--;
40 argv++;
41 if (argc)
42 seq = simple_strtol(*argv, NULL, 16);
Park, Aiden7165fd52019-08-03 08:30:31 +000043 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 Glassd11544df2020-09-22 14:54:48 -060051 for (i = 0; !end_of_hob(hdr); i++, hdr = get_next_hob(hdr)) {
52 if (seq != -1 && seq != i)
53 continue;
Park, Aiden7165fd52019-08-03 08:30:31 +000054 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, Aiden7165fd52019-08-03 08:30:31 +000075 }
76
77 return 0;
78}
79
Simon Glassd11544df2020-09-22 14:54:48 -060080U_BOOT_CMD(hob, 2, 1, do_hob,
81 "[seq] Print Hand-Off Block (HOB) information"
82 " seq - Record # to show (all by default)",
Park, Aiden7165fd52019-08-03 08:30:31 +000083 ""
84);