Skip to content

Commit 1d32eee

Browse files
sjg20xypron
authored andcommitted
efi: Support showing tables
Add a command (for the app and payload) to display the tables provided by EFI. Note that for the payload the tables should always be present, so an error message is unnecessary and would bloat the code. Signed-off-by: Simon Glass <[email protected]>
1 parent 041840e commit 1d32eee

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

cmd/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ obj-$(CONFIG_CMD_EXTENSION) += extension_board.o
6262
obj-$(CONFIG_CMD_ECHO) += echo.o
6363
obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
6464
obj-$(CONFIG_CMD_EEPROM) += eeprom.o
65-
obj-$(CONFIG_EFI) += efi.o
65+
obj-$(CONFIG_EFI) += efi.o efi_common.o
6666
obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o efi_common.o
6767
obj-$(CONFIG_CMD_EFICONFIG) += eficonfig.o
6868
ifdef CONFIG_CMD_EFICONFIG

cmd/efi.c

+30-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
#include <common.h>
88
#include <command.h>
99
#include <efi.h>
10+
#include <efi_api.h>
1011
#include <errno.h>
1112
#include <log.h>
1213
#include <malloc.h>
1314
#include <sort.h>
15+
#include <uuid.h>
1416
#include <asm/global_data.h>
1517

1618
DECLARE_GLOBAL_DATA_PTR;
@@ -273,8 +275,34 @@ static int do_efi_mem(struct cmd_tbl *cmdtp, int flag, int argc,
273275
return ret ? CMD_RET_FAILURE : 0;
274276
}
275277

278+
static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc,
279+
char *const argv[])
280+
{
281+
struct efi_system_table *systab;
282+
283+
if (IS_ENABLED(CONFIG_EFI_APP)) {
284+
systab = efi_get_sys_table();
285+
if (!systab) {
286+
printf("Cannot read system table\n");
287+
return CMD_RET_FAILURE;
288+
}
289+
} else {
290+
int size;
291+
int ret;
292+
293+
ret = efi_info_get(EFIET_SYS_TABLE, (void **)&systab, &size);
294+
if (ret) /* this should not happen */
295+
return CMD_RET_FAILURE;
296+
}
297+
298+
efi_show_tables(systab);
299+
300+
return 0;
301+
}
302+
276303
static struct cmd_tbl efi_commands[] = {
277304
U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""),
305+
U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""),
278306
};
279307

280308
static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
@@ -298,5 +326,6 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
298326
U_BOOT_CMD(
299327
efi, 3, 1, do_efi,
300328
"EFI access",
301-
"mem [all] Dump memory information [include boot services]"
329+
"mem [all] Dump memory information [include boot services]\n"
330+
"tables Dump tables"
302331
);

doc/usage/cmd/efi.rst

+22
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Synopsis
1010
::
1111

1212
efi mem [all]
13+
efi tables
1314

1415
Description
1516
-----------
@@ -54,6 +55,14 @@ Attributes
5455
Shows a code for memory attributes. The key for this is shown below the
5556
table.
5657

58+
efi tables
59+
~~~~~~~~~~
60+
61+
This shows a list of the EFI tables provided in the system table. These use
62+
GUIDs so it is not possible in general to show the name of a table. But some
63+
effort is made to provide a useful table, where the GUID is known by U-Boot.
64+
65+
5766
Example
5867
-------
5968

@@ -195,3 +204,16 @@ Example
195204
f: uncached, write-coalescing, write-through, write-back
196205
rf: uncached, write-coalescing, write-through, write-back, needs runtime mapping
197206
1: uncached
207+
208+
209+
=> efi tables
210+
000000001f8edf98 ee4e5898-3914-4259-9d6e-dc7bd79403cf EFI_LZMA_COMPRESSED
211+
000000001ff2ace0 05ad34ba-6f02-4214-952e-4da0398e2bb9 EFI_DXE_SERVICES
212+
000000001f8ea018 7739f24c-93d7-11d4-9a3a-0090273fc14d EFI_HOB_LIST
213+
000000001ff2bac0 4c19049f-4137-4dd3-9c10-8b97a83ffdfa EFI_MEMORY_TYPE
214+
000000001ff2cb10 49152e77-1ada-4764-b7a2-7afefed95e8b (unknown)
215+
000000001f9ac018 060cc026-4c0d-4dda-8f41-595fef00a502 EFI_MEM_STATUS_CODE_REC
216+
000000001f9ab000 eb9d2d31-2d88-11d3-9a16-0090273fc14d SMBIOS table
217+
000000001fb7e000 eb9d2d30-2d88-11d3-9a16-0090273fc14d EFI_GUID_EFI_ACPI1
218+
000000001fb7e014 8868e871-e4f1-11d3-bc22-0080c73c8881 ACPI table
219+
000000001e654018 dcfa911d-26eb-469f-a220-38b7dc461220 (unknown)

0 commit comments

Comments
 (0)