From patchwork Thu Feb 21 06:26:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1045775 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WFfQmbgl"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 444l163MqYz9sBF for ; Thu, 21 Feb 2019 17:28:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 36A1EC21E0D; Thu, 21 Feb 2019 06:27:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 33FBCC22081; Thu, 21 Feb 2019 06:26:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 02CC5C21E60; Thu, 21 Feb 2019 06:25:47 +0000 (UTC) Received: from mail-yb1-f194.google.com (mail-yb1-f194.google.com [209.85.219.194]) by lists.denx.de (Postfix) with ESMTPS id 41C1CC2203E for ; Thu, 21 Feb 2019 06:25:43 +0000 (UTC) Received: by mail-yb1-f194.google.com with SMTP id j189so10623350ybj.9 for ; Wed, 20 Feb 2019 22:25:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T4o4H7+P3BhVWXjJF1xxsOUbt837lx1a9JAEEiqDEtg=; b=WFfQmbglvlYWZbq/chaAHQMb6JCXnSCr7qjnn6iAwzGU0i4VB6vqMS3q4qEmYZwkJM QfJ+ijwtJNa2G6JYPcEYGeWfH60l6Fv8M38Te61xGMXDjU+Bc2WN/NxozMij1AsZdrpA RAt8U1dX7xoxB+uxibx1CQWw9EDuiALoj+eEd2HIrjGFT8MJGfXx6CINUafvw/c/bEye WKrqO7LFYUpgVYQMQvWI6jIzJCRGD4qNTwVriC+cgMfWYthGi84R3Fm4E0ZpTMjq/yoO v9VysehLqnIsp2Gqs0infYwYOVbgJ0PR9GCWTjptoJLr2HrVp0CbY0JbVfk6VgezQWfI K6SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T4o4H7+P3BhVWXjJF1xxsOUbt837lx1a9JAEEiqDEtg=; b=F1jOr8Fn3lNdax/UQdVeZ4LG2yULCS7zoACvUDJFaz5ugGDTmxJ5dpiUD/malmI4Ud vJeJyyCJkMVh5v4IBV6g52FHETlY7E3WtPtqZTgJj5c8p9siRSt+RVPN4gAy1cnrDuSf Aimwrlzl6h/is05XulcEekSo14SJjvxADuLJ5XbLwHEgW/wolKCzPGo0RnByTo+KZWWI bYt1TgaO/wakXu1pCdUAKzKI8BEnAS3M3OZ1nwofny1ZLbd8vWw/y6JO+goul74oUoWc 80CZq3hHybQuVY4TQUSxav6gGa6h2DFZyR/MyACbQ70CfmRh9F/yJEs+r55nbW5Yw7TH cGdg== X-Gm-Message-State: AHQUAuaBYuKhrfLs1fEEOdKoGto9xJRwk280pa2xvUMSJ+apZ5pzB8lz BQwSGQw3eSIwwCx6lsf/gHmVOOFXwQA= X-Google-Smtp-Source: AHgI3IYiP3nAvuO/bNgqbPgN2CpPcbvIa1mfbY11Q/DVaGLHbxR79OcWz+y7DqQpvBJFeSljhhZ1sg== X-Received: by 2002:a25:61d1:: with SMTP id v200mr31745665ybb.517.1550730341868; Wed, 20 Feb 2019 22:25:41 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 82sm7917999ywq.97.2019.02.20.22.25.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 22:25:41 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Thu, 21 Feb 2019 15:26:47 +0900 Message-Id: <20190221062652.3641-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221062652.3641-1-takahiro.akashi@linaro.org> References: <20190221062652.3641-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v7 2/7] cmd: add efidebug command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Currently, there is no easy way to add or modify UEFI variables. In particular, bootmgr supports BootOrder/BootXXXX variables, it is quite hard to define them as u-boot variables because they are represented in a complicated and encoded format. The new command, efidebug, helps address these issues and give us more friendly interfaces: * efidebug boot add: add BootXXXX variable * efidebug boot rm: remove BootXXXX variable * efidebug boot dump: display all BootXXXX variables * efidebug boot next: set BootNext variable * efidebug boot order: set/display a boot order (BootOrder) Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- MAINTAINERS | 1 + cmd/Kconfig | 10 + cmd/Makefile | 1 + cmd/efidebug.c | 578 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 590 insertions(+) create mode 100644 cmd/efidebug.c diff --git a/MAINTAINERS b/MAINTAINERS index 0cce9db2660e..4fabb75eda37 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -471,6 +471,7 @@ F: lib/efi*/ F: test/py/tests/test_efi* F: test/unicode_ut.c F: cmd/bootefi.c +F: cmd/efidebug.c F: cmd/nvedit_efi.c F: tools/file2include.c diff --git a/cmd/Kconfig b/cmd/Kconfig index ddcdee44538d..88b086b074be 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1407,6 +1407,16 @@ config CMD_DISPLAY displayed on a simple board-specific display. Implement display_putc() to use it. +config CMD_EFIDEBUG + bool "efidebug - display/configure UEFI environment" + depends on EFI_LOADER + default n + help + Enable the 'efidebug' command which provides a subset of UEFI + shell utility with simplified functionality. It will be useful + particularly for managing boot parameters as well as examining + various EFI status for debugging. + config CMD_LED bool "led" default y if LED diff --git a/cmd/Makefile b/cmd/Makefile index b9ee51869d48..acb85f49fba8 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -51,6 +51,7 @@ obj-$(CONFIG_CMD_ECHO) += echo.o obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o obj-$(CONFIG_CMD_EEPROM) += eeprom.o obj-$(CONFIG_EFI_STUB) += efi.o +obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o obj-$(CONFIG_CMD_ELF) += elf.o obj-$(CONFIG_HUSH_PARSER) += exit.o obj-$(CONFIG_CMD_EXT4) += ext4.o diff --git a/cmd/efidebug.c b/cmd/efidebug.c new file mode 100644 index 000000000000..641ec98a4d32 --- /dev/null +++ b/cmd/efidebug.c @@ -0,0 +1,578 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * UEFI Shell-like command + * + * Copyright (c) 2018 AKASHI Takahiro, Linaro Limited + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * do_efi_boot_add() - set UEFI boot option + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, + * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure + * + * Implement efidebug "boot add" sub-command. + * Create or change UEFI boot option. + * - boot add