From patchwork Mon Feb 25 06:54:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1047597 X-Patchwork-Delegate: xypron.glpk@gmx.de 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="kHCX0ifK"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 447CPN5DfSz9s1l for ; Mon, 25 Feb 2019 17:55:04 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 475C4C21DDC; Mon, 25 Feb 2019 06:54:55 +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, 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 B3847C21DEC; Mon, 25 Feb 2019 06:53:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C2B74C21D72; Mon, 25 Feb 2019 06:53:47 +0000 (UTC) Received: from mail-yb1-f195.google.com (mail-yb1-f195.google.com [209.85.219.195]) by lists.denx.de (Postfix) with ESMTPS id 4868EC21E07 for ; Mon, 25 Feb 2019 06:53:41 +0000 (UTC) Received: by mail-yb1-f195.google.com with SMTP id 66so3340499ybo.13 for ; Sun, 24 Feb 2019 22:53:41 -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=wV1uuW4Qmt2SQAyYGb25GvH2CBEBe27/jkpyGO0r6ws=; b=kHCX0ifKv0+cBynkmCP8LjbLn7ug8hZ3X+NtOZpHqjof4GJLjquL0gFEMkRzcHPvvK 4xoM7Yo3NETv0qkvZzoh084GTAzTd+CeN+naSz5VhSv6BTw6S+JPxM2zMToDP8cdRZ/V rdjRFCj8yteOGo0vEEwqNkgOMHHTWBvo1Mpn+kK55CFHkxyA/O0CDaXSqUobcCRyIv2/ r38vUikEoPCEopG352qMZY7Kyhs97qkP8/ZY9K7c5z6upTagBqHEYRcke7M8PIZ7uJ6E PCDE32WsByqm/TT8ijHDBMRgs2jVUxfxrUuzipnK2tCj7hGryltPcRfQpTnGjo+8gTjC v2OQ== 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=wV1uuW4Qmt2SQAyYGb25GvH2CBEBe27/jkpyGO0r6ws=; b=Kmky/zpLwIE4JxHon7xSdCyJPkBXdlU7rB3VHmKhI6RAsEIYtDgoluSblRQpOlapZ1 VO/COWfTtfADfg/HjlagSsiTBYgesXWGzRNqYYatBJrAw27kCtISXu8s1m3GfkDCC2g6 KS6kYElnJoigM4RDcG5YhYBjOB4XiBLfqO/cEHI2CU63fUBAMOBpCvH/abhnU49iyF0P sW9SZRjKDUJYJTxL+CYSMF+ASP59MahLDJGxVDmo+Gs9CcXYSIGM2eQIkX1cN627YjZW vEpDmpW7H/CirFnuExEfX/iPje0RuyvtRckMXraffFGFUMFM0vvk9HJoQLUKwgFRIVoN cU6w== X-Gm-Message-State: AHQUAubcohSzhdqdxVkWHHMk0Ew6FHhpQx+f9v2N/+qiHFPwIlMjDlwn S0WfuvX3u2srPhbbDk7gN4vv4t/5Hwc= X-Google-Smtp-Source: AHgI3IaL/Mb6OZPVaJot36r01nooYppNvBb8QzeWMrT9NHHvLoUyWl1FSH5gRcS2mE7B8vEpn/4KmA== X-Received: by 2002:a25:8b8f:: with SMTP id j15mr13104122ybl.252.1551077619962; Sun, 24 Feb 2019 22:53:39 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id k184sm488757ywa.85.2019.02.24.22.53.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 22:53:39 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Mon, 25 Feb 2019 15:54:38 +0900 Message-Id: <20190225065443.2000-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225065443.2000-1-takahiro.akashi@linaro.org> References: <20190225065443.2000-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v9 3/8] 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 | 587 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 599 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..a1e0832bc43e --- /dev/null +++ b/cmd/efidebug.c @@ -0,0 +1,587 @@ +// 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 + +#define RT systab.runtime + +/** + * do_efi_boot_add() - set UEFI load 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 load option. + * - boot add