Skip to content

Commit 041840e

Browse files
sjg20xypron
authored andcommitted
efi: Split out table-listing code into a new file
This code is used with EFI_LOADER but is also useful (with some modifications) for the EFI app and payload. Move it into a shared file. Show the address of the table so it can be examined if needed. Also show the table name as unknown if necessary. Our list of GUIDs is fairly small. Signed-off-by: Simon Glass <[email protected]>
1 parent 30c9646 commit 041840e

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

cmd/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ obj-$(CONFIG_CMD_ECHO) += echo.o
6363
obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
6464
obj-$(CONFIG_CMD_EEPROM) += eeprom.o
6565
obj-$(CONFIG_EFI) += efi.o
66-
obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o
66+
obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o efi_common.o
6767
obj-$(CONFIG_CMD_EFICONFIG) += eficonfig.o
6868
ifdef CONFIG_CMD_EFICONFIG
6969
ifdef CONFIG_EFI_MM_COMM_TEE

cmd/efi_common.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
/*
3+
* Common code for EFI commands
4+
*
5+
* Copyright 2023 Google LLC
6+
* Written by Simon Glass <[email protected]>
7+
*/
8+
9+
#include <common.h>
10+
#include <efi.h>
11+
#include <efi_api.h>
12+
#include <uuid.h>
13+
14+
void efi_show_tables(struct efi_system_table *systab)
15+
{
16+
int i;
17+
18+
for (i = 0; i < systab->nr_tables; i++) {
19+
struct efi_configuration_table *tab = &systab->tables[i];
20+
char guid_str[37];
21+
22+
uuid_bin_to_str(tab->guid.b, guid_str, 1);
23+
printf("%p %pUl %s\n", tab->table, guid_str,
24+
uuid_guid_get_str(tab->guid.b) ?: "(unknown)");
25+
}
26+
}

cmd/efidebug.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,7 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag,
649649
static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag,
650650
int argc, char *const argv[])
651651
{
652-
efi_uintn_t i;
653-
654-
for (i = 0; i < systab.nr_tables; ++i)
655-
printf("%pUl (%pUs)\n",
656-
&systab.tables[i].guid, &systab.tables[i].guid);
652+
efi_show_tables(&systab);
657653

658654
return CMD_RET_SUCCESS;
659655
}

include/efi.h

+9
Original file line numberDiff line numberDiff line change
@@ -648,4 +648,13 @@ int efi_call_exit_boot_services(void);
648648
int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp,
649649
int *desc_sizep, uint *versionp);
650650

651+
/**
652+
* efi_show_tables() - Show a list of available tables
653+
*
654+
* Shows the address, GUID (and name where known) for each table
655+
*
656+
* @systab: System table containing the list of tables
657+
*/
658+
void efi_show_tables(struct efi_system_table *systab);
659+
651660
#endif /* _LINUX_EFI_H */

0 commit comments

Comments
 (0)