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 B29ECC43334 for ; Tue, 12 Jul 2022 07:04:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 54C798408E; Tue, 12 Jul 2022 09:04:40 +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="CpH513qd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 856B08409A; Tue, 12 Jul 2022 09:04:38 +0200 (CEST) Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) (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 88B3784072 for ; Tue, 12 Jul 2022 09:04:34 +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-yb1-xb2a.google.com with SMTP id p129so12473763yba.7 for ; Tue, 12 Jul 2022 00:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MMr1I6U8cOtSwm34OudQ/jnlW7gJPT8APpDxqT5n4xs=; b=CpH513qdB1GXqMPHHZ7N+QbVDCv4lzK+wrD9iCr1IQVNfAFFuFOjQQmhsp8eFf7wJW HyxEOX+fU6J8emsYokLg3oW5QTtrqwANpYPBruJMtcngH9OLZ/ux4oeR+PFarkqtH9Au 2sN+CzxaQyVjkWYyRR5kyC8nBu2hmtHl3v4L/+hwLpGu5agg50cZ5O8KG0DcxNjBWQ4Z skTB7hACaqSQ4F/j5T7RyzoM9rmgd2a1lD3LC2tmsm+o5eAHT4MHbJbND+Se2HMA6+Tf U9O7jd3IyvJNVqgRrT/j5G3WXwffLhriHmZC2zkX28+sj+6/6syXMHaPWdydoaOfVURJ XvOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MMr1I6U8cOtSwm34OudQ/jnlW7gJPT8APpDxqT5n4xs=; b=zVZWvY20s/ugyhG1fj8tHv5X+VCRsmwEfZ1pVTfr06ITmXH/VI1v1XPh0/IlWDkO8W 95n4FVPIufHkp7nlNb3Yi76gfbkZrfJAb8CtHGMhSKM3cm4Wo+Z+tgyPc2OSVFpyGEmu IqfzuSnUWbEjePAomr/8hkSz+n33lAyHi33+9VcJaHmNUQ2sd5jZIInI1OyWHzSAC1ax eEgr83wn84MG6QZ4gmeueyXyLKs/zMdhsMYsMuB4j8e3jSBoNpzrGuhg0J6o6isjNSQY EZa/eHi5sWzHcUctaLze0Pr1SIktZtJjT8zGOJYi0detuVcZ5LDylus3m4Wu2U0sGl6q zvpQ== X-Gm-Message-State: AJIora97IxVG9YJoegfDmILPsLprwa2HwVQvpMVezXRO+XTvGCLgXPD8 x3HCto86xVu+bLHShg05SEMTnDWb9KJjYeR8aOtpHg== X-Google-Smtp-Source: AGRyM1s4ilp5HD/GiF7tNZLhWqgLsmWsoNvvRWCbVOgvuM4F6Hobd27Y0DsAmch8aZVNEoM3JkXY+NYTSbfP3AMBpBw= X-Received: by 2002:a25:dd83:0:b0:66c:8d8d:4f5f with SMTP id u125-20020a25dd83000000b0066c8d8d4f5fmr21467965ybg.79.1657609473324; Tue, 12 Jul 2022 00:04:33 -0700 (PDT) MIME-Version: 1.0 References: <20220619045607.1669-1-masahisa.kojima@linaro.org> <20220619045607.1669-4-masahisa.kojima@linaro.org> <12c2a961-deb5-2403-c459-11a0a3add853@gmx.de> In-Reply-To: <12c2a961-deb5-2403-c459-11a0a3add853@gmx.de> From: Masahisa Kojima Date: Tue, 12 Jul 2022 16:04:22 +0900 Message-ID: Subject: Re: [PATCH v8 3/9] eficonfig: add "Edit Boot Option" menu entry To: Heinrich Schuchardt Cc: Ilias Apalodimas , Simon Glass , Takahiro Akashi , Mark Kettenis , u-boot@lists.denx.de Content-Type: text/plain; charset="UTF-8" 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.6 at phobos.denx.de X-Virus-Status: Clean On Sun, 10 Jul 2022 at 18:08, Heinrich Schuchardt wrote: > > On 6/19/22 06:56, Masahisa Kojima wrote: > > This commit adds the menu entry to edit the existing > > BOOT#### variable contents. > > User selects the item from the boot option list, then > > user can edit the description, file path and optional_data. > > > > Note that automatically generated boot option entry by bootmenu > > to suppport the removable media device is filtered out and user > > can not edit the automatically generated entry. > > > > Signed-off-by: Masahisa Kojima > > --- > > Changes in v8: > > - fix menu header string > > - fix function and structure prefix to "eficonfig" > > > > Newly created in v7 > > > > cmd/eficonfig.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 172 insertions(+) > > > > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c > > index 20747db115..0a58b83ea3 100644 > > --- a/cmd/eficonfig.c > > +++ b/cmd/eficonfig.c > > @@ -1197,6 +1197,177 @@ out: > > return ret; > > } > > > > Please, provide function descriptions. OK. Thanks, Masahisa Kojima > > Best regards > > Heinrich > > > +static efi_status_t eficonfig_process_boot_selected(void *data) > > +{ > > + struct eficonfig_boot_selection_data *info = data; > > + > > + if (info) > > + *info->selected = info->bootorder_index; > > + > > + return EFI_SUCCESS; > > +} > > + > > +static efi_status_t eficonfig_show_boot_selection(u16 *bootorder, efi_uintn_t count, > > + int *selected) > > +{ > > + u32 i; > > + efi_status_t ret; > > + efi_uintn_t size, actual_count = 0; > > + void *load_option; > > + struct efi_load_option lo; > > + u16 varname[] = u"Boot####"; > > + struct eficonfig_item *menu_item, *iter; > > + > > + menu_item = calloc(count + 1, sizeof(struct eficonfig_item)); > > + if (!menu_item) { > > + ret = EFI_OUT_OF_RESOURCES; > > + goto out; > > + } > > + > > + iter = menu_item; > > + for (i = 0; i < count; i++) { > > + efi_create_indexed_name(varname, sizeof(varname), > > + "Boot", bootorder[i]); > > + load_option = efi_get_var(varname, &efi_global_variable_guid, &size); > > + if (!load_option) > > + continue; > > + > > + ret = efi_deserialize_load_option(&lo, load_option, &size); > > + if (ret != EFI_SUCCESS) { > > + log_warning("Invalid load option for %ls\n", varname); > > + free(load_option); > > + continue; > > + } > > + > > + if (size >= sizeof(efi_guid_t) && > > + !guidcmp(lo.optional_data, &efi_guid_bootmenu_auto_generated)) { > > + /* > > + * auto generated entry has GUID in optional_data, > > + * skip auto generated entry because it will be generated > > + * again even if it is edited or deleted. > > + */ > > + free(load_option); > > + continue; > > + } > > + > > + if (lo.attributes & LOAD_OPTION_ACTIVE) { > > + char *buf, *p; > > + struct eficonfig_boot_selection_data *info; > > + > > + info = calloc(1, sizeof(struct eficonfig_boot_selection_data)); > > + if (!info) { > > + free(load_option); > > + ret = EFI_OUT_OF_RESOURCES; > > + goto out; > > + } > > + > > + buf = calloc(1, utf16_utf8_strlen(lo.label) + 1); > > + if (!buf) { > > + free(load_option); > > + free(info); > > + ret = EFI_OUT_OF_RESOURCES; > > + goto out; > > + } > > + p = buf; > > + utf16_utf8_strcpy(&p, lo.label); > > + info->bootorder_index = i; > > + info->selected = selected; > > + iter->title = buf; > > + iter->func = eficonfig_process_boot_selected; > > + iter->data = info; > > + iter++; > > + actual_count++; > > + } > > + free(load_option); > > + } > > + > > + /* add "Quit" entry */ > > + iter->title = strdup("Quit"); > > + iter->func = eficonfig_process_quit; > > + iter->data = NULL; > > + actual_count += 1; > > + > > + ret = eficonfig_process_common(menu_item, actual_count, " ** Select Boot Option **"); > > + > > +out: > > + iter = menu_item; > > + for (i = 0; i < actual_count; i++, iter++) { > > + free(iter->title); > > + free(iter->data); > > + } > > + > > + free(menu_item); > > + > > + return ret; > > +} > > + > > +static efi_status_t eficonfig_process_edit_boot_option(void *data) > > +{ > > + u16 *bootorder; > > + efi_status_t ret; > > + efi_uintn_t num, size; > > + struct eficonfig_boot_option *bo = NULL; > > + > > + bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid, &size); > > + if (!bootorder) { > > + eficonfig_print_msg("BootOrder is not defined!"); > > + ret = EFI_NOT_FOUND; > > + return ret; > > + } > > + > > + num = size / sizeof(u16); > > + while (1) { > > + int selected; > > + void *load_option; > > + struct efi_load_option lo; > > + u16 varname[] = u"Boot####"; > > + > > + ret = eficonfig_show_boot_selection(bootorder, num, &selected); > > + if (ret != EFI_SUCCESS) > > + break; > > + > > + bo = calloc(1, sizeof(struct eficonfig_boot_option)); > > + if (!bo) { > > + ret = EFI_OUT_OF_RESOURCES; > > + goto out; > > + } > > + > > + bo->boot_index = selected; > > + efi_create_indexed_name(varname, sizeof(varname), > > + "Boot", bootorder[selected]); > > + load_option = efi_get_var(varname, &efi_global_variable_guid, &size); > > + if (!load_option) { > > + free(bo); > > + ret = EFI_NOT_FOUND; > > + goto out; > > + } > > + > > + ret = efi_deserialize_load_option(&lo, load_option, &size); > > + if (ret != EFI_SUCCESS) { > > + free(bo); > > + free(load_option); > > + goto out; > > + } > > + > > + ret = eficonfig_edit_boot_option(varname, bo, lo.label, lo.optional_data, > > + size, lo.file_path, > > + " ** Edit Boot Option ** "); > > + > > + free(load_option); > > + free(bo); > > + if (ret != EFI_SUCCESS && ret != EFI_ABORTED) > > + break; > > + } > > + > > +out: > > + free(bootorder); > > + > > + /* to stay the parent menu */ > > + ret = (ret == EFI_ABORTED) ? EFI_NOT_READY : ret; > > + > > + return ret; > > +} > > + > > static efi_status_t eficonfig_init(void) > > { > > efi_status_t ret; > > @@ -1230,6 +1401,7 @@ static efi_status_t eficonfig_init(void) > > > > static const struct eficonfig_item maintenance_menu_items[] = { > > {"Add Boot Option", eficonfig_process_add_boot_option}, > > + {"Edit Boot Option", eficonfig_process_edit_boot_option}, > > {"Quit", eficonfig_process_quit}, > > }; > > >