From patchwork Tue Dec 18 05:05:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 154068 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3283065ljp; Mon, 17 Dec 2018 21:09:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/UyUMlXbIqDfhl6MwYdrEUKF7MPGbwJoy9PNHzQHHp59QCZoeYre2kb6juHqmVJGA2kZKwq X-Received: by 2002:aa7:d35a:: with SMTP id m26mr9639682edr.244.1545109751796; Mon, 17 Dec 2018 21:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545109751; cv=none; d=google.com; s=arc-20160816; b=QSKKIyQVVlPSHlEgHJ1Io/Qw2TWGoADs+7kJzLAqCllqpry0XprlKP9Lj1rtqwbBQx pch3xoUABTdI6lFvKXq4AGA+oVoh7zvUd3nSvk3zHXZ2zjQFwddIhURiu4TRvwenfuET Qbgmco1oLdEnbGJopRG/RyR1u7LV/sp4GS2zFqjfEyR1gJe8Xs8/+I16ZSXtYeTy3bvU pMvEm4O3mNE7E03dF4dRsS+NqUhDMEVF13Vym+42JIIb1nytR4ceDYsKmzUxz8vz3QfF dJPEa+dQkcOPU/nIji9KDn7fnx7fqQIkg6iXxPaQhY6anZplcFSClGXkG0v7qsxfYKBF G7Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:message-id:date:to:from:dkim-signature; bh=agHiQjQgoKyL+Ikj0IXrmg9bAdVLXERttoOCnFHU09A=; b=GWMVAauxRzwYPH3zLb8WL4VB04rDuBqdV9MXhPC0ZSef9E+Y0SXO/Pks7fHvLqjIgA dBAOs9lGCe+1u/qHdwYuyV8fu/uo3cuQFtfAGVil2HHKLGqQQlasVtji11WaipSq2wbL 3AOrhi9kVKT8cErxkmscDBT3OYHR4g/5SSO3qyNfJtGoRzXEql3QfCx3rJhPk2rG1/wG KgxDNquov9feMRSp7WpgIdFa0W6ZxH1wUMbZfoUK1tR7AXHmObEv5qYvcP9CII9U3zuL Hz8Hv7lAjudbkdw0neOjDKsE8tCbvrOcgNCtgbXe5M0gR1gn8EE7tNjxGvdBDsycv9e3 BEWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PQmZm5is; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id w20si40916eds.451.2018.12.17.21.09.10; Mon, 17 Dec 2018 21:09:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PQmZm5is; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id B840BC21DFA; Tue, 18 Dec 2018 05:05:05 +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_BLOCKED, 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 8730BC21F79; Tue, 18 Dec 2018 05:04:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DD1F2C21FAA; Tue, 18 Dec 2018 05:01:44 +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 45C90C22018 for ; Tue, 18 Dec 2018 05:01:44 +0000 (UTC) Received: by mail-yb1-f195.google.com with SMTP id e124so5992648ybb.8 for ; Mon, 17 Dec 2018 21:01:44 -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=68bSM3ZWp8a/MxS9wREi7e01eM6IGuvuLFPQI16Fv44=; b=PQmZm5isTv1hYVnGHseeNKKhX6e1h8WCoh6e0KPJIklSPMlr/YgTZ6K5BJKzIxIFLK SZRkajN4F/ZIagdwHsOqgoBzpqAIWNphHMoao2SOZlwYYjhm9uBDtAlGwXJw9aS3o5vF /FvKGAtsQitR7tJk3afPq2DI9rD/fW8VUjBd4= 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=68bSM3ZWp8a/MxS9wREi7e01eM6IGuvuLFPQI16Fv44=; b=sD9BBu9gk+RiO3G0+EuIHpSD6h/p8WY5JxCbezOnm4JqM0m4aIIm3GuYFX1lg937vH m7LDpBnO2qAV90HMcIfB1O0b2Ro/+VlmSTyzdIdw+9xkc8FDcvrKb7+gMqdsNhbNw/Ln mUVrAmn061lmxxCQ3WOTJOM/h72q9sDJjBkKAbi1cufzzJoiyD8EqDpOQxLA5pwKGwpQ xztuQJih/ZzcIo3JmHx0YD1LHA6ip6kBk6x4iqNzg/EySKPmgO2MqWxfP5gLqUZI9dUu I5p6UfSMX2/LvDwO48ozrF73uJVcfDBkANEvpYZS258m1B6sqEq0JS9fnrFXin/Oct3g laRg== X-Gm-Message-State: AA+aEWa0l2Y/NwZt8vPMVL9WFE53dw0+uP0DjVE0l4Qoz4zGmg6rffcS 4LZSbxbAM8/qXOiA9bIMM/hiN8U1ra8= X-Received: by 2002:a25:1e46:: with SMTP id e67mr15858980ybe.328.1545109303068; Mon, 17 Dec 2018 21:01:43 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id h75sm5498367ywa.50.2018.12.17.21.01.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 21:01:42 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de Date: Tue, 18 Dec 2018 14:05:02 +0900 Message-Id: <20181218050510.20308-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 0/8] cmd: add efishell 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 contains only efishell-specific part of my original patch[1]. See also the other patch[2]. 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: => efishell boot add 1 SHELL mmc 0:1 /Shell.efi "" => efishell boot add 2 HELLO mmc 0:1 /hello.efi "" => efishell boot dump Boot0001: attributes: A-- (0x00000001) label: SHELL file_path: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,MBR,0x086246ba,0x800,0x40000)/\\Shell.efi data: Boot0002: attributes: A-- (0x00000001) label: HELLO file_path: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,MBR,0x086246ba,0x800,0x40000)/\\hello.efi data: => efishell boot order 1 2 => efishell 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! (or you can do "efishell setvar PlatformLang en") => env print -e Boot0001: {boot,run}(blob) 00000000: 01 00 00 00 68 00 53 00 ....h.S. 00000010: 48 00 45 00 4c 00 4c 00 H.E.L.L. 00000020: 00 00 01 04 14 00 b9 73 .......s 00000030: 1d e6 84 a3 cc 4a ae ab .....J.. 00000040: 82 e8 28 f3 62 8b 03 1a ..(.b... 00000050: 05 00 00 03 1a 05 00 00 ........ 00000060: 04 01 2a 00 01 00 00 00 ..*..... 00000070: 00 08 00 00 00 00 00 00 ........ 00000080: 00 00 04 00 00 00 00 00 ........ 00000090: ba 46 62 08 00 00 00 00 .Fb..... 000000a0: 00 00 00 00 00 00 00 00 ........ 000000b0: 01 01 04 04 1c 00 5c 00 ......\. 000000c0: 5c 00 53 00 68 00 65 00 \.S.h.e. 000000d0: 6c 00 6c 00 2e 00 65 00 l.l...e. 000000e0: 66 00 69 00 00 00 7f ff f.i.... 000000f0: 04 00 00 ... Boot0002: {boot,run}(blob) 00000000: 01 00 00 00 68 00 48 00 ....h.H. 00000010: 45 00 4c 00 4c 00 4f 00 E.L.L.O. 00000020: 00 00 01 04 14 00 b9 73 .......s 00000030: 1d e6 84 a3 cc 4a ae ab .....J.. 00000040: 82 e8 28 f3 62 8b 03 1a ..(.b... 00000050: 05 00 00 03 1a 05 00 00 ........ 00000060: 04 01 2a 00 01 00 00 00 ..*..... 00000070: 00 08 00 00 00 00 00 00 ........ 00000080: 00 00 04 00 00 00 00 00 ........ 00000090: ba 46 62 08 00 00 00 00 .Fb..... 000000a0: 00 00 00 00 00 00 00 00 ........ 000000b0: 01 01 04 04 1c 00 5c 00 ......\. 000000c0: 5c 00 68 00 65 00 6c 00 \.h.e.l. 000000d0: 6c 00 6f 00 2e 00 65 00 l.o...e. 000000e0: 66 00 69 00 00 00 7f ff f.i.... 000000f0: 04 00 00 ... BootOrder: {boot,run}(blob) 00000000: 01 00 02 00 .... OsIndicationsSupported: {ro,boot}(blob) 00000000: 00 00 00 00 00 00 00 00 ........ PlatformLang: {boot,run}(blob) 00000000: 65 6e en => run -e Boot0001 or bootefi bootmgr (shell ...) "setvar" command now supports efi shell-like syntax: => env set -e foo =S\"akashi\" =0x012345 =Habcdef => env print -e foo foo: {boot,run}(blob) 00000000: 61 6b 61 73 68 69 45 23 akashiE# 00000010: 01 00 ab cd ef ..... Other useful sub commands are: => efishell devices ; print uefi devices => efishell drivers ; print uefi drivers => efishell images ; print loaded images => efishell dh ; print uefi handles => efishell memmap ; dump uefi memory map # I admit there is some room to improve the output from those commands. [1] https://lists.denx.de/pipermail/u-boot/2018-November/346450.html [2] https://lists.denx.de/pipermail/u-boot/2018-December/352403.html Enjoy! -Takahiro Akashi 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 (8): cmd: add efishell command cmd: efishell: add devices command cmd: efishell: add drivers command cmd: efishell: add images command cmd: efishell: add memmap command cmd: efishell: add dh command cmd: efishell: export uefi variable helper functions cmd: env: add "-e" option for handling UEFI variables cmd/Kconfig | 10 + cmd/Makefile | 1 + cmd/efishell.c | 1000 +++++++++++++++++++++++++++++++++++++++++++++ cmd/nvedit.c | 61 ++- include/command.h | 4 + 5 files changed, 1074 insertions(+), 2 deletions(-) create mode 100644 cmd/efishell.c