]> Git Repo - u-boot.git/blame - cmd/x86/hob.c
x86: hob: Add way to show a single hob entry
[u-boot.git] / cmd / x86 / hob.c
CommitLineData
7165fd58
PA
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2014-2015, Bin Meng <[email protected]>
4 */
5
6#include <common.h>
7#include <command.h>
8#include <efi.h>
ba06b3c5 9#include <uuid.h>
7165fd58
PA
10#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
09140113 29static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
7165fd58
PA
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];
d11544df 37 int seq = -1; /* Show all by default */
7165fd58 38
d11544df
SG
39 argc--;
40 argv++;
41 if (argc)
42 seq = simple_strtol(*argv, NULL, 16);
7165fd58
PA
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");
d11544df
SG
51 for (i = 0; !end_of_hob(hdr); i++, hdr = get_next_hob(hdr)) {
52 if (seq != -1 && seq != i)
53 continue;
7165fd58
PA
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");
7165fd58
PA
75 }
76
77 return 0;
78}
79
d11544df
SG
80U_BOOT_CMD(hob, 2, 1, do_hob,
81 "[seq] Print Hand-Off Block (HOB) information"
82 " seq - Record # to show (all by default)",
7165fd58
PA
83 ""
84);
This page took 0.057392 seconds and 4 git commands to generate.