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 B7244C433EF for ; Sun, 10 Jul 2022 09:08:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 88404844B4; Sun, 10 Jul 2022 11:08:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="EJfw4Y/W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 971C5844C0; Sun, 10 Jul 2022 11:08:22 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E444C843A2 for ; Sun, 10 Jul 2022 11:08:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657444099; bh=1rl8OaTSlwiBHJTaHTT2/lv9eivX4r1SoHhoL/59aGM=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=EJfw4Y/W6eHXs22PB4QuY3RiWTMBrr3myKonRP8rwUPRYbFmInO5IA+ktDkmLNSzg eatnnzK4WJOJaP3gBxK4zBDPAohsQaNgqRvDYCq44SWA6/yukiElyR/KX82f+o6NSy PPpool6c+JhEZ02IUeE/u4K3y1/zsSd7SuBedcqg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([62.143.94.109]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mf078-1nclo03fP0-00gUkJ; Sun, 10 Jul 2022 11:08:18 +0200 Message-ID: <12c2a961-deb5-2403-c459-11a0a3add853@gmx.de> Date: Sun, 10 Jul 2022 11:08:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.0.1 Subject: Re: [PATCH v8 3/9] eficonfig: add "Edit Boot Option" menu entry Content-Language: en-US To: Masahisa Kojima Cc: Ilias Apalodimas , Simon Glass , Takahiro Akashi , Francois Ozog , Mark Kettenis , u-boot@lists.denx.de References: <20220619045607.1669-1-masahisa.kojima@linaro.org> <20220619045607.1669-4-masahisa.kojima@linaro.org> From: Heinrich Schuchardt In-Reply-To: <20220619045607.1669-4-masahisa.kojima@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:2uyuF9g/QrtMFzN7JAw+MZD72beB4HOiQ0RUpn6zgLNr+vVFumH 3xq6Pw4sN3SpOG0vi33dBkUWtBgOePwGy3e6oC9QTxZHce0A5Hnjm/Vzi9HkWIWVClUr2CE f07NWVqf5NOYTPF3N/Hbn+m6Kp5FzPPPUfhtcekguXlH6ng7JbeXlHEHQ/8wcCbwSw1Le9x 05dORhDPPvbD/kFtDPzWg== X-UI-Out-Filterresults: notjunk:1;V03:K0:kDyGo31qEWc=:zkf/3kgk/rB/yUhixNHftD sX5QhX3laoRvHNLtvUmCR/iD8u2dExBUW6XeNrb0bENtNsdBtMjXPV3AErAAQMJssOrhvYV1n b+sQixmpqAt2Vcvu1xgyJCkO8RD/tQIPNV96vRsPXEpKGR8csSZ7m3EUDpalMoNxj8TKk1Dsy PLAgJvkB8d+PbD70yHyjlh1qjm1lekyOON5thkV0bKhe0TDNaujk0MCkqtYLSIU12yNQY9shz yB9TjSzrp6GxEgo4XNzkwY93X96+p+xs6RDLEJzbQmo5skLkN4uMcpbAzPzcVXlEWse/cwtSf Vy4UxPIivYuDGDtc1LaUmMF3w4LNGXpDkU6+1yBuHb9WohKZ39VNYGC9iDuwF/ptxdusGyMPS cfAniPa7+ra0v+XffrYRyD3gHwbkIlYhXALtY/Oc8XPVr+6xB3fT4xgZGmNRM7d8dXg9vmrMK enAozOlQlKt6xus4zZsuUmNenkt8WJDTuR2dRA2AgmMUiQKQ8LPAJidWJJkS/nXX6ENp5Tx+8 xogwXfrUk1pWrlVTuCswTWRjZXpmaG2WzdFpquhcE9hVDt5Gk6CRN1OpAugSukm/tDMhOM2aK vNXrc0l7sMqMG4A8K8OqniS5lT2TymOP8VfnecO/6vwoG9JEvvecivtvihqMW5gCXb0n5qpi4 LWzxx2uNtaGVEzVLX6O4tH8vDOgfimchIpm+zD2ZTGF1OAhmKys0Ji20uOGRSQgathDVWimUT S+Uk766+BnFxpSYFCSjTJdC7QctVnDZav4sJSArxHAL3HaOvk9xivYZgP39OEnn1cDKRdHFN+ S3lmZanKmshSO0BlKLFxsTTckC36cjMnH2Jvj7ztQxWXdx9LivW0EOrVZC4Lh2/Xhc36zvS9I cDykEevrzzACBgwVAy94ebD9XgaxnSn7nkB5yqXcmb5M1NZ1pwPYK3ux4nfih8SMu93g599Qg Rg1heJ33awftso39fJExmxoeTfG1ldb1A9tP8A8DLkFjQDX9RNVFeXkz0NH6Mk2vC+BO4gqOh iv3FiNQSlYvGaleCWoszcDvV0yCRzZoXYdU/0hkOqdlv3dCEBQIjvfcCSfLBVhMoH+JSAS12d rGJvyPK0SdInghtBuJPIpKPsVwbpAahEoi5dUuID96njlUVvznolM5Wlw== 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 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. Best regards Heinrich > +static efi_status_t eficonfig_process_boot_selected(void *data) > +{ > + struct eficonfig_boot_selection_data *info =3D data; > + > + if (info) > + *info->selected =3D info->bootorder_index; > + > + return EFI_SUCCESS; > +} > + > +static efi_status_t eficonfig_show_boot_selection(u16 *bootorder, efi_u= intn_t count, > + int *selected) > +{ > + u32 i; > + efi_status_t ret; > + efi_uintn_t size, actual_count =3D 0; > + void *load_option; > + struct efi_load_option lo; > + u16 varname[] =3D u"Boot####"; > + struct eficonfig_item *menu_item, *iter; > + > + menu_item =3D calloc(count + 1, sizeof(struct eficonfig_item)); > + if (!menu_item) { > + ret =3D EFI_OUT_OF_RESOURCES; > + goto out; > + } > + > + iter =3D menu_item; > + for (i =3D 0; i < count; i++) { > + efi_create_indexed_name(varname, sizeof(varname), > + "Boot", bootorder[i]); > + load_option =3D efi_get_var(varname, &efi_global_variable_guid, &size= ); > + if (!load_option) > + continue; > + > + ret =3D efi_deserialize_load_option(&lo, load_option, &size); > + if (ret !=3D EFI_SUCCESS) { > + log_warning("Invalid load option for %ls\n", varname); > + free(load_option); > + continue; > + } > + > + if (size >=3D 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 =3D calloc(1, sizeof(struct eficonfig_boot_selection_data)); > + if (!info) { > + free(load_option); > + ret =3D EFI_OUT_OF_RESOURCES; > + goto out; > + } > + > + buf =3D calloc(1, utf16_utf8_strlen(lo.label) + 1); > + if (!buf) { > + free(load_option); > + free(info); > + ret =3D EFI_OUT_OF_RESOURCES; > + goto out; > + } > + p =3D buf; > + utf16_utf8_strcpy(&p, lo.label); > + info->bootorder_index =3D i; > + info->selected =3D selected; > + iter->title =3D buf; > + iter->func =3D eficonfig_process_boot_selected; > + iter->data =3D info; > + iter++; > + actual_count++; > + } > + free(load_option); > + } > + > + /* add "Quit" entry */ > + iter->title =3D strdup("Quit"); > + iter->func =3D eficonfig_process_quit; > + iter->data =3D NULL; > + actual_count +=3D 1; > + > + ret =3D eficonfig_process_common(menu_item, actual_count, " ** Select= Boot Option **"); > + > +out: > + iter =3D menu_item; > + for (i =3D 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 =3D NULL; > + > + bootorder =3D efi_get_var(u"BootOrder", &efi_global_variable_guid, &si= ze); > + if (!bootorder) { > + eficonfig_print_msg("BootOrder is not defined!"); > + ret =3D EFI_NOT_FOUND; > + return ret; > + } > + > + num =3D size / sizeof(u16); > + while (1) { > + int selected; > + void *load_option; > + struct efi_load_option lo; > + u16 varname[] =3D u"Boot####"; > + > + ret =3D eficonfig_show_boot_selection(bootorder, num, &selected); > + if (ret !=3D EFI_SUCCESS) > + break; > + > + bo =3D calloc(1, sizeof(struct eficonfig_boot_option)); > + if (!bo) { > + ret =3D EFI_OUT_OF_RESOURCES; > + goto out; > + } > + > + bo->boot_index =3D selected; > + efi_create_indexed_name(varname, sizeof(varname), > + "Boot", bootorder[selected]); > + load_option =3D efi_get_var(varname, &efi_global_variable_guid, &size= ); > + if (!load_option) { > + free(bo); > + ret =3D EFI_NOT_FOUND; > + goto out; > + } > + > + ret =3D efi_deserialize_load_option(&lo, load_option, &size); > + if (ret !=3D EFI_SUCCESS) { > + free(bo); > + free(load_option); > + goto out; > + } > + > + ret =3D 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 !=3D EFI_SUCCESS && ret !=3D EFI_ABORTED) > + break; > + } > + > +out: > + free(bootorder); > + > + /* to stay the parent menu */ > + ret =3D (ret =3D=3D 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[] =3D { > {"Add Boot Option", eficonfig_process_add_boot_option}, > + {"Edit Boot Option", eficonfig_process_edit_boot_option}, > {"Quit", eficonfig_process_quit}, > }; >