From patchwork Thu Apr 28 08:09:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 567125 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp5232130map; Thu, 28 Apr 2022 01:10:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFJtn/yE0R3mEWVf9mQ/SD5PGHTgpG4/gdtx7D1uQS+RPAZLfYtk691HyPgLYPg7irq0Og X-Received: by 2002:a17:907:33c2:b0:6f3:9aff:d532 with SMTP id zk2-20020a17090733c200b006f39affd532mr17625401ejb.394.1651133453120; Thu, 28 Apr 2022 01:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651133453; cv=none; d=google.com; s=arc-20160816; b=Oc4xVDL2S1SovNpN0+GbV3NT5mD6PAtFyOOHxXqsWnNU85dIKxk4RFQ7k7RXhqVVVh LF8aQ+9PkEAbuyGBgZTs5ffkaTduX5p9GlZhZFE0M5Ga55nvo5WQoGzNpavj6LwjBHwX 6HEgwiCx4K7Tkje9x5Bi37ULlseEsYpoNH/3Th1mVZ6YxawXOPBazrX1zJusNHSgDwYL 5FmnrhmUL0CKJemHJgt9byALcnEZuVMYUbVG9WmR0RhXZYQ/klFdZTtdqTQLYEdXHxua YVQhnTzZqDzOyf3ELA/FHYXWT2eML0U4ZyCJOPI+8inv814oe3Xk/yQh8mwzd6RolHZj jizw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=FQ5Vf+S2zCNV/hJsCylmnILvx7VNqGKJO416/Tr/DTw=; b=g5ty0I48uxJnb2zMeSIJjH21JHw+scmCVR8tzOq8mVfOm+4TcKcmBB0dlSdiNHe8Ka 9Bolo+7dz+1jIFPaNzMshDS1LcPq0koXDdHqOsEpSGvCDqb96kQKhnElQ2w2Zxzw71vh JvaT6WvOfrO+Uqpuu9mPwmUydrwn6N7GXjJ18+brNF9XPnFZz6LiE6fPRNDERz4ocyoB ihyB+XxnLRfhC2cPkARpMvXwKcPmJPX+6n91Ar2Q+tR/TcmL+rx2C5GJNFN+I2OhQmUZ uveaB3aNBA7CDbQZTDPpyqbWwgpiW6igqTT9i5nuqFeO46Dc4zpfvL0LJQaWfJEAzTIg 5c8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rgDr8XWK; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id n15-20020aa7d04f000000b00423fc9d80ebsi3158649edo.338.2022.04.28.01.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 01:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rgDr8XWK; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A051280FEC; Thu, 28 Apr 2022 10:10:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rgDr8XWK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5652808BA; Thu, 28 Apr 2022 10:10:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (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 27155802EF for ; Thu, 28 Apr 2022 10:10:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pj1-x1029.google.com with SMTP id m14-20020a17090a34ce00b001d5fe250e23so3731017pjf.3 for ; Thu, 28 Apr 2022 01:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=FQ5Vf+S2zCNV/hJsCylmnILvx7VNqGKJO416/Tr/DTw=; b=rgDr8XWKwk13R7OwYhB3lALLS7jKQBWMOjM5tomuvlPcg0fcAfJnqwnMXsfbiWxrZx 7QbiJLSRe4ruzqkzIKdNr7bqiULPaaQ/h7qsYSQth9c9eRRvS7cgQ9tKl29uj6F1m7HX JxiHKgfb0s4B3r6KbZBIExHPssHESOW11M8akJcvKvXQxjPrBqiuJAnZofX7FB041uI1 EqfmfsUfETjJcAsSg4bDyymc+NMkO7hw5PleWy6m2e8yfvVjdq6lkYLXWLaZTK4draeN U8EftJP+cXnwcBNvFHqh93p/GtI5o9Xcnecqjqq9GIdl3tjcNP5UDAYZdGqvcpS7y9Ss 06Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FQ5Vf+S2zCNV/hJsCylmnILvx7VNqGKJO416/Tr/DTw=; b=yx8St+xsW3mDzyljeALexSjFuf0A9TlusUkVGbeRNVxIYuMSEQkQOhBsSY/RH8OWSJ a1wY5buauy/KLu8t5UA2UTlI6q1KGlr5O3nw+I/LefRTN/Kzob7SNd+bYmtk+z3J3mQV UpTHcyXlpBwrbibCb5clg318HZwlqdOm+CAq/iCX7TZ9NrLOeXA21rQZdxu/R+V2CtuM IywzEFT3yldFWuzYT6lyKLCmPrCBNcvAqJJEk3qwwsaIjSYNGY17v9/yGqugG1pL23nA WtskFdVcyjaFwDiNxT5PvKixUG0fGiWksFIzWlHfYWk06IvL8D5MVY2LkKXYGwlrDjVc 7NFg== X-Gm-Message-State: AOAM532JDmADQDCG0DGvdOJymnzKZxhKTZCYvSo1/h8cqUaj0c2Vwbf6 pnUO74JXbKEFB2WKbl0nUQQBPMFXxs4brA== X-Received: by 2002:a17:902:b10f:b0:156:612f:318d with SMTP id q15-20020a170902b10f00b00156612f318dmr32258325plr.143.1651133435947; Thu, 28 Apr 2022 01:10:35 -0700 (PDT) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id b15-20020a17090a7acf00b001cd4989ff5fsm5684259pjl.38.2022.04.28.01.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 01:10:35 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Francois Ozog , Mark Kettenis , Masahisa Kojima Subject: [PATCH v5 00/17] enable menu-driven boot device selection Date: Thu, 28 Apr 2022 17:09:33 +0900 Message-Id: <20220428080950.23509-1-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 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.5 at phobos.denx.de X-Virus-Status: Clean This patch series adds the menu-driven boot device selection, by extending the existing "bootmenu" to include UEFI and distro_boot related entries, and supports menu-driven UEFI boot variable maintenance. This patch series also includes the removable media support that UEFI specification requires to support. The menu example is as follows. *** U-Boot Boot Menu *** bootmenu_00 : Boot 1. kernel bootmenu_01 : Boot 2. kernel bootmenu_02 : Reset board UEFI BOOT0000 : debian UEFI BOOT0001 : ubuntu UEFI BOOT0002 : mmc0:1 UEFI BOOT0003 : mmc0:2 UEFI BOOT0004 : nvme0:1 UEFI BOOT0005 : nvme0:2 UEFI BOOT0006 : usb0:2 UEFI BOOT0007 : usb1:1 UEFI BOOT0008 : usb1:2 distro_boot : usb0 distro_boot : scsi0 distro_boot : virtio0 distro_boot : dhcp Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit [How to run on QEMU(arm64)] 1) clone source code $ git clone https://git.linaro.org/people/masahisa.kojima/u-boot.git \ -b kojima/bootmenu_v5_upstream_0428 --depth 1 2) prepare U-Boot .config $ make qemu_arm64_menuconfig then, enable CONFIG_CMD_BOOTMENU and CONFIG_AUTOBOOT_MENU_SHOW 3) run on QEMU(arm64) example $ qemu-system-aarch64 -machine virt,gic-version=3 -cpu cortex-a57 -m 4G -nographic \ -no-acpi -bios ./u-boot.bin -hda xxx.img [Major Changes] - rebased to v2022.07-rc1 - there is detailed changelog in each commit AKASHI Takahiro (2): efi_loader: export efi_locate_device_handle() efi_loader: bootmgr: add booting from removable media Masahisa Kojima (15): lib/charset: add u16_strlcat() function test: unit test for u16_strlcat() menu: always show the menu regardless of the number of entry menu: menu_get_choice() return -ENOENT if menu item is empty bootmenu: flush input buffer before waiting user key input bootmenu: update bootmenu_entry structure bootmenu: add UEFI boot entry into bootmenu bootmenu: add distro boot entry bootmenu: add Kconfig option not to enter U-Boot console bootmenu: factor out the user input handling efi_loader: menu-driven addition of UEFI boot option efi_loader: menu-driven deletion of UEFI boot variable efi_loader: menu-driven update of UEFI bootorder variable bootmenu: add removable media entries doc:bootmenu: add UEFI boot and distro boot support description cmd/Kconfig | 10 + cmd/bootmenu.c | 807 +++++++++---- common/menu.c | 142 ++- doc/usage/cmd/bootmenu.rst | 78 +- include/charset.h | 17 + include/config_distro_bootcmd.h | 14 +- include/efi_default_filename.h | 33 + include/efi_loader.h | 61 + include/menu.h | 20 + lib/charset.c | 22 + lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_bootmenu_maintenance.c | 1245 +++++++++++++++++++++ lib/efi_loader/efi_bootmgr.c | 50 +- lib/efi_loader/efi_boottime.c | 59 +- lib/efi_loader/efi_console.c | 81 ++ lib/efi_loader/efi_disk.c | 11 + lib/efi_loader/efi_file.c | 75 +- test/unicode_ut.c | 50 + 18 files changed, 2518 insertions(+), 258 deletions(-) create mode 100644 include/efi_default_filename.h create mode 100644 lib/efi_loader/efi_bootmenu_maintenance.c