aboutsummaryrefslogtreecommitdiff
path: root/cmd/eficonfig.c
AgeCommit message (Collapse)Author
2023-11-20cmd: eficonfig: create shortened boot optionsHeinrich Schuchardt
The boot options created by eficonfig should use shortened device-paths to avoid problems if drives are enumerated in a different sequence. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15Fix incorrect return code of boot option updateRaymond Mao
Correct the return code for out-of-memory and no boot option found Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15Move bootorder and bootoption apis to libRaymond Mao
Rename and move bootorder and bootoption apis from cmd to lib for re-use between eficonfig and bootmgr Fix 'unexpected indentation' when 'make htmldocs' after functions are moved Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-02-10Merge tag 'efi-2023-04-rc2' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2023-04-rc2 Documentation: * Provide page with links to talks on U-Boot UEFI: * Enable CTRL+S to save the boot order in eficonfig command * Run attribute check for QueryVariableInfo() only for the file store * Bug fixes Others: * Improve output formatting of the coninfo command # -----END PGP SIGNATURE----- # gpg: Signature made Fri 10 Feb 2023 12:15:45 PM EST # gpg: using RSA key 6DC4F9C71F29A6FA06B76D33C481DBBC2C051AC4 # gpg: Good signature from "Heinrich Schuchardt <xypron.glpk@gmx.de>" [unknown] # gpg: aka "[jpeg image of size 1389]" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 6DC4 F9C7 1F29 A6FA 06B7 6D33 C481 DBBC 2C05 1AC4
2023-02-10Correct SPL use of EFI_SECURE_BOOTSimon Glass
This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_SECURE_BOOT defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10Correct SPL use of EFI_MM_COMM_TEESimon Glass
This converts 1 usage of this option to the non-SPL form, since there is no SPL_EFI_MM_COMM_TEE defined in Kconfig Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-10eficonfig: CTRL+S to save the boot orderMasahisa Kojima
The change boot order menu in eficonfig can have at most INT_MAX lines and it is troublesome to scroll down to the "Save" entry. This commit assigns CTRL+S to save the boot order. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Acked-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10menu: remove CTRL+C to quitMasahisa Kojima
On the sandbox called without "--terminal raw" CTRL+C leaves U-Boot, "ESC/CTRL+C to quit" is misleading. Let's remove CTRL+C to quit key handling from bootmenu and eficonfig menu. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-27eficonfig: add vertical scroll supportMasahisa Kojima
The current eficonfig menu does not support vertical scroll, so it can not display the menu entries greater than the console row size. This commit add the vertial scroll support. The console size is retrieved by SIMPLE_TEXT_OUTPUT_PROTOCOL.QueryMode() service, then calculates the row size for menu entry by subtracting menu header and description row size from the console row size. "start" and "end" are added in the efimenu structure. "start" keeps the menu entry index at the top, "end" keeps the bottom menu entry index. item_data_print() menu function only draws the menu entry between "start" and "end". This commit also fixes the issue that "Save" and "Quit" entries can be moved by BKEY_PLUS in change boot order menu. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-27eficonfig: refactor change boot order implementationMasahisa Kojima
This commit removes the change boot order specific menu implementation. The change boot order implementation calls eficonfig_process_common() same as other menus. The change boot order menu requires own item_data_print and item_choice implementation, but display_statusline function can be a same function as other menus. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-27eficonfig: refactor eficonfig_process_common functionMasahisa Kojima
Current change boot order implementation does not call eficonfig_process_common() and call own menu functions for display_statusline, item_data_print and item_choice. Change boot order functionality should call eficonfig_process_common() to improve maintenanceability. This commit is a preparation to remove the change boot order specific implementation. The menu functions (display_statusline, item_data_print and item_choice) are added as argument of eficonfig_process_common(). The menu description string displayed at the bottom of the menu is also added as argument. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-16menu: Make use of CLI character processingSimon Glass
Avoid duplicating some of the escape-sequence processing here and use the CLI function instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-16menu: Update bootmenu_loop() to return the codeSimon Glass
Use the return value to save having to pass around a pointer. This also resolves any ambiguity about what *key contains when the function is called. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-16menu: Rename KEY_... to BKEY_...Simon Glass
This enum values conflict with linux/input.h so rename them. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-12-20eficonfig: avoid SetVariable between GetNextVariableName callsMasahisa Kojima
The current code calls efi_set_variable_int() to delete the invalid boot option between calls to efi_get_next_variable_name_int(), it may produce unpredictable results. This commit moves removal of the invalid boot option outside of the efi_get_next_variable_name_int() calls. EFI_NOT_FOUND returned from efi_get_next_variable_name_int() indicates we retrieved all EFI variables, it should be treated as EFI_SUCEESS. To address the checkpatch warning of too many leading tabs, combine two if statement into one. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-20eficonfig: carve out efi_get_next_variable_name_int callsMasahisa Kojima
To retrieve the EFI variable name by efi_get_next_variable_name_int(), the sequence of alloc -> efi_get_next_variable_name_int -> realloc -> efi_get_next_variable_name_int is required. In current code, this sequence repeatedly appears in the several functions. It should be curved out a common function. This commit also fixes the missing free() of var_name16 in eficonfig_delete_invalid_boot_option(). Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-02eficonfig: use efi_get_next_variable_name_int()Masahisa Kojima
eficonfig command reads all possible UEFI load options from 0x0000 to 0xFFFF to construct the menu. This takes too much time in some environment. This commit uses efi_get_next_variable_name_int() to read all existing UEFI load options to significantlly reduce the count of efi_get_var() call. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-12-02eficonfig: use u16_strsize() to get u16 string buffer sizeMasahisa Kojima
Use u16_strsize() to simplify the u16 string buffer size calculation. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-02eficonfig: fix going one directory up issueMasahisa Kojima
The directory name in eficonfig menu entry contains the '\' separator. strcmp() argument ".." is wrong and one directory up handling does not work correctly. strcmp() argument must include '\' separator. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-11-22eficonfig: add UEFI Secure Boot Key enrollment interfaceMasahisa Kojima
This commit adds the menu-driven UEFI Secure Boot Key enrollment interface. User can enroll PK, KEK, db and dbx by selecting file. Only the signed EFI Signature List(s) with an authenticated header, typically '.auth' file, is accepted. To clear the PK, KEK, db and dbx, user needs to enroll the null key signed by PK or KEK. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-11-22eficonfig: use protocol interface for file selectionMasahisa Kojima
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is not always provided by U-Boot. Use protocol interface functions instead of U-Boot internal functions. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-11-22eficonfig: expose eficonfig_create_device_path()Masahisa Kojima
Following commits are adding support for UEFI variable management via the eficonfig menu. Those functions needs to use eficonfig_create_device_path() to construct the full device path from device path of the volume and file path, so move it out of their static declarations. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-11-22eficonfig: refactor change boot order implementationMasahisa Kojima
All the eficonfig menus other than "Change Boot Order" use 'eficonfig_entry' structure for each menu entry. This commit refactors change boot order implementation to use 'eficonfig_entry' structure same as other menus to have consistent menu handling. This commit also simplifies the data->active handling when KEY_SPACE is pressed, and sizeof() parameter. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-11-22eficonfig: expose append entry functionMasahisa Kojima
Following commits are adding support for UEFI variable management via the eficonfig menu. Those functions needs to use append_entry() and append_quit_entry() to construct the menu, so move them out of their static declarations. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-11-22eficonfig: refactor file selection handlingMasahisa Kojima
eficonfig_select_file_handler() is commonly used to select the file. eficonfig_display_select_file_option() adds an additional menu to clear the selected file. eficonfig_display_select_file_option() is not always necessary for the file selection process, so it must be outside of eficonfig_select_file_handler(). This commit also renames the following functions to avoid confusion. eficonfig_select_file_handler() -> eficonfig_process_select_file() eficonfig_select_file() -> eficonfig_show_file_selection() eficonfig_display_select_file_option() -> eficonfig_process_show_file_option() Finally, test_eficonfig.py need to be updated to get aligned with the above modification. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-11-16eficonfig: fix missing variable initializationMasahisa Kojima
The 'ret' variable must be initialized before use in eficonfig_delete_invalid_boot_option(). Fixes: c416f1c0bc ("bootmenu: add removable media entries") Addresses-Coverity: 376207 ("Uninitialized variables") Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-11-16cmd: remove superfluous if in eficonfig_edit_boot_optionHeinrich Schuchardt
Goto for an immediately succeeding label is superfluous. Fixes: 87d791423ac6 ("eficonfig: menu-driven addition of UEFI boot option") Addresses-Coverity: 376202 ("Identical code for different branches") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-09-14eficonfig: add "Change Boot Order" menu entryMasahisa Kojima
This commit adds the menu entry to update UEFI BootOrder variable. User moves the entry with UP/DOWN key, changes the order with PLUS/MINUS key, press SPACE to activate or deactivate the entry, then finalizes the order by ENTER key. If the entry is activated, the boot index is added into the BootOrder variable in the order of the list. The U-Boot menu framework is well designed for static menu, this commit implements the own menu display and key handling for dynamically change the order of menu entry. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-09-14eficonfig: scan media device in eficonfig startupMasahisa Kojima
In eficonfig startup, scan media devices and update the UEFI boot option. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-09-14bootmenu: add removable media entriesMasahisa Kojima
UEFI specification requires booting from removal media using a architecture-specific default image name such as BOOTAA64.EFI. This commit adds the removable media entries into bootmenu, so that user can select the removable media and boot with default image. The bootmenu automatically enumerates the possible bootable media devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, add it as new UEFI boot option(BOOT####) and update BootOrder variable. This automatically generated UEFI boot option has the dedicated guid in the optional_data to distinguish it from the UEFI boot option user adds manually. This optional_data is removed when the efi bootmgr loads the selected UEFI boot option. This commit also provides the BOOT#### variable maintenance feature. Depending on the system hardware setup, some devices may not exist at a later system boot, so bootmenu checks the available device in each bootmenu invocation and automatically removes the BOOT#### variable corrensponding to the non-existent media device. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-09-14eficonfig: add "Delete Boot Option" menu entryMasahisa Kojima
This commit adds the menu entry to delete the UEFI boot option. User moves the entry with UP/DOWN key, changes, then presses ENTER key to delete the selected boot option. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-09-14eficonfig: add "Edit Boot Option" menu entryMasahisa Kojima
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 support the removable media device is filtered out and user can not edit the automatically generated entry. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2022-09-14eficonfig: menu-driven addition of UEFI boot optionMasahisa Kojima
This commit add the "eficonfig" command. The "eficonfig" command implements the menu-driven UEFI boot option maintenance feature. This commit implements the addition of new boot option. User can select the block device volume having efi_simple_file_system_protocol and select the file corresponding to the Boot#### variable. User can also enter the description and optional_data of the BOOT#### variable in utf8. This commit adds "include/efi_config.h", it contains the common definition to be used from other menus such as UEFI Secure Boot key management. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>