summaryrefslogtreecommitdiff
path: root/common/menu.c
AgeCommit message (Collapse)Author
2026-03-03menu: Move shortcut-key handling to bootmenu_loop()Simon Glass
The bootmenu_conv_key() function is shared with expo subsystem for key input. Adding alphanumeric-to-BKEY_SHORTCUT conversion there causes expo to swallow typed characters instead of inserting them as text, since BKEY_SHORTCUT falls in the range that expo treats as a command key rather than passing through. Move the shortcut-key detection into bootmenu_loop() where it is only used in the bootmenu context. Fixes: 8c986521c3c9 ("cmd: bootmenu: permit to select bootmenu entry with a shortcut") Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2025-06-05cmd: bootmenu: permit to select bootmenu entry with a shortcutChristian Marangi
Permit to select a bootmenu entry with a key shortcut. This is especially useful in production or testing scenario to automate flashing procedure or testing procedure. The boot entry are changed to append the shortcut key to it. Example: 1. Run default boot command. 2. Boot system via TFTP. 3. Boot production system from NAND. 4. Boot recovery system from NAND. 5. Load production system via TFTP then write to NAND. 6. Load recovery system via TFTP then write to NAND. 7. Load BL31+U-Boot FIP via TFTP then write to NAND. 8. Load BL2 preloader via TFTP then write to NAND. 9. Reboot. a. Reset all settings to factory defaults. 0. Exit 0 is always reserved for Exit to console. On pressing the keyboard key 2, the bootmenu entry 2 is selected and executed. Up to 34 key shortcut (0 excluded as reserved) are supported from 1-9 and a-z. If a shortcut key not present in the bootmenu list is pressed, it is simply ignored and eventually the autoboot is interrupted. Capital A-Z are converted to lower a-z and the related option is selected. Suggested-by: Weijie Gao <[email protected]> Signed-off-by: Christian Marangi <[email protected]> Tested-by: Petr Štetiar <[email protected]>
2024-11-04menu: add support to check if menu needs to be reprintedWeijie Gao
This patch adds a new callback named need_reprint for menu. The need_reprint will be called before printing the menu. If the callback exists and returns FALSE, menu printing will be canceled. This is very useful if the menu was not changed. It can save time for serial-based menu to handle more input data. Signed-off-by: Weijie Gao <[email protected]> Reviewed-by: Daniel Golle <[email protected]> Tested-by: Daniel Golle <[email protected]>
2024-11-04menu: fix the logic checking whether ESC key is pressedWeijie Gao
It's observed that the bootmenu on a serial console sometimes incorrectly quitted with superfluous characters filled to command line input: > *** U-Boot Boot Menu *** > > 1. Startup system (Default) > 2. Upgrade firmware > 3. Upgrade ATF BL2 > 4. Upgrade ATF FIP > 5. Load image > 0. U-Boot console > > > Press UP/DOWN to move, ENTER to select, ESC to quit >MT7988> [B Analysis shows it was caused by the wrong logic of bootmenu_loop: At first the bootmenu_loop received the first ESC char correctly. However, during the second call to bootmenu_loop, there's no data in the UART Rx FIFO. Due to the low baudrate, the second char of the down array key sequence hasn't be fully received. But bootmenu_loop just did a mdelay(10), and then treated it as a single ESC key press event. It didn't even try tstc() again after the 10ms timeout. This patch fixes this issue by letting bootmenu_loop check tstc() twice. Tested-By: E Shattow <[email protected]> Signed-off-by: Weijie Gao <[email protected]> Reviewed-by: Daniel Golle <[email protected]> Tested-by: Daniel Golle <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2024-07-15common: Remove duplicate newlinesMarek Vasut
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <[email protected]>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-06common: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from all "commmon/" files and when needed add missing include files directly. Signed-off-by: Tom Rini <[email protected]>
2023-06-23menu: Re-enable the ANSI codesSimon Glass
The intent here was to allow ANSI codes to be disabled, since it was proving impoosible to test operation of the menu code when it kept moving the cursor. Unfortunately this ended up in the patch. Correct this by enabling ANSI again. Signed-off-by: Simon Glass <[email protected]> Reported-by: Pali Rohár <[email protected]> Reported-by: Mark Kettenis <[email protected]> Reported-by: Frank Wunderlich <[email protected]> Fixes: 32bab0eae51b ("menu: Make use of CLI character processing") Tested-by: Mark Kettenis <[email protected]> Reviewed-by: Mark Kettenis <[email protected]>
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 <[email protected]> Acked-by: Heinrich Schuchardt <[email protected]>
2023-01-16menu: Factor out menu-keypress decodingSimon Glass
Move this code into a separate function so that it can be used in the new VBE menu. Signed-off-by: Simon Glass <[email protected]>
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 <[email protected]>
2023-01-16menu: Use a switch statementSimon Glass
Convert the long line of if() statements to a switch() since this makes better use of the C language. Signed-off-by: Simon Glass <[email protected]>
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 <[email protected]>
2023-01-16menu: Update bootmenu_autoboot_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 <[email protected]>
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 <[email protected]>
2022-09-18cyclic: Use schedule() instead of WATCHDOG_RESET()Stefan Roese
Globally replace all occurances of WATCHDOG_RESET() with schedule(), which handles the HW_WATCHDOG functionality and the cyclic infrastructure. Signed-off-by: Stefan Roese <[email protected]> Reviewed-by: Simon Glass <[email protected]> Tested-by: Tom Rini <[email protected]> [am335x_evm, mx6cuboxi, rpi_3,dra7xx_evm, pine64_plus, am65x_evm, j721e_evm]
2022-09-14menu: add KEY_PLUS, KEY_MINUS and KEY_SPACE handlingMasahisa Kojima
This is preparation to support menu-driven UEFI BootOrder variable updated by KEY_PLUS, KEY_MINUS and KEY_SPACE. Signed-off-by: Masahisa Kojima <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>
2022-05-07bootmenu: factor out the user input handlingMasahisa Kojima
This commit moves the user input handling from cmd/bootmenu.c to common/menu.c to reuse it from other modules. Signed-off-by: Masahisa Kojima <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2022-05-03menu: menu_get_choice() return -ENOENT if menu item is emptyMasahisa Kojima
menu_get_choice() needs to handle the case that menu item is empty. In this case, menu_get_choice() returns -ENOENT. Signed-off-by: Masahisa Kojima <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Signed-off-by: Heinrich Schuchardt <[email protected]>
2022-05-03menu: always show the menu regardless of the number of entryMasahisa Kojima
To make user aware of the menu entry selection, menu always appears regardless of the number of entry. Signed-off-by: Masahisa Kojima <[email protected]> Adjust test/py/tests/test_bootmenu.py Reviewed-by: Heinrich Schuchardt <[email protected]>
2020-05-07menu: add support for client defined statusline functionThirupathaiah Annapureddy
Currently displaying status line is done in a weak function menu_display_statusline(). bootmenu.c overrides the weak default function. It calls menu_default_choice() and interprets the data as struct bootmenu_entry. pxe boot also uses common menu code for pxe menus. If there is a system that enables both bootmenu and pxe, menu_display_statusline() defined in bootmenu.c will be called and it will interpret struct pxe_label as struct bootmenu_entry. This leads to data aborts and pxe menu corruptions. This patch adds support for client defined statusline function to resolve the above bug. Signed-off-by: Thirupathaiah Annapureddy <[email protected]>
2019-07-24menu: don't bother going interactive with just one menu itemLeon Yu
If there is only one menu item available, prompting user to enter choice makes little sense and just causes unnecessary boot delay. This change makes menu_get_choice return the only one item when there is no other choices. Signed-off-by: Leon Yu <[email protected]> Cc: Tom Warren <[email protected]> Cc: Stephen Warren <[email protected]> Cc: Thierry Reding <[email protected]>
2018-06-05menu: fix timeout durationMasahiro Yamada
For distro-boot, the TIMEOUT directive in the boot script specifies how long to pause in units of 1/10 sec. [1] Commit 8594753ba0a7 ("menu: only timeout when menu is displayed") corrected this by simply dividing the timeout value by 10 in menu_interactive_choice(). I see two problems: - For example, "TIMEOUT 5" should wait for 0.5 sec, but the current implementation cannot handle the granularity of 1/10 sec. In fact, it never breaks because "m->timeout / 10" is zero, which means no timeout. - The menu API is used not only by cmd/pxe.c but also by common/autoboot.c . For the latter case, the unit of the timeout value is _second_ because its default is associated with CONFIG_BOOTDELAY. To fix the first issue, use DIV_ROUND_UP() so that the timeout value is rounded up to the closest integer. For the second issue, move the division to the boundary between cmd/pxe.c and common/menu.c . This is a more desirable place because the comment of struct pxe_menu says: * timeout - time in tenths of a second to wait for a user key-press before * booting the default label. Then, the comment of menu_create() says: * timeout - A delay in seconds to wait for user input. If 0, timeout is * disabled, and the default choice will be returned unless prompt is 1. [1] https://www.syslinux.org/wiki/index.php?title=SYSLINUX#TIMEOUT_timeout Signed-off-by: Masahiro Yamada <[email protected]>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <[email protected]>
2016-03-27Fix typo choosen in comments and printf logsAlexander Merkle
Minor change: chosen is written with one "o". No code change here, only comment & printf. Signed-off-by: Alexander Merkle <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2015-05-27menu: Return an error code if Ctrl-C is pressedTuomas Tynkkynen
Previously, if the menu activated by the 'sysboot' command gets interrupted by a Ctrl-C, the behaviour is as if the menu timeout was reached - i.e. boot the default menu entry. This patch fixes that so a Ctrl-C now terminates the command as the user would expect. Signed-off-by: Tuomas Tynkkynen <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2014-10-25misc: use __weakJeroen Hofstee
Signed-off-by: Jeroen Hofstee <[email protected]>
2014-05-29Add cli_ prefix to readline functionsSimon Glass
This makes it clear where the code resides. Signed-off-by: Simon Glass <[email protected]>
2014-05-29move CLI prototypes to cli.h and add commentsSimon Glass
Move the CLI prototypes from common.h to cli.h as part of an effort to reduce the size of common.h. Signed-off-by: Simon Glass <[email protected]>
2013-07-24Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk
Signed-off-by: Wolfgang Denk <[email protected]> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <[email protected]>
2013-03-29menu: export menu_default_choice() functionAnatolij Gustschin
Checking the default menu item and obtaining its data can be useful in custom menu code. Export menu_default_choice() function which serves this purpose. Signed-off-by: Anatolij Gustschin <[email protected]>
2013-03-29menu: Add support for user defined item choice functionPali Rohár
Selecting menu items is currently done in menu_interactive_choice() by reading the user input strings from standard input. Extend menu_interactive_choice() to support user defined function for selecting menu items. This function and its argument can be specified when creating the menu. Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Anatolij Gustschin <[email protected]>
2012-06-21menu: only timeout when menu is displayedRob Herring
Make the menu timeout apply only when prompt flag is set and after the menu is displayed. This allows auto boot to work no matter whether prompt is set or cleared. Use the default selection if the menu times out. This also fixes the timeout value given to readline_into_buffer to be seconds instead of 10th of seconds. Old behavior: if prompt display menu and wait for choice else wait for timeout if key pressed display menu and wait for choice else exit command New behavior: if prompt display menu if key pressed wait for choice else boot default entry on timeout else boot default entry Signed-off-by: Rob Herring <[email protected]>
2012-02-12common, menu: do not trigger timeout again, if a line is readHeiko Schocher
Signed-off-by: Heiko Schocher <[email protected]> Cc: Jason Hobbs <[email protected]> Acked-by: Jason Hobbs <[email protected]>
2012-02-12common, menu: add statusline supportHeiko Schocher
add the possibility to show a statusline when printing a menu Signed-off-by: Heiko Schocher <[email protected]> Cc: Jason Hobbs <[email protected]> Cc: Mike Frysinger <[email protected]> Acked-by: Mike Frysinger <[email protected]>
2012-02-12common: add possibility for readline_into_buffer timeoutHeiko Schocher
add possibility to add a timeout when reading a line into a buffer. Signed-off-by: Heiko Schocher <[email protected]> Cc: Mike Frysinger <[email protected]> Acked-by: Mike Frysinger <[email protected]>
2011-12-05common/menu.c: Fix build warningAnatolij Gustschin
Fix: menu.c: In function 'menu_item_print': menu.c:91: warning: passing argument 1 of 'putc' makes integer from pointer without a cast Signed-off-by: Anatolij Gustschin <[email protected]> Acked-by: Heiko Schocher <[email protected]> Tested-by: Heiko Schocher <[email protected]> Acked-by: Marek Vasut <[email protected]>
2011-11-29menu.c: use puts() instead of printf() where possibleWolfgang Denk
common/menu.c used printf() in a number of places to print user provided, constant strings (like the "title" string). printf() is dangerous here for example in case the user unwittingly embeds some '%' caracters that printf() would interpret as formatting and then pick up random arguments. Use puts() instead. We also omit the trailing ':' in the title line - if a user wants this, he can provide it as part of the title string. Signed-off-by: Wolfgang Denk <[email protected]>
2011-10-17common, menu: use abortboot for menu timeoutJason Hobbs
Signed-off-by: Jason Hobbs <[email protected]>
2011-10-17Add generic, reusable menu codeJason Hobbs
This will be used first by the pxe code, but is intended to be generic and reusable for other jobs in U-boot. Signed-off-by: Jason Hobbs <[email protected]>