From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 647FAC433EF for ; Wed, 9 Mar 2022 02:37:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 84E30839C4; Wed, 9 Mar 2022 03:37:23 +0100 (CET) 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="JK15NJB6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 97B2383986; Wed, 9 Mar 2022 03:36:16 +0100 (CET) Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 795C983994 for ; Wed, 9 Mar 2022 03:36:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x52e.google.com with SMTP id c11so743683pgu.11 for ; Tue, 08 Mar 2022 18:36:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=md/XikORUPt57oWNoMOX+okgJMHvla3ckK1vFkwnJuc=; b=JK15NJB6ZhyjI61kfQiaCeo3YoV6wONAEQDKslnPRcF/SSnlvJPhEInmqIfqQDamvq j4nAppHyYvDeBbxu5DYuJcnBmRLYg6VLm5/s16Gt9G4wocUTo8xhmRg11sqbSbHRHqHN oRsbvuAYdI6ywSizfzMXciwqYgJeYW7L5261ED/RCajU17ychJnYb+OJDX8O9Zw9qOc2 7ZmAGAZ978h3KelOE1kLLyBkPDHYJHl3u1MumndvySSkxU2Qk17O2oaIborCwkkQcJFm ix0Jfl3gbLJWhAdDRnaGL1dB7g8GMJ6BEpfIc2Jj8zshZOShxiA+r3D89DMiQDxDUUMl 72WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=md/XikORUPt57oWNoMOX+okgJMHvla3ckK1vFkwnJuc=; b=xUsx3wZRFM0BblffH3Rd1QU6HykypQ29BAHyEyb934upuf24EGdc978bAOxOGq9BS5 VW90reSWItSRzGLFhajQHDOvaAULKJMq/r7GFpBso853V5H3sFeLUxlzqrD/t+w+lcOV X0KuY/fFuCUsvVJY/bNHvqt81btrke4FUd48K/Rcfc4UEGa1dqX1/9ZtUbe86m/ylXRd dM3XhXIT3vCYyANzCvJeSaQi7bUSGWDtJv5gLml9VN99Q19fEF3QtRALEjpopPZfJtST pBA7IN+kUBWy3hOCBNVTJ0EgO8J0vhufW2Y93l8+5MXRmM7EqZzNb9qpvCu9BbndBGR1 UBXg== X-Gm-Message-State: AOAM533Q1pEYZGkuwyEGAfwVXKzapnZqhRGoZGT9EkJEIDR3ddhgZhXx 75QfarkT3hvClJg+ijGGtp2HHx0c9bnJOlF8 X-Google-Smtp-Source: ABdhPJxa8w4lAoTlapsgJybo0aJqfxo1O+mA5c0wYgATVmj8zS2sxq8Z9+49B8lTJGeLbPgcVGow6A== X-Received: by 2002:a63:1c7:0:b0:37c:4e86:25e9 with SMTP id 190-20020a6301c7000000b0037c4e8625e9mr16584792pgb.550.1646793362303; Tue, 08 Mar 2022 18:36:02 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:2d45:59c2:b66a:384a]) by smtp.gmail.com with ESMTPSA id d4-20020a17090a8d8400b001bc386dc44bsm4219488pjo.23.2022.03.08.18.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 18:36:01 -0800 (PST) Date: Wed, 9 Mar 2022 11:35:57 +0900 From: Takahiro Akashi To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Francois Ozog , Mark Kettenis Subject: Re: [RFC PATCH v3 1/2] efi_loader: introduce "bootefi bootindex" command Message-ID: <20220309023557.GB136899@laputa> Mail-Followup-To: Takahiro Akashi , Masahisa Kojima , u-boot@lists.denx.de, Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Francois Ozog , Mark Kettenis References: <20220308140745.26180-1-masahisa.kojima@linaro.org> <20220308140745.26180-2-masahisa.kojima@linaro.org> <20220308141728.GC228584@laputa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Wed, Mar 09, 2022 at 09:47:25AM +0900, Masahisa Kojima wrote: > On Tue, 8 Mar 2022 at 23:17, Takahiro Akashi wrote: > > > > On Tue, Mar 08, 2022 at 11:07:44PM +0900, Masahisa Kojima wrote: > > > This commit introduces the new command "bootefi bootindex". > > > With this command, user can select which "Boot####" option > > > to load and execute. > > > > You can do the same thing with: > > $ efidebug boot next 1 (for BOOT0001) > > $ bootefi bootmgr > > Thank you for the information, it is good to know. > My only concern is that user needs to enable "efidebug" command > for this case, since efidebug implies that it is for debug purpose. Yeah, that is the point where I and ex-maintainer have never agreed. So we have no standard UI for UEFI subsystem on U-Boot until now. Just FYI, we can do the same thing in yet another way :) => env set -e -nv -bs -rt BootNext =0x0001 Similarly, BootOrder as well. -Takahiro Akashi > Thanks, > Masahisa Kojima > > > > > -Takahiro Akashi > > > > > > > Signed-off-by: Masahisa Kojima > > > --- > > > Changes in v3: > > > - newly created > > > > > > cmd/bootefi.c | 42 ++++++++++++++++++++++++++++++++++++ > > > include/efi_loader.h | 1 + > > > lib/efi_loader/efi_bootmgr.c | 7 +++--- > > > 3 files changed, 46 insertions(+), 4 deletions(-) > > > > > > diff --git a/cmd/bootefi.c b/cmd/bootefi.c > > > index 46eebd5ee2..df86438fec 100644 > > > --- a/cmd/bootefi.c > > > +++ b/cmd/bootefi.c > > > @@ -416,6 +416,30 @@ static int do_efibootmgr(void) > > > return CMD_RET_SUCCESS; > > > } > > > > > > +/** > > > + * do_efibootindex() - load and execute the specified Boot#### option > > > + * > > > + * Return: status code > > > + */ > > > +static int do_efibootindex(u16 boot_index) > > > +{ > > > + efi_handle_t handle; > > > + efi_status_t ret; > > > + void *load_options; > > > + > > > + ret = efi_try_load_entry(boot_index, &handle, &load_options); > > > + if (ret != EFI_SUCCESS) { > > > + log_notice("EFI boot manager: failed to load Boot%04X\n", boot_index); > > > + return CMD_RET_FAILURE; > > > + } > > > + > > > + ret = do_bootefi_exec(handle, load_options); > > > + > > > + if (ret != EFI_SUCCESS) > > > + return CMD_RET_FAILURE; > > > + > > > + return CMD_RET_SUCCESS; > > > +} > > > /** > > > * do_bootefi_image() - execute EFI binary > > > * > > > @@ -654,6 +678,22 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, > > > return CMD_RET_FAILURE; > > > } > > > > > > + if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) { > > > + if (!strcmp(argv[1], "bootindex")) { > > > + char *endp; > > > + int boot_index; > > > + > > > + if (argc < 3) > > > + return CMD_RET_USAGE; > > > + > > > + boot_index = (int)hextoul(argv[2], &endp); > > > + if (*endp != '\0' || boot_index > 0xffff) > > > + return CMD_RET_USAGE; > > > + > > > + return do_efibootindex((u16)boot_index); > > > + } > > > + } > > > + > > > if (argc > 2) { > > > uintptr_t fdt_addr; > > > > > > @@ -702,6 +742,8 @@ static char bootefi_help_text[] = > > > "\n" > > > " If specified, the device tree located at gets\n" > > > " exposed as EFI configuration table.\n" > > > + "bootefi bootindex \n" > > > + " - load and boot EFI payload based on the specified BootXXXX variable.\n" > > > #endif > > > ; > > > #endif > > > diff --git a/include/efi_loader.h b/include/efi_loader.h > > > index 80a5f1ec01..e5972f5fee 100644 > > > --- a/include/efi_loader.h > > > +++ b/include/efi_loader.h > > > @@ -861,6 +861,7 @@ efi_status_t efi_set_load_options(efi_handle_t handle, > > > efi_uintn_t load_options_size, > > > void *load_options); > > > efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options); > > > +efi_status_t efi_try_load_entry(u16 n, efi_handle_t *handle, void **load_options); > > > > > > /** > > > * struct efi_image_regions - A list of memory regions > > > diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c > > > index 8c04ecbdc8..a3060b5c62 100644 > > > --- a/lib/efi_loader/efi_bootmgr.c > > > +++ b/lib/efi_loader/efi_bootmgr.c > > > @@ -42,8 +42,7 @@ static const struct efi_runtime_services *rs; > > > * @load_options: load options set on the loaded image protocol > > > * Return: status code > > > */ > > > -static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, > > > - void **load_options) > > > +efi_status_t efi_try_load_entry(u16 n, efi_handle_t *handle, void **load_options) > > > { > > > struct efi_load_option lo; > > > u16 varname[] = u"Boot0000"; > > > @@ -165,7 +164,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) > > > /* load BootNext */ > > > if (ret == EFI_SUCCESS) { > > > if (size == sizeof(u16)) { > > > - ret = try_load_entry(bootnext, handle, > > > + ret = efi_try_load_entry(bootnext, handle, > > > load_options); > > > if (ret == EFI_SUCCESS) > > > return ret; > > > @@ -189,7 +188,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) > > > for (i = 0; i < num; i++) { > > > log_debug("%s trying to load Boot%04X\n", __func__, > > > bootorder[i]); > > > - ret = try_load_entry(bootorder[i], handle, load_options); > > > + ret = efi_try_load_entry(bootorder[i], handle, load_options); > > > if (ret == EFI_SUCCESS) > > > break; > > > } > > > -- > > > 2.17.1 > > >