From patchwork Thu Feb 21 06:26:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1045769 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="KzblsckD"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 444kxP3yywz9sBF for ; Thu, 21 Feb 2019 17:25:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id AB41AC22058; Thu, 21 Feb 2019 06:25:36 +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 A9C77C21E0D; Thu, 21 Feb 2019 06:25:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B4D2AC21E0D; Thu, 21 Feb 2019 06:25:31 +0000 (UTC) Received: from mail-yb1-f193.google.com (mail-yb1-f193.google.com [209.85.219.193]) by lists.denx.de (Postfix) with ESMTPS id 2C36FC21D8E for ; Thu, 21 Feb 2019 06:25:31 +0000 (UTC) Received: by mail-yb1-f193.google.com with SMTP id f5so105117ybf.3 for ; Wed, 20 Feb 2019 22:25:31 -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:mime-version :content-transfer-encoding; bh=zjBNQaSBRA4rMcYTQJl0LCbnt7rc8Ruh43ndbIKUlfA=; b=KzblsckDvsvEG33wUFEUNbCiTYbYC7z2oN4lLruSQx2Duwb5YsaLNH3AMhuPuZjkel CI9KdHefJBCdXulItPpzpb4SaYU1Y7axp55hcGuDvhHRcsgnRtahsn4TXRHqQPz0jtAy Jt7OxPG0AaR12gZSZmeCr9iXTJgHHzkwS9k7kHnXMwCBsJ1cDmhRSMw5qLaR2kBGTdMk tKX/XoPtAHmopmq9KT4DyL9MTJ4OPMB4b38FDBbPhfdLrYulesLZNUv/YKSGmJeSk+n2 8pQFoj/ZcHvjhaUdnuumsT0uaAQVrBHDKIOkZeRxwna59lybUfvCR+Lm3SjmH0hTUfgC QytA== 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:mime-version :content-transfer-encoding; bh=zjBNQaSBRA4rMcYTQJl0LCbnt7rc8Ruh43ndbIKUlfA=; b=OL3TRiKnv9lM7WoD7jx8awxrAWgCzJH6UNpm+6Ib5c0BcZcEkSSkmYZRoJCfYoZto6 gByFRxQraQYnbL2HR2oY8QAi5bStqocQLJAKDdWP6jNv2NKHTzNE7jKNLO/rQVvuVrYI nNPBjPP/bFgR4m2pOSjniICnXI3BLWVsigpbfZi24edVTbcVy3Lk3je9qpzY/vo/kozD YCula3wqi5SQi26G0plr7gtZM05hRE9hw70OiwnmWkc92QXXG5D5n139BCwwI8KUSLbP /uUEE+VBGQb6UZm3m0Al3/FwtSER8ClVhMcQVpEyzcqeCuTJb7PowoalhWNh4ppOV3C1 +0xg== X-Gm-Message-State: AHQUAuZ0mIoG2TYIrRtzPbhKcjWNtsL6owblpMkHC6ntiubb0fm0aUBb boLivJtDiCQE/B3oukEAjW4YeA== X-Google-Smtp-Source: AHgI3IadC1voFYT7waJ1PSt0/MWeE4p+CgHgWt13h6QXH3XxDlYWcZYkzGT0VS9kKoh6jPC1lVK/KQ== X-Received: by 2002:a25:da06:: with SMTP id n6mr30973830ybf.268.1550730329559; Wed, 20 Feb 2019 22:25:29 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z77sm6482504ywz.91.2019.02.20.22.25.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 22:25:29 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Thu, 21 Feb 2019 15:26:45 +0900 Message-Id: <20190221062652.3641-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v7 0/7] cmd: add efidebug for efi environment 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" This patch set is a collection of patches to enhance efi user interfaces /commands. It will help improve user experience on efi boot and make it more usable *without* edk2's shell utility. Let's see how it works: => efidebug boot add 1 SHELL scsi 1:1 /Shell.efi "" => efidebug boot add 2 HELLO scsi 1:1 /hello.efi "" => efidebug boot dump Boot0001: attributes: A-- (0x00000001) label: SHELL file_path: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)/HD(1,MBR,0x086246ba,0x800,0x40000)/\\Shell.efi data: Boot0002: attributes: A-- (0x00000001) label: HELLO file_path: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(1,0)/HD(1,MBR,0x086246ba,0x800,0x40000)/\\hello.efi data: => efidebug boot order 1 2 => efidebug boot order 1: Boot0001: SHELL 2: Boot0002: HELLO => run -e Boot0002 (or bootefi bootmgr - 2) ; '-' means no dtb specified WARNING: booting without device tree Booting: HELLO ## Starting EFI application at 000000007db8b040 ... Hello, world! ## Application terminated, r = 0 => env set -e PlatformLang en ; important! => env print -e Boot0001: BS|RT, DataSize = 0x79 00000000: 01 00 00 00 66 00 53 00 48 00 45 00 4c 00 4c 00 ....f.S.H.E.L.L. 00000010: 00 00 01 04 14 00 b9 73 1d e6 84 a3 cc 4a ae ab .......s.....J.. 00000020: 82 e8 28 f3 62 8b 03 02 08 00 01 00 00 00 04 01 ..(.b........... 00000030: 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 00 *............... 00000040: 04 00 00 00 00 00 ba 46 62 08 00 00 00 00 00 00 .......Fb....... 00000050: 00 00 00 00 00 00 01 01 04 04 1c 00 5c 00 5c 00 ............\.\. 00000060: 53 00 68 00 65 00 6c 00 6c 00 2e 00 65 00 66 00 S.h.e.l.l...e.f. 00000070: 69 00 00 00 7f ff 04 00 00 i........ Boot0002: BS|RT, DataSize = 0x79 00000000: 01 00 00 00 66 00 48 00 45 00 4c 00 4c 00 4f 00 ....f.H.E.L.L.O. 00000010: 00 00 01 04 14 00 b9 73 1d e6 84 a3 cc 4a ae ab .......s.....J.. 00000020: 82 e8 28 f3 62 8b 03 02 08 00 01 00 00 00 04 01 ..(.b........... 00000030: 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 00 *............... 00000040: 04 00 00 00 00 00 ba 46 62 08 00 00 00 00 00 00 .......Fb....... 00000050: 00 00 00 00 00 00 01 01 04 04 1c 00 5c 00 5c 00 ............\.\. 00000060: 68 00 65 00 6c 00 6c 00 6f 00 2e 00 65 00 66 00 h.e.l.l.o...e.f. 00000070: 69 00 00 00 7f ff 04 00 00 i........ BootOrder: BS|RT, DataSize = 0x4 00000000: 01 00 02 00 .... PlatformLang: BS|RT, DataSize = 0x2 00000000: 65 6e en => run -e Boot0001 or bootefi bootmgr (UEFI shell ...) "env set" command now supports UEFI shell-like syntax: => env set -e foo =S\"akashi\" =0x012345 =Habcdef => env print -e foo foo: BS|RT, DataSize = 0xd 00000000: 61 6b 61 73 68 69 45 23 01 00 ab cd ef akashiE#..... Other useful sub commands are: => efidebug devices ; print uefi devices => efidebug drivers ; print uefi drivers => efidebug dh ; print uefi handles => efidebug images ; print loaded images => efidebug memmap ; dump uefi memory map Enjoy! -Takahiro Akashi Changes in v7 (Feb 21, 2019) * fix travis errors * make CMD_NVEDIT_EFI configurable * improve command help text * add function descriptions at every function * output error message when "boot add" fails * use locate_handle_buffer() instead of locate_handle() * use allocate_pool() instead of malloc() * wrap EFI function calls with EFI_CALL * Travis CI result: https://travis-ci.org/t-akashi/u-boot/builds/496298404 Changes in v6 (Jan 24, 2019) * re-organize the code so that we can compile in "env [set|print] -e" support with or without CONFIG_CMD_EFIDEBUG * remove "efidebug setvar" and "efidebug dumpvar" sub-commands * re-implement "env print -e" using GetNextVariableName API and print_hex_dump() * "env print -e" print more information, including attributes and size * change a header format at "devices" and "drivers" sub-commands Changes in v5 (Jan 21, 2019) * rename the command name from efitool to efidebug again * add it to MAINTAINERS * follow a standard way of adding sub commands * allow "env -e" syntax without enabling CONFIG_CMD_EFIDEBUG (merging v4's patch#8 into patch#1) * change "_"-prefixed function names * change some internal variables' names * not print an efi driver's name at "efidebug drivers", yet showing a device path * change protocol name strings from char to u16 at "efidebug dh" * add a helper function to print efi memory attributes at "efidebug memmap" Changes in v4 (Jan 15, 2019) * rename the command name from efishell to efitool * use efi_uintn_t for "size" if appropriate * correct a help text for "boot add" sub-command * "boot" sub-command always takes a hexadecimal number * use systab.boottime directly instead of a local variable, bs * fix a bug in "setvar" sub-command * fix a bug in "devices" and "dh" sub-command * fix a bug in "memmap" sub-command * add "boot next" sub-command to set BootNext variable * "drivers" sub-command prints more useful info, including a driver's name which originates from a corresponding u-boot efi driver * "dh" sub-commands prints more useful info, including a list of protocols which are bound to a given handle Changes in v3 (Dec 18, 2018) * split v2 into two separate patch series * add CONFIG_CMD_EFISHELL to enable/disable efishell command * add missing free() at several places in efishell command Changes in v2 (Nov 5, 2018) * modify efi_dp_from_name() for use in efishell * rename efi_marshal_load_option() to efi_serialize_load_option(), taking a "struct efi_load_option" as an argument * improve a format in dumping uefi variables * enhance a setvar syntax as efi's shell does * change a syntax from "bootefi bootmgr -2" to "bootefi bootmgr - 2" * add -e option to run command * add -e option to env command * add more sub-commands AKASHI Takahiro (7): cmd: env: add "-e" option for handling UEFI variables cmd: add efidebug command cmd: efidebug: add devices command cmd: efidebug: add drivers command cmd: efidebug: add dh command cmd: efidebug: add images command cmd: efidebug: add memmap command MAINTAINERS | 2 + cmd/Kconfig | 20 + cmd/Makefile | 2 + cmd/efidebug.c | 1038 +++++++++++++++++++++++++++++++++++++++++++++ cmd/nvedit.c | 28 +- cmd/nvedit_efi.c | 395 +++++++++++++++++ include/command.h | 8 + 7 files changed, 1492 insertions(+), 1 deletion(-) create mode 100644 cmd/efidebug.c create mode 100644 cmd/nvedit_efi.c