Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9BC82C6FD19 for ; Fri, 10 Mar 2023 20:53:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9AF9585FD2; Fri, 10 Mar 2023 21:50:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jdny6ALA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 36E8B85FAD; Fri, 10 Mar 2023 21:49:40 +0100 (CET) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C7CD985F7E for ; Fri, 10 Mar 2023 21:49:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id b12so3654827ilf.9 for ; Fri, 10 Mar 2023 12:49:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678481365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cHOAnyNYUILjwbcPvw2/pUc74SKk88/5ZEjXs+N/mWk=; b=jdny6ALAnZ5l8eBeS68IepHYxsFkeJ8kfr3+iUD0RGh1nlT6iQ+qOG7mHKswGrD2qf WBeIOJ4dej1g6zv7BuIEVZ4p6h2n0GM5GOdVvJMdrja9bEMIqdr3YlzFYuCom9U44FMU AKWR3sRhrDhhg0r7VAbigCgvaK1o+kwGyBfhQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678481365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cHOAnyNYUILjwbcPvw2/pUc74SKk88/5ZEjXs+N/mWk=; b=5HbSFrILjDwhRPJWzkG3iJaw5HESzvoFyg9qJW2sDPTko+A56FOgHyff32zWGHiDG4 2RUEPghQ+8ckew0YSZqxUJcdAqsSsCmNZv6lGWgIV8vutazIP+CmtPDfN4nNIf9a9gZO O3es/JHmA100Zy/9lN/df92uPUyyeOzyZOiBT4GErY6X2y++dTa1ntrAB3VQGBzR7JIS pK4ABWFe6/8/q3bfYAeGl+sClm7JqgwwS0MUjfRvDYcVdyF10A51kv6HUQX1GI7cg23S xdgIlIYK2wGW+1MOL+8gnr6x4WsZNPTWVY/Gfcij5BX77npuiwVhY9ICjaOkJ1Vtq+4e j7SQ== X-Gm-Message-State: AO0yUKXCvrCubMArybedYy5ygvy+8vjrnOTdF58vpZkopFzPXBLNLFiY z3UFkNltRUWRR3YCv3U43IrKQ+Ce2VTavoZ0DeA= X-Google-Smtp-Source: AK7set8gKZkjETwcr4NuxS/zsWgFEkEl2Q6h4FKqydHmSY20kiGD0KIprY5ECa2nSLIwjdEUZiQtyw== X-Received: by 2002:a92:b50c:0:b0:317:93dc:10f5 with SMTP id f12-20020a92b50c000000b0031793dc10f5mr5172924ile.19.1678481365423; Fri, 10 Mar 2023 12:49:25 -0800 (PST) Received: from sjg1.roam.corp.google.com (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id a7-20020a056e020e0700b00315785bfabfsm273817ilk.47.2023.03.10.12.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 12:49:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Simon Glass Subject: [PATCH v2 10/12] efi: Split out table-listing code into a new file Date: Fri, 10 Mar 2023 12:49:00 -0800 Message-Id: <20230310204903.416969-11-sjg@chromium.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230310204903.416969-1-sjg@chromium.org> References: <20230310204903.416969-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 --- Changes in v2: - Add new patch to split out table-listing code into a new file cmd/Makefile | 2 +- cmd/efi_common.c | 26 ++++++++++++++++++++++++++ cmd/efidebug.c | 6 +----- include/efi.h | 9 +++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 cmd/efi_common.c diff --git a/cmd/Makefile b/cmd/Makefile index 2d8bb4fc052..1c5c6f3c00c 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -63,7 +63,7 @@ obj-$(CONFIG_CMD_ECHO) += echo.o obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o obj-$(CONFIG_CMD_EEPROM) += eeprom.o obj-$(CONFIG_EFI) += efi.o -obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o +obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o efi_common.o obj-$(CONFIG_CMD_EFICONFIG) += eficonfig.o ifdef CONFIG_CMD_EFICONFIG ifdef CONFIG_EFI_MM_COMM_TEE diff --git a/cmd/efi_common.c b/cmd/efi_common.c new file mode 100644 index 00000000000..7eedf0726a7 --- /dev/null +++ b/cmd/efi_common.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Common code for EFI commands + * + * Copyright 2023 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include + +void efi_show_tables(struct efi_system_table *systab) +{ + int i; + + for (i = 0; i < systab->nr_tables; i++) { + struct efi_configuration_table *tab = &systab->tables[i]; + char guid_str[37]; + + uuid_bin_to_str(tab->guid.b, guid_str, 1); + printf("%p %s %s\n", tab->table, guid_str, + uuid_guid_get_str(tab->guid.b) ?: "(unknown)"); + } +} diff --git a/cmd/efidebug.c b/cmd/efidebug.c index e6959ede930..9622430c475 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -649,11 +649,7 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - efi_uintn_t i; - - for (i = 0; i < systab.nr_tables; ++i) - printf("%pUl (%pUs)\n", - &systab.tables[i].guid, &systab.tables[i].guid); + efi_show_tables(&systab); return CMD_RET_SUCCESS; } diff --git a/include/efi.h b/include/efi.h index c3087d3da28..342dd52fed9 100644 --- a/include/efi.h +++ b/include/efi.h @@ -637,4 +637,13 @@ int efi_call_exit_boot_services(void); int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp, int *desc_sizep, uint *versionp); +/** + * efi_show_tables() - Show a list of available tables + * + * Shows the address, GUID (and name where known) for each table + * + * @systab: System table containing the list of tables + */ +void efi_show_tables(struct efi_system_table *systab); + #endif /* _LINUX_EFI_H */ -- 2.40.0.rc1.284.g88254d51c5-goog