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 B7153C6FD1F for ; Sun, 19 Mar 2023 19:34:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8734E85CD5; Sun, 19 Mar 2023 20:31:59 +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="TIxQkVh1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BA8E985C88; Sun, 19 Mar 2023 20:31:22 +0100 (CET) Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (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 0B0CC85BFA for ; Sun, 19 Mar 2023 20:31:14 +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-pj1-x102e.google.com with SMTP id gp15-20020a17090adf0f00b0023d1bbd9f9eso14388753pjb.0 for ; Sun, 19 Mar 2023 12:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1679254272; 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=0FESs8pTG8FiPxASqr7m/tsJMc5QO2MVuDMDg6hzhEo=; b=TIxQkVh1GgcLjNx20+n77w9d/9EHXwgKPgeGzUiM7HTXbruzhvfpoyGwF40x8F3oQ4 BuSEQ5tQqiQDz/axKTMVHqP9a4MFNdqlNZSY0SE3kposZY1nd1D3+l8CU6QJMZUOki9N x1IXU6YVqE0JQaaMYzH4WBVyY10YLlfzh+kmI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679254272; 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=0FESs8pTG8FiPxASqr7m/tsJMc5QO2MVuDMDg6hzhEo=; b=Q116YoQUaoxIk/vtBBeF7LTyokAFVniY7ezWX1nx80wv4LlS/lL0+8vgSMX27QARi4 nDKZq9apv2RBuN2rhT0D4qFRLLaVRaZOj+lXReE7BSRiAESfDqdLZrtMj3VJJpXa3cQY z5WRoBi15gKTyTQqfwmX5ivDfgCWkWamjxrYJXUXQon0GOxSwST7uGIAKcPxYlPkuzQD D24j58F5SLNVQhkm0mk0jfrPiyfsUu5skwGWiTC41qSfc/lWj4HdGIAs3oMlzyEY2BPq uHronaA3FiYRAcaxDoFwkVRI4FZr+iaKVR7vFXqUVqujB0ft1zOggdhfIWvnKg+I/zH2 wcPQ== X-Gm-Message-State: AO0yUKXMUqZ0WI5mJ+ufXK8SL2W4IPVdtK+NZ1a/8UfNMjy0zHXMOH2n 2u5Jd1qKArcvdOSUGkR0qjhSufLsIcFW9cDFcbE= X-Google-Smtp-Source: AK7set+fK44PcEc8vTrgxvwgfFaFdN3FuB5czihMep3m2PSMkxIdlzpPncpT2BhSiiqnLkYPt65tmw== X-Received: by 2002:a17:903:1245:b0:19e:d6f2:feea with SMTP id u5-20020a170903124500b0019ed6f2feeamr16598550plh.9.1679254272126; Sun, 19 Mar 2023 12:31:12 -0700 (PDT) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id v12-20020a1709029a0c00b0019a75ea08e5sm5090651plp.33.2023.03.19.12.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:31:11 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Simon Glass Subject: [PATCH v3 10/12] efi: Split out table-listing code into a new file Date: Mon, 20 Mar 2023 08:30:14 +1300 Message-Id: <20230319193017.1084764-11-sjg@chromium.org> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230319193017.1084764-1-sjg@chromium.org> References: <20230319193017.1084764-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 v3: - Use %pUl to print the UUID 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 2d8bb4fc0529..1c5c6f3c00cb 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 000000000000..f4056096cd3f --- /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 %pUl %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 e6959ede930f..9622430c475e 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 c3087d3da28e..342dd52fed9f 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