bootstd: Add a boot menu
cover bootstd: Add a boot menu
So far standard boot lacks a boot menu, although it is possible to create a rudimentary one using the existing 'bootmenu' command.
Even then, this text-based menu offer only basic functionality and does not take full advantage of the displays which are common on many devices.
This series provides a 'bootflow menu' command which allows the user to select from the available bootflows. An attempt is made to show the name of the available operating systems, by reading more information into the bootflow. A logo can be read also, where supported, so that this can be presented to the user when an option is highlighted.
Full use is made of TrueType fonts, if enabled. For cases where only a serial console is available, it falls back to a simple text-based menu.
All of this is implementing using a new 'expo' construct, a collection of scenes (like menu screens) which can be navigated by the user to view information and select option. This is fairly general and should be able to cope with a wider array of use cases, with less hacking of the menu code, such as is currently needed for CMD_BOOTEFI_BOOTMGR.
Of course it would be possible to enhance the existing menu rather than creating a new setup. Instead it seems better to make the existing menu use expo, if code space permits. It avoids the event-loop problem and should be more extensible, given its loosely coupled components and use of IDs instead of pointers. Further motivation is provided in the documentation.
For now the CLI keypress-decoding code is split out to be used by the new menu. The key codes defined by menu.h are reused also.
This is of course just a starting point. Some ideas for future work are included in the documentation.
Simon Glass (24):
sandbox: Enable mmc command and legacy images
cli: Move readline character-processing to a state machine
bootmenu: Add a few comments
menu: Rename KEY_... to BKEY_...
menu: Update bootmenu_autoboot_loop() to return the code
menu: Update bootmenu_loop() to return the code
menu: Use a switch statement
menu: Make use of CLI character processing
image: Add a function to find a script in an image
video: Enable VIDEO_ANSI by default only with EFI
video: truetype: Rename the metrics function
video: Fix unchnaged typo
video: Add font functions to the vidconsole API
bootstd: Read the Operating System name for distro/scripts
bootstd: Allow reading a logo for the OS
menu: Factor out menu-keypress decoding
expo: Add basic implementation
expo: Add support for scenes
expo: Add support for scene menus
expo: Add basic tests
bootstd: Support creating a boot menu
bootstd: Add a test for the bootstd menu
bootstd: Support setting a theme for the menu
expo: Add documentation
arch/sandbox/dts/test.dts | 11 + boot/Kconfig | 12 + boot/Makefile | 3 + boot/bootflow.c | 1 + boot/bootflow_internal.h | 37 ++ boot/bootflow_menu.c | 281 ++++++++++++++ boot/bootmeth-uclass.c | 69 +++- boot/bootmeth_distro.c | 36 ++ boot/bootmeth_script.c | 38 ++ boot/bootstd-uclass.c | 2 + boot/expo.c | 133 +++++++ boot/scene.c | 385 +++++++++++++++++++ boot/scene_internal.h | 123 ++++++ boot/scene_menu.c | 372 ++++++++++++++++++ cmd/bootflow.c | 44 ++- cmd/bootmenu.c | 19 +- cmd/eficonfig.c | 38 +- cmd/font.c | 6 +- cmd/source.c | 173 +++++---- common/Makefile | 6 +- common/cli_getch.c | 208 ++++++++++ common/cli_readline.c | 150 ++------ common/menu.c | 157 ++++---- configs/sandbox_defconfig | 2 + configs/sandbox_flattree_defconfig | 2 + configs/snow_defconfig | 4 + configs/tools-only_defconfig | 2 + doc/develop/expo.rst | 184 +++++++++ doc/develop/index.rst | 1 + drivers/video/Kconfig | 7 +- drivers/video/console_truetype.c | 35 +- drivers/video/vidconsole-uclass.c | 33 ++ include/bootflow.h | 40 ++ include/bootmeth.h | 16 + include/bootstd.h | 4 + include/cli.h | 74 ++++ include/expo.h | 474 +++++++++++++++++++++++ include/image.h | 13 + include/menu.h | 77 +++- include/video.h | 2 +- include/video_console.h | 63 ++- test/boot/Makefile | 2 + test/boot/bootflow.c | 130 +++++++ test/boot/expo.c | 510 +++++++++++++++++++++++++ test/py/tests/bootstd/armbian.bmp.xz | Bin 0 -> 1384 bytes test/py/tests/bootstd/mmc4.img.xz | Bin 0 -> 7072 bytes test/py/tests/test_android/test_avb.py | 2 + test/py/tests/test_ut.py | 216 ++++++++++- 48 files changed, 3813 insertions(+), 384 deletions(-) create mode 100644 boot/bootflow_internal.h create mode 100644 boot/bootflow_menu.c create mode 100644 boot/expo.c create mode 100644 boot/scene.c create mode 100644 boot/scene_internal.h create mode 100644 boot/scene_menu.c create mode 100644 common/cli_getch.c create mode 100644 doc/develop/expo.rst create mode 100644 include/expo.h create mode 100644 test/boot/expo.c create mode 100644 test/py/tests/bootstd/armbian.bmp.xz create mode 100644 test/py/tests/bootstd/mmc4.img.xz
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 1/24 sandbox: Enable mmc command and legacy images
The mmc command is useful for testing mmc disk images in sandbox, so enable it. We also need to enable legacy images so that we can run tests which use them.
Disable it for a few avb tests since MMC is not implemented there yet.
---
configs/sandbox_defconfig | 2 ++ configs/sandbox_flattree_defconfig | 2 ++ test/py/tests/test_android/test_avb.py | 2 ++ 3 files changed, 6 insertions(+)
configs/sandbox_defconfig +2 -0
@@ -13,6 +13,7 @@ CONFIG_FIT=y CONFIG_FIT_RSASSA_PSS=y CONFIG_FIT_CIPHER=y CONFIG_FIT_VERBOSE=y +CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y
@@ -71,6 +72,7 @@ CONFIG_CMD_IDE=y CONFIG_CMD_I2C=y CONFIG_CMD_LOADM=y CONFIG_CMD_LSBLK=y +CONFIG_CMD_MMC=y CONFIG_CMD_MUX=y CONFIG_CMD_OSD=y CONFIG_CMD_PCI=y
configs/sandbox_flattree_defconfig +2 -0
@@ -11,6 +11,7 @@ CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_FIT_VERBOSE=y +CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y
@@ -40,6 +41,7 @@ CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y +CONFIG_CMD_MMC=y CONFIG_CMD_OSD=y CONFIG_CMD_PCI=y CONFIG_CMD_REMOTEPROC=y
test/py/tests/test_android/test_avb.py +2 -0
@@ -39,6 +39,7 @@ def test_avb_verify(u_boot_console): @pytest.mark.buildconfigspec('cmd_avb') @pytest.mark.buildconfigspec('cmd_mmc') [email protected]('sandbox') def test_avb_mmc_uuid(u_boot_console): """Check if 'avb get_uuid' works, compare results with 'part list mmc 1' output
@@ -97,6 +98,7 @@ def test_avb_is_unlocked(u_boot_console): @pytest.mark.buildconfigspec('cmd_avb') @pytest.mark.buildconfigspec('cmd_mmc') [email protected]('sandbox') def test_avb_mmc_read(u_boot_console): """Test mmc read operation """
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 2/24 cli: Move readline character-processing to a state machine
In reply to Simon GlassThe current cread_line() function is very long. It handles the escape processing inline. The menu command does similar processing but at the character level, so there is some duplication.
Split the character processing into a new function cli_ch_process() which processes individual characters and returns the resulting input character, taking account of escape sequences. It requires the caller to set up and maintain its state.
Update cread_line() to use this new function.
The only intended functional change is that an invalid escape sequence does not add invalid/control characters into the input buffer, but instead discards these.
---
common/Makefile | 6 +- common/cli_getch.c | 204 ++++++++++++++++++++++++++++++++++++++++++ common/cli_readline.c | 150 +++++-------------------------- include/cli.h | 72 +++++++++++++++ 4 files changed, 301 insertions(+), 131 deletions(-) create mode 100644 common/cli_getch.c
common/Makefile +3 -3
@@ -42,7 +42,7 @@ obj-$(CONFIG_LCD_ROTATION) += lcd_console_rotation.o obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_UPDATE_COMMON) += update.o obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o -obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o +obj-$(CONFIG_CMDLINE) += cli_getch.o cli_readline.o cli_simple.o endif # !CONFIG_SPL_BUILD
@@ -97,8 +97,8 @@ obj-y += eeprom/eeprom_field.o eeprom/eeprom_layout.o endif obj-y += cli.o -obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o -obj-$(CONFIG_STM32MP1_DDR_INTERACTIVE) += cli_simple.o cli_readline.o +obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_getch.o cli_simple.o cli_readline.o +obj-$(CONFIG_STM32MP1_DDR_INTERACTIVE) += cli_getch.o cli_simple.o cli_readline.o obj-$(CONFIG_DFU_OVER_USB) += dfu.o obj-y += command.o obj-$(CONFIG_$(SPL_TPL_)LOG) += log.o
common/cli_getch.c new file +204 -0
204 lines not on this page · raw message
common/cli_readline.c +22 -128
193 lines not on this page · raw message
include/cli.h +72 -0
83 lines not on this page · raw message
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 3/24 bootmenu: Add a few comments
In reply to Simon GlassThe behaviour of these two functions is completely undocumented. Add some notes so the poor, suffering dev can figure out what is going on.
---
include/menu.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
include/menu.h +42 -0
@@ -42,6 +42,7 @@ struct bootmenu_data {struct bootmenu_entry *first;/* first menu entry */ }; +/** enum bootmenu_key - keys that can be returned by the bootmenu */ enum bootmenu_key {KEY_NONE =0 ,KEY_UP ,
@@ -53,8 +54,49 @@ enum bootmenu_key { KEY_SPACE, }; +/** +* bootmenu_autoboot_loop() - handle autobooting if no key is pressed +* +* This shows a prompt to allow the user to press a key to interrupt auto boot +* of the first menu option. +* +* It then waits for the required time (menu->delay in seconds) for a key to be +* pressed. If nothing is pressed in that time, @key returns KEY_SELECT +* indicating that the current option should be chosen. +* +* @menu: Menu being processed +* @key: Returns the code for the key the user pressed: +* enter: KEY_SELECT +* Ctrl-C: KEY_QUIT +* anything else: KEY_NONE +* @esc: Set to 1 if the escape key is pressed, otherwise not updated +*/ void bootmenu_autoboot_loop (struct bootmenu_data *menu,enum bootmenu_key *key,int *esc); + +/** +* bootmenu_loop() - handle waiting for a keypress when autoboot is disabled +* +* This is used when the menu delay is negative, indicating that the delay has +* elapsed, or there was no delay to begin with. +* +* It reads a character and processes it, returning a menu-key code if a +* character is recognised +* +* @menu: Menu being processed +* @key: Returns the code for the key the user pressed: +* enter: KEY_SELECT +* Ctrl-C: KEY_QUIT +* Up arrow: KEY_UP +* Down arrow: KEY_DOWN +* Escape (by itself): KEY_QUIT +* Plus: KEY_PLUS +* Minus: KEY_MINUS +* Space: KEY_SPACE +* @esc: On input, a non-zero value indicates that an escape sequence has +* resulted in that many characters so far. On exit this is updated to the +* new number of characters +*/ void bootmenu_loop (struct bootmenu_data *menu,enum bootmenu_key *key,int *esc);
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 03/24] bootmenu: Add a few comments
Quoted 40 lines · Simon Glass
The behaviour of these two functions is completely undocumented. Add some notes so the poor, suffering dev can figure out what is going on.
Signed-off-by Simon Glass <[email protected]>---
include/menu.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)include/menu.h +16
-0@@ -42,6 +42,7 @@ struct bootmenu_data {struct bootmenu_entry *first;/* first menu entry */ }; +/** enum bootmenu_key - keys that can be returned by the bootmenu */ enum bootmenu_key {KEY_NONE =0 ,KEY_UP ,@@ -53,8 +54,49 @@ enum bootmenu_key { KEY_SPACE, }; +/** +* bootmenu_autoboot_loop() - handle autobooting if no key is pressed +* +* This shows a prompt to allow the user to press a key to interrupt auto boot +* of the first menu option. +* +* It then waits for the required time (menu->delay in seconds) for a key to be +* pressed. If nothing is pressed in that time, @key returns KEY_SELECT +* indicating that the current option should be chosen. +* +* @menu: Menu being processed +* @key: Returns the code for the key the user pressed: +* enter: KEY_SELECT +* Ctrl-C: KEY_QUIT +* anything else: KEY_NONE
include/menu.h enum bootmenu_key { · line 81
Quoted 10 lines
include/menu.h +8
-0+* @esc: Set to 1 if the escape key is pressed, otherwise not updated +*/ void bootmenu_autoboot_loop (struct bootmenu_data *menu,enum bootmenu_key *key,int *esc); + +/** +* bootmenu_loop() - handle waiting for a keypress when autoboot is disabled +* +* This is used when the menu delay is negative, indicating that the delay has +* elapsed, or there was no delay to begin with.
Unfortunately the description does not match the code.
This function is entered if some key was pressed, so autoboot was stopped. When the delay elapses the default action is taken by the caller.
Quoted 4 lines
include/menu.h +4
-0+* +* It reads a character and processes it, returning a menu-key code if a +* character is recognised +*
include/menu.h enum bootmenu_key { · line 95
Quoted 10 lines
include/menu.h +10
-0+* @menu: Menu being processed +* @key: Returns the code for the key the user pressed: +* enter: KEY_SELECT +* Ctrl-C: KEY_QUIT +* Up arrow: KEY_UP +* Down arrow: KEY_DOWN +* Escape (by itself): KEY_QUIT +* Plus: KEY_PLUS +* Minus: KEY_MINUS +* Space: KEY_SPACE
We already discussed that this list is to change. We should support accelerator keys in menus.
include/menu.h enum bootmenu_key { · line 96
Quoted 1 line
include/menu.h +1
-0+* @esc: On input, a non-zero value indicates that an escape sequence has
1 indicates that the ESC key has been pressed.
All other values indicate that the ESC key has not been pressed.
--
The whole design is broken in that the concept of a menu is not properly encapsulated.
A function like bootmenu_autoboot_loop() should not be exported.
The view side of a menu should be in a function that takes the following arguments:
- the location (x,y) on the screen
- the size (dx, dy) of the displayed menu
(further items should be viewed by vertical scrolling,
more characters by horizontal scrolling)
- a list of menu items to display
- a event function called whenever the selected menu item changes (or NULL)
Such an event function will allow to display extra information for a menu item.
The model would be an array of utf-8 strings.
The controller will invoke the view function and receive the index of the selected item as the return value (or -1 if ESC is pressed).
Best regards
Heinrich
Quoted 6 lines
include/menu.h +3
-0+* resulted in that many characters so far. On exit this is updated to the +* new number of characters +*/ void bootmenu_loop (struct bootmenu_data *menu,enum bootmenu_key *key,int *esc);
Re: [PATCH 03/24] bootmenu: Add a few comments
Hi Heinrich,
Quoted 55 lines · Heinrich Schuchardt
Quoted 40 lines · Simon Glass
The behaviour of these two functions is completely undocumented. Add some notes so the poor, suffering dev can figure out what is going on.
Signed-off-by Simon Glass <[email protected]>---
include/menu.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)include/menu.h +16
-0@@ -42,6 +42,7 @@ struct bootmenu_data {struct bootmenu_entry *first;/* first menu entry */ }; +/** enum bootmenu_key - keys that can be returned by the bootmenu */ enum bootmenu_key {KEY_NONE =0 ,KEY_UP ,@@ -53,8 +54,49 @@ enum bootmenu_key { KEY_SPACE, }; +/** +* bootmenu_autoboot_loop() - handle autobooting if no key is pressed +* +* This shows a prompt to allow the user to press a key to interrupt auto boot +* of the first menu option. +* +* It then waits for the required time (menu->delay in seconds) for a key to be +* pressed. If nothing is pressed in that time, @key returns KEY_SELECT +* indicating that the current option should be chosen. +* +* @menu: Menu being processed +* @key: Returns the code for the key the user pressed: +* enter: KEY_SELECT +* Ctrl-C: KEY_QUIT +* anything else: KEY_NONE include/menu.h enum bootmenu_key { · line 81
Quoted 10 lines
include/menu.h +8
-0+* @esc: Set to 1 if the escape key is pressed, otherwise not updated +*/ void bootmenu_autoboot_loop (struct bootmenu_data *menu,enum bootmenu_key *key,int *esc); + +/** +* bootmenu_loop() - handle waiting for a keypress when autoboot is disabled +* +* This is used when the menu delay is negative, indicating that the delay has +* elapsed, or there was no delay to begin with. Unfortunately the description does not match the code.
Quoted 2 lines
This function is entered if some key was pressed, so autoboot was stopped. When the delay elapses the default action is taken by the caller.
This one doesn't do default action, right? That functionality is in bootmenu_autoboot_loop() above.
Quoted 16 lines
Quoted 5 lines
include/menu.h +4
-0+* +* It reads a character and processes it, returning a menu-key code if a +* character is recognised +* include/menu.h enum bootmenu_key { · line 95
Quoted 10 lines
include/menu.h +10
-0+* @menu: Menu being processed +* @key: Returns the code for the key the user pressed: +* enter: KEY_SELECT +* Ctrl-C: KEY_QUIT +* Up arrow: KEY_UP +* Down arrow: KEY_DOWN +* Escape (by itself): KEY_QUIT +* Plus: KEY_PLUS +* Minus: KEY_MINUS +* Space: KEY_SPACE
Quoted 2 lines
We already discussed that this list is to change. We should support accelerator keys in menus.
OK, but not related to my change here.
Quoted 23 lines
include/menu.h enum bootmenu_key { · line 96
Quoted 2 lines
include/menu.h +1
-0+* @esc: On input, a non-zero value indicates that an escape sequence has 1 indicates that the ESC key has been pressed.
All other values indicate that the ESC key has not been pressed.--
The whole design is broken in that the concept of a menu is not properly encapsulated.
A function like
bootmenu_autoboot_loop()should not be exported.The view side of a menu should be in a function that takes the following arguments:
- the location (x,y) on the screen
- the size (dx, dy) of the displayed menu
(further items should be viewed by vertical scrolling,
more characters by horizontal scrolling)
- a list of menu items to display
- a event function called whenever the selected menu item changes (or NULL)
Quoted 7 lines
Such an event function will allow to display extra information for a menu item.
The model would be an array of utf-8 strings.
The controller will invoke the view function and receive the index of the selected item as the return value (or -1 if ESC is pressed).
I think the existing menu system is not useful as a basis for what we want, which I why I designed expo. We should focus on getting that right. Just to be clear, I will not be taking on any effort involved in making things work with EFI. But you may wish to.
Quoted 12 lines
Best regards
Heinrich
Quoted 6 lines
include/menu.h +3
-0+* resulted in that many characters so far. On exit this is updated to the +* new number of characters +*/ void bootmenu_loop (struct bootmenu_data *menu,enum bootmenu_key *key,int *esc);
Regards,
Simon
PATCH 4/24 menu: Rename KEY_... to BKEY_...
In reply to Simon GlassThis enum values conflict with linux/input.h so rename them.
---
cmd/bootmenu.c | 10 +++++----- cmd/eficonfig.c | 26 +++++++++++++------------- common/menu.c | 34 +++++++++++++++++----------------- include/menu.h | 32 ++++++++++++++++---------------- 4 files changed, 51 insertions(+), 51 deletions(-)
cmd/bootmenu.c +5 -5
@@ -86,7 +86,7 @@ static char *bootmenu_choice_entry(void *data) {struct bootmenu_data *menu = data;struct bootmenu_entry *iter; -enum bootmenu_key key =KEY_NONE ; +enum bootmenu_key key =BKEY_NONE ;int esc =0 ;int i;
@@ -100,22 +100,22 @@ static char *bootmenu_choice_entry(void *data) }switch (key) { -case KEY_UP : +case BKEY_UP :if (menu->active >0 ) --menu->active;/* no menu key selected, regenerate menu */ return NULL ; -case KEY_DOWN : +case BKEY_DOWN :if (menu->active < menu->count -1 ) ++menu->active;/* no menu key selected, regenerate menu */ return NULL ; -case KEY_SELECT : +case BKEY_SELECT : iter = menu->first;for (i =0 ; i < menu->active; ++i) iter = iter->next;return iter->key; -case KEY_QUIT : +case BKEY_QUIT :/* Quit by choosing the last entry - U-Boot console */ iter = menu->first;while (iter->next)
cmd/eficonfig.c +13 -13
@@ -193,31 +193,31 @@ static char *eficonfig_choice_entry(void *data)int esc =0 ;struct list_head *pos, *n;struct eficonfig_entry *entry; -enum bootmenu_key key =KEY_NONE ; +enum bootmenu_key key =BKEY_NONE ;struct efimenu *efi_menu = data;while (1 ) {bootmenu_loop ((struct bootmenu_data *)efi_menu, &key, &esc);switch (key) { -case KEY_UP : +case BKEY_UP :if (efi_menu->active >0 ) --efi_menu->active;/* no menu key selected, regenerate menu */ return NULL ; -case KEY_DOWN : +case BKEY_DOWN :if (efi_menu->active < efi_menu->count -1 ) ++efi_menu->active;/* no menu key selected, regenerate menu */ return NULL ; -case KEY_SELECT : +case BKEY_SELECT :list_for_each_safe (pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list);if (entry->num == efi_menu->active)return entry->key; }break ; -case KEY_QUIT : +case BKEY_QUIT :/* Quit by choosing the last entry */ entry = list_last_entry(&efi_menu->list, struct eficonfig_entry, list);return entry->key;
@@ -1864,14 +1864,14 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)int esc =0 ;struct list_head *pos, *n;struct eficonfig_boot_order *tmp; -enum bootmenu_key key =KEY_NONE ; +enum bootmenu_key key =BKEY_NONE ;struct eficonfig_boot_order *entry;while (1 ) {bootmenu_loop (NULL , &key, &esc);switch (key) { -case KEY_PLUS : +case BKEY_PLUS :if (efi_menu->active >0 ) {list_for_each_safe (pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_boot_order, list);
@@ -1885,11 +1885,11 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)list_add (&tmp->list, &entry->list); } fallthrough; -case KEY_UP : +case BKEY_UP :if (efi_menu->active >0 ) --efi_menu->active;return EFI_NOT_READY ; -case KEY_MINUS : +case BKEY_MINUS :if (efi_menu->active < efi_menu->count -3 ) {list_for_each_safe (pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_boot_order, list);
@@ -1905,11 +1905,11 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) ++efi_menu->active; }return EFI_NOT_READY ; -case KEY_DOWN : +case BKEY_DOWN :if (efi_menu->active < efi_menu->count -1 ) ++efi_menu->active;return EFI_NOT_READY ; -case KEY_SELECT : +case BKEY_SELECT :/* "Save" */ if (efi_menu->active == efi_menu->count -2 )return EFI_SUCCESS ;
@@ -1919,7 +1919,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)return EFI_ABORTED ;break ; -case KEY_SPACE : +case BKEY_SPACE :if (efi_menu->active < efi_menu->count -2 ) {list_for_each_safe (pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_boot_order, list);
@@ -1930,7 +1930,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) } }break ; -case KEY_QUIT : +case BKEY_QUIT :return EFI_ABORTED ;default :/* Pressed key is not valid, no need to regenerate the menu */
common/menu.c +17 -17
@@ -446,16 +446,16 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,switch (c) {case '\e' : *esc =1 ; - *key =KEY_NONE ; + *key =BKEY_NONE ;break ;case '\r' : - *key =KEY_SELECT ; + *key =BKEY_SELECT ;break ;case 0x3 :/* ^C */ - *key =KEY_QUIT ; + *key =BKEY_QUIT ;break ;default : - *key =KEY_NONE ; + *key =BKEY_NONE ;break ; }
@@ -471,7 +471,7 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu, printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, menu->count + 5, 1);if (menu->delay ==0 ) - *key =KEY_SELECT ; + *key =BKEY_SELECT ; } void bootmenu_loop(struct bootmenu_data *menu,
@@ -503,17 +503,17 @@ void bootmenu_loop(struct bootmenu_data *menu,/* First char of ANSI escape sequence '\e' */ if (c =='\e' ) { *esc =1 ; - *key =KEY_NONE ; + *key =BKEY_NONE ; }break ;case 1 :/* Second char of ANSI '[' */ if (c =='[' ) { *esc =2 ; - *key =KEY_NONE ; + *key =BKEY_NONE ; }else {/* Alone ESC key was pressed */ - *key =KEY_QUIT ; + *key =BKEY_QUIT ; *esc = (c =='\e' ) ?1 :0 ; }break ;
@@ -522,7 +522,7 @@ void bootmenu_loop(struct bootmenu_data *menu,/* Third char of ANSI (number '1') - optional */ if (*esc ==2 && c =='1' ) { *esc =3 ; - *key =KEY_NONE ; + *key =BKEY_NONE ;break ; }
@@ -530,31 +530,31 @@ void bootmenu_loop(struct bootmenu_data *menu,/* ANSI 'A' - key up was pressed */ if (c =='A' ) - *key =KEY_UP ; + *key =BKEY_UP ;/* ANSI 'B' - key down was pressed */ else if (c =='B' ) - *key =KEY_DOWN ; + *key =BKEY_DOWN ;/* other key was pressed */ else - *key =KEY_NONE ; + *key =BKEY_NONE ;break ; }/* enter key was pressed */ if (c =='\r' ) - *key =KEY_SELECT ; + *key =BKEY_SELECT ;/* ^C was pressed */ if (c ==0x3 ) - *key =KEY_QUIT ; + *key =BKEY_QUIT ;if (c =='+' ) - *key =KEY_PLUS ; + *key =BKEY_PLUS ;if (c =='-' ) - *key =KEY_MINUS ; + *key =BKEY_MINUS ;if (c ==' ' ) - *key =KEY_SPACE ; + *key =BKEY_SPACE ; }
include/menu.h +16 -16
@@ -44,14 +44,14 @@ struct bootmenu_data {/** enum bootmenu_key - keys that can be returned by the bootmenu */ enum bootmenu_key { -KEY_NONE =0 , -KEY_UP , -KEY_DOWN , -KEY_SELECT , -KEY_QUIT , -KEY_PLUS , -KEY_MINUS , -KEY_SPACE , +BKEY_NONE =0 , +BKEY_UP , +BKEY_DOWN , +BKEY_SELECT , +BKEY_QUIT , +BKEY_PLUS , +BKEY_MINUS , +BKEY_SPACE , };/**
@@ -85,14 +85,14 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,* * @menu: Menu being processed * @key: Returns the code for the key the user pressed: -* enter: KEY_SELECT -* Ctrl-C: KEY_QUIT -* Up arrow: KEY_UP -* Down arrow: KEY_DOWN -* Escape (by itself): KEY_QUIT -* Plus: KEY_PLUS -* Minus: KEY_MINUS -* Space: KEY_SPACE +* enter: BKEY_SELECT +* Ctrl-C: BKEY_QUIT +* Up arrow: BKEY_UP +* Down arrow: BKEY_DOWN +* Escape (by itself): BKEY_QUIT +* Plus: BKEY_PLUS +* Minus: BKEY_MINUS +* Space: BKEY_SPACE * @esc: On input, a non-zero value indicates that an escape sequence has * resulted in that many characters so far. On exit this is updated to the * new number of characters
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 04/24] menu: Rename KEY_... to BKEY_...
Quoted 16 lines · Simon Glass
This enum values conflict with
linux/input.hso rename them.Signed-off-by Simon Glass <[email protected]>---
cmd/bootmenu.c | 10 +++++----- cmd/eficonfig.c | 26 +++++++++++++------------- common/menu.c | 34 +++++++++++++++++----------------- include/menu.h | 32 ++++++++++++++++---------------- 4 files changed, 51 insertions(+), 51 deletions(-)cmd/bootmenu.c +0
-0
cmd/bootmenu.c static char *bootmenu_choice_entry(void *data) · line 86
Quoted 1 line
cmd/bootmenu.c +0
-0@@ -86,7 +86,7 @@ static char *bootmenu_choice_entry(void *data) {
The argument should be of type struct bootmenu_data* and not void.
This function and the enum should be move to common/menu.c and not exported.
common/menu.c does not import linux/input.h so there will be no conflict but that sould not stop you from renaming the constants.
Best regards
Heinrich
Quoted 292 lines
cmd/bootmenu.c +5
-5struct bootmenu_data *menu = data;struct bootmenu_entry *iter; -enum bootmenu_key key =KEY_NONE ; +enum bootmenu_key key =BKEY_NONE ;int esc =0 ;int i;@@ -100,22 +100,22 @@ static char *bootmenu_choice_entry(void *data) }switch (key) { -case KEY_UP : +case BKEY_UP :if (menu->active >0 ) --menu->active;/* no menu key selected, regenerate menu */ return NULL ; -case KEY_DOWN : +case BKEY_DOWN :if (menu->active < menu->count -1 ) ++menu->active;/* no menu key selected, regenerate menu */ return NULL ; -case KEY_SELECT : +case BKEY_SELECT : iter = menu->first;for (i =0 ; i < menu->active; ++i) iter = iter->next;return iter->key; -case KEY_QUIT : +case BKEY_QUIT :/* Quit by choosing the last entry - U-Boot console */ iter = menu->first;while (iter->next)cmd/eficonfig.c +13
-13@@ -193,31 +193,31 @@ static char *eficonfig_choice_entry(void *data)int esc =0 ;struct list_head *pos, *n;struct eficonfig_entry *entry; -enum bootmenu_key key =KEY_NONE ; +enum bootmenu_key key =BKEY_NONE ;struct efimenu *efi_menu = data;while (1 ) {bootmenu_loop ((struct bootmenu_data *)efi_menu, &key, &esc);switch (key) { -case KEY_UP : +case BKEY_UP :if (efi_menu->active >0 ) --efi_menu->active;/* no menu key selected, regenerate menu */ return NULL ; -case KEY_DOWN : +case BKEY_DOWN :if (efi_menu->active < efi_menu->count -1 ) ++efi_menu->active;/* no menu key selected, regenerate menu */ return NULL ; -case KEY_SELECT : +case BKEY_SELECT :list_for_each_safe (pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_entry, list);if (entry->num == efi_menu->active)return entry->key; }break ; -case KEY_QUIT : +case BKEY_QUIT :/* Quit by choosing the last entry */ entry = list_last_entry(&efi_menu->list, struct eficonfig_entry, list);return entry->key;@@ -1864,14 +1864,14 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)int esc =0 ;struct list_head *pos, *n;struct eficonfig_boot_order *tmp; -enum bootmenu_key key =KEY_NONE ; +enum bootmenu_key key =BKEY_NONE ;struct eficonfig_boot_order *entry;while (1 ) {bootmenu_loop (NULL , &key, &esc);switch (key) { -case KEY_PLUS : +case BKEY_PLUS :if (efi_menu->active >0 ) {list_for_each_safe (pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_boot_order, list);@@ -1885,11 +1885,11 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)list_add (&tmp->list, &entry->list); } fallthrough; -case KEY_UP : +case BKEY_UP :if (efi_menu->active >0 ) --efi_menu->active;return EFI_NOT_READY ; -case KEY_MINUS : +case BKEY_MINUS :if (efi_menu->active < efi_menu->count -3 ) {list_for_each_safe (pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_boot_order, list);@@ -1905,11 +1905,11 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) ++efi_menu->active; }return EFI_NOT_READY ; -case KEY_DOWN : +case BKEY_DOWN :if (efi_menu->active < efi_menu->count -1 ) ++efi_menu->active;return EFI_NOT_READY ; -case KEY_SELECT : +case BKEY_SELECT :/* "Save" */ if (efi_menu->active == efi_menu->count -2 )return EFI_SUCCESS ;@@ -1919,7 +1919,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)return EFI_ABORTED ;break ; -case KEY_SPACE : +case BKEY_SPACE :if (efi_menu->active < efi_menu->count -2 ) {list_for_each_safe (pos, n, &efi_menu->list) { entry = list_entry(pos, struct eficonfig_boot_order, list);@@ -1930,7 +1930,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu) } }break ; -case KEY_QUIT : +case BKEY_QUIT :return EFI_ABORTED ;default :/* Pressed key is not valid, no need to regenerate the menu */ common/menu.c +17
-17@@ -446,16 +446,16 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,switch (c) {case '\e' : *esc =1 ; - *key =KEY_NONE ; + *key =BKEY_NONE ;break ;case '\r' : - *key =KEY_SELECT ; + *key =BKEY_SELECT ;break ;case 0x3 :/* ^C */ - *key =KEY_QUIT ; + *key =BKEY_QUIT ;break ;default : - *key =KEY_NONE ; + *key =BKEY_NONE ;break ; }@@ -471,7 +471,7 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu, printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, menu->count + 5, 1);if (menu->delay ==0 ) - *key =KEY_SELECT ; + *key =BKEY_SELECT ; } void bootmenu_loop(struct bootmenu_data *menu,@@ -503,17 +503,17 @@ void bootmenu_loop(struct bootmenu_data *menu,/* First char of ANSI escape sequence '\e' */ if (c =='\e' ) { *esc =1 ; - *key =KEY_NONE ; + *key =BKEY_NONE ; }break ;case 1 :/* Second char of ANSI '[' */ if (c =='[' ) { *esc =2 ; - *key =KEY_NONE ; + *key =BKEY_NONE ; }else {/* Alone ESC key was pressed */ - *key =KEY_QUIT ; + *key =BKEY_QUIT ; *esc = (c =='\e' ) ?1 :0 ; }break ;@@ -522,7 +522,7 @@ void bootmenu_loop(struct bootmenu_data *menu,/* Third char of ANSI (number '1') - optional */ if (*esc ==2 && c =='1' ) { *esc =3 ; - *key =KEY_NONE ; + *key =BKEY_NONE ;break ; }@@ -530,31 +530,31 @@ void bootmenu_loop(struct bootmenu_data *menu,/* ANSI 'A' - key up was pressed */ if (c =='A' ) - *key =KEY_UP ; + *key =BKEY_UP ;/* ANSI 'B' - key down was pressed */ else if (c =='B' ) - *key =KEY_DOWN ; + *key =BKEY_DOWN ;/* other key was pressed */ else - *key =KEY_NONE ; + *key =BKEY_NONE ;break ; }/* enter key was pressed */ if (c =='\r' ) - *key =KEY_SELECT ; + *key =BKEY_SELECT ;/* ^C was pressed */ if (c ==0x3 ) - *key =KEY_QUIT ; + *key =BKEY_QUIT ;if (c =='+' ) - *key =KEY_PLUS ; + *key =BKEY_PLUS ;if (c =='-' ) - *key =KEY_MINUS ; + *key =BKEY_MINUS ;if (c ==' ' ) - *key =KEY_SPACE ; + *key =BKEY_SPACE ; }include/menu.h +16
-16@@ -44,14 +44,14 @@ struct bootmenu_data {/** enum bootmenu_key - keys that can be returned by the bootmenu */ enum bootmenu_key { -KEY_NONE =0 , -KEY_UP , -KEY_DOWN , -KEY_SELECT , -KEY_QUIT , -KEY_PLUS , -KEY_MINUS , -KEY_SPACE , +BKEY_NONE =0 , +BKEY_UP , +BKEY_DOWN , +BKEY_SELECT , +BKEY_QUIT , +BKEY_PLUS , +BKEY_MINUS , +BKEY_SPACE , };/** @@ -85,14 +85,14 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,* * @menu: Menu being processed * @key: Returns the code for the key the user pressed: -* enter: KEY_SELECT -* Ctrl-C: KEY_QUIT -* Up arrow: KEY_UP -* Down arrow: KEY_DOWN -* Escape (by itself): KEY_QUIT -* Plus: KEY_PLUS -* Minus: KEY_MINUS -* Space: KEY_SPACE +* enter: BKEY_SELECT +* Ctrl-C: BKEY_QUIT +* Up arrow: BKEY_UP +* Down arrow: BKEY_DOWN +* Escape (by itself): BKEY_QUIT +* Plus: BKEY_PLUS +* Minus: BKEY_MINUS +* Space: BKEY_SPACE * @esc: On input, a non-zero value indicates that an escape sequence has * resulted in that many characters so far. On exit this is updated to the * new number of characters
Re: [PATCH 04/24] menu: Rename KEY_... to BKEY_...
Hi Heinrich,
Quoted 22 lines · Heinrich Schuchardt
Quoted 16 lines · Simon Glass
This enum values conflict with
linux/input.hso rename them.Signed-off-by Simon Glass <[email protected]>---
cmd/bootmenu.c | 10 +++++----- cmd/eficonfig.c | 26 +++++++++++++------------- common/menu.c | 34 +++++++++++++++++----------------- include/menu.h | 32 ++++++++++++++++---------------- 4 files changed, 51 insertions(+), 51 deletions(-)cmd/bootmenu.c +0
-0cmd/bootmenu.c static char *bootmenu_choice_entry(void *data) · line 86
Quoted 1 line
cmd/bootmenu.c +0
-0@@ -86,7 +86,7 @@ static char *bootmenu_choice_entry(void *data) {The argument should be of type struct bootmenu_data* and not void.
Quoted 1 line
This function and the enum should be move to
common/menu.cand not exported.
That would be a separate patch.
Quoted 3 lines
common/menu.cdoes not importlinux/input.hso there will be no conflict but that sould not stop you from renaming the constants.
Yes, it's not the conflict, just the confusion.
Regards,
Simon
PATCH 5/24 menu: Update bootmenu_autoboot_loop() to return the code
In reply to Simon GlassUse 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.
---
cmd/bootmenu.c | 2 +- common/menu.c | 16 +++++++++------- include/menu.h | 7 +++---- 3 files changed, 13 insertions(+), 12 deletions(-)
cmd/bootmenu.c +1 -1
@@ -93,7 +93,7 @@ static char *bootmenu_choice_entry(void *data)while (1 ) {if (menu->delay >=0 ) {/* Autoboot was not stopped */ -bootmenu_autoboot_loop (menu, &key, &esc); + key =bootmenu_autoboot_loop (menu, &esc); }else {/* Some key was pressed, so autoboot was stopped */ bootmenu_loop (menu, &key, &esc);
common/menu.c +9 -7
@@ -425,9 +425,9 @@ int menu_destroy(struct menu *m)return 1 ; } -void bootmenu_autoboot_loop (struct bootmenu_data *menu, -enum bootmenu_key *key,int *esc) +enum bootmenu_key bootmenu_autoboot_loop (struct bootmenu_data *menu,int *esc) { +enum bootmenu_key key =BKEY_NONE ;int i, c;while (menu->delay >0 ) {
@@ -446,16 +446,16 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,switch (c) {case '\e' : *esc =1 ; - *key =BKEY_NONE ; + key =BKEY_NONE ;break ;case '\r' : - *key =BKEY_SELECT ; + key =BKEY_SELECT ;break ;case 0x3 :/* ^C */ - *key =BKEY_QUIT ; + key =BKEY_QUIT ;break ;default : - *key =BKEY_NONE ; + key =BKEY_NONE ;break ; }
@@ -471,7 +471,9 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu, printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, menu->count + 5, 1);if (menu->delay ==0 ) - *key =BKEY_SELECT ; + key =BKEY_SELECT ; + +return key; } void bootmenu_loop(struct bootmenu_data *menu,
include/menu.h +3 -4
@@ -65,14 +65,13 @@ enum bootmenu_key {* indicating that the current option should be chosen. * * @menu: Menu being processed -* @key: Returns the code for the key the user pressed: +* @esc: Set to 1 if the escape key is pressed, otherwise not updated +* Returns: code for the key the user pressed: * enter: KEY_SELECT * Ctrl-C: KEY_QUIT * anything else: KEY_NONE -* @esc: Set to 1 if the escape key is pressed, otherwise not updated */ -void bootmenu_autoboot_loop (struct bootmenu_data *menu, -enum bootmenu_key *key,int *esc); +enum bootmenu_key bootmenu_autoboot_loop (struct bootmenu_data *menu,int *esc);/** * bootmenu_loop() - handle waiting for a keypress when autoboot is disabled
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 05/24] menu: Update bootmenu_autoboot_loop() to return the code
cmd/bootmenu.c static char *bootmenu_choice_entry(void *data)
Quoted 17 lines · Simon 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]>---
cmd/bootmenu.c | 2 +- common/menu.c | 16 +++++++++------- include/menu.h | 7 +++---- 3 files changed, 13 insertions(+), 12 deletions(-)cmd/bootmenu.c +0
-0@@ -93,7 +93,7 @@ static char *bootmenu_choice_entry(void *data)
First of all this function should be moved to common/menu.c.
Quoted 65 lines
cmd/bootmenu.c +1
-1while (1 ) {if (menu->delay >=0 ) {/* Autoboot was not stopped */ -bootmenu_autoboot_loop (menu, &key, &esc); + key =bootmenu_autoboot_loop (menu, &esc); }else {/* Some key was pressed, so autoboot was stopped */ bootmenu_loop (menu, &key, &esc);common/menu.c +9
-7@@ -425,9 +425,9 @@ int menu_destroy(struct menu *m)return 1 ; } -void bootmenu_autoboot_loop (struct bootmenu_data *menu, -enum bootmenu_key *key,int *esc) +enum bootmenu_key bootmenu_autoboot_loop (struct bootmenu_data *menu,int *esc) { +enum bootmenu_key key =BKEY_NONE ;int i, c;while (menu->delay >0 ) {@@ -446,16 +446,16 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,switch (c) {case '\e' : *esc =1 ; - *key =BKEY_NONE ; + key =BKEY_NONE ;break ;case '\r' : - *key =BKEY_SELECT ; + key =BKEY_SELECT ;break ;case 0x3 :/* ^C */ - *key =BKEY_QUIT ; + key =BKEY_QUIT ;break ;default : - *key =BKEY_NONE ; + key =BKEY_NONE ;break ; }@@ -471,7 +471,9 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu, printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, menu->count + 5, 1);if (menu->delay ==0 ) - *key =BKEY_SELECT ; + key =BKEY_SELECT ; + +return key; } void bootmenu_loop(struct bootmenu_data *menu,include/menu.h +0
-1@@ -65,14 +65,13 @@ enum bootmenu_key {* indicating that the current option should be chosen. * * @menu: Menu being processed -* @key: Returns the code for the key the user pressed:
include/menu.h enum bootmenu_key { · line 74
Quoted 10 lines
include/menu.h +3
-3+* @esc: Set to 1 if the escape key is pressed, otherwise not updated +* Returns: code for the key the user pressed: * enter: KEY_SELECT * Ctrl-C: KEY_QUIT * anything else: KEY_NONE -* @esc: Set to 1 if the escape key is pressed, otherwise not updated */ -void bootmenu_autoboot_loop (struct bootmenu_data *menu, -enum bootmenu_key *key,int *esc); +enum bootmenu_key bootmenu_autoboot_loop (struct bootmenu_data *menu,int *esc);
This function should not be exported.
enum bootmenu cannot accomomdate accelerator keys. The return type should be int.
Best regards
Heinrich
Quoted 3 lines
include/menu.h +0
-0/** * bootmenu_loop() - handle waiting for a keypress when autoboot is disabled
Re: [PATCH 05/24] menu: Update bootmenu_autoboot_loop() to return the code
Hi Heinrich,
Quoted 91 lines · Heinrich Schuchardt
cmd/bootmenu.c static char *bootmenu_choice_entry(void *data)
Quoted 17 lines · Simon 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]>---
cmd/bootmenu.c | 2 +- common/menu.c | 16 +++++++++------- include/menu.h | 7 +++---- 3 files changed, 13 insertions(+), 12 deletions(-)cmd/bootmenu.c +0
-0@@ -93,7 +93,7 @@ static char *bootmenu_choice_entry(void *data)First of all this function should be moved to
common/menu.c.Quoted 69 lines
cmd/bootmenu.c +1
-1while (1 ) {if (menu->delay >=0 ) {/* Autoboot was not stopped */ -bootmenu_autoboot_loop (menu, &key, &esc); + key =bootmenu_autoboot_loop (menu, &esc); }else {/* Some key was pressed, so autoboot was stopped */ bootmenu_loop (menu, &key, &esc);common/menu.c +9
-7@@ -425,9 +425,9 @@ int menu_destroy(struct menu *m)return 1 ; } -void bootmenu_autoboot_loop (struct bootmenu_data *menu, -enum bootmenu_key *key,int *esc) +enum bootmenu_key bootmenu_autoboot_loop (struct bootmenu_data *menu,int *esc) { +enum bootmenu_key key =BKEY_NONE ;int i, c;while (menu->delay >0 ) {@@ -446,16 +446,16 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu,switch (c) {case '\e' : *esc =1 ; - *key =BKEY_NONE ; + key =BKEY_NONE ;break ;case '\r' : - *key =BKEY_SELECT ; + key =BKEY_SELECT ;break ;case 0x3 :/* ^C */ - *key =BKEY_QUIT ; + key =BKEY_QUIT ;break ;default : - *key =BKEY_NONE ; + key =BKEY_NONE ;break ; }@@ -471,7 +471,9 @@ void bootmenu_autoboot_loop(struct bootmenu_data *menu, printf(ANSI_CURSOR_POSITION ANSI_CLEAR_LINE, menu->count + 5, 1);if (menu->delay ==0 ) - *key =BKEY_SELECT ; + key =BKEY_SELECT ; + +return key; } void bootmenu_loop(struct bootmenu_data *menu,include/menu.h +2
-1@@ -65,14 +65,13 @@ enum bootmenu_key {* indicating that the current option should be chosen. * * @menu: Menu being processed -* @key: Returns the code for the key the user pressed: +* @esc: Set to 1 if the escape key is pressed, otherwise not updated +* Returns: code for the key the user pressed: * enter: KEY_SELECT * Ctrl-C: KEY_QUIT
Quoted 8 lines
include/menu.h enum bootmenu_key { · line 74
Quoted 6 lines
include/menu.h +1
-3* anything else: KEY_NONE -* @esc: Set to 1 if the escape key is pressed, otherwise not updated */ -void bootmenu_autoboot_loop (struct bootmenu_data *menu, -enum bootmenu_key *key,int *esc); +enum bootmenu_key bootmenu_autoboot_loop (struct bootmenu_data *menu,int *esc);This function should not be exported.
Out of scope for this patch.
Quoted 3 lines
enum bootmenu cannot accomomdate accelerator keys. The return type should be int.
What accelerator keys? I don't see how they work at present.
Regards,
Simon
PATCH 6/24 menu: Update bootmenu_loop() to return the code
In reply to Simon GlassUse 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.
---
cmd/bootmenu.c | 2 +- cmd/eficonfig.c | 4 ++-- common/menu.c | 30 ++++++++++++++++-------------- include/menu.h | 11 +++++------ 4 files changed, 24 insertions(+), 23 deletions(-)
cmd/bootmenu.c +1 -1
@@ -96,7 +96,7 @@ static char *bootmenu_choice_entry(void *data) key =bootmenu_autoboot_loop (menu, &esc); }else {/* Some key was pressed, so autoboot was stopped */ -bootmenu_loop (menu, &key, &esc); + key =bootmenu_loop (menu, &esc); }switch (key) {
cmd/eficonfig.c +2 -2
@@ -197,7 +197,7 @@ static char *eficonfig_choice_entry(void *data)struct efimenu *efi_menu = data;while (1 ) { -bootmenu_loop ((struct bootmenu_data *)efi_menu, &key, &esc); + key =bootmenu_loop ((struct bootmenu_data *)efi_menu, &esc);switch (key) {case BKEY_UP :
@@ -1868,7 +1868,7 @@ static efi_status_t eficonfig_choice_change_boot_order(struct efimenu *efi_menu)struct eficonfig_boot_order *entry;while (1 ) { -bootmenu_loop (NULL , &key, &esc); + key =bootmenu_loop (NULL , &esc);switch (key) {case BKEY_PLUS :
common/menu.c +16 -14
@@ -476,9 +476,9 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc)return key; } -void bootmenu_loop (struct bootmenu_data *menu, -enum bootmenu_key *key,int *esc) +enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu,int *esc) { +enum bootmenu_key key =BKEY_NONE ;int c;if (*esc ==1 ) {
@@ -505,17 +505,17 @@ void bootmenu_loop(struct bootmenu_data *menu,/* First char of ANSI escape sequence '\e' */ if (c =='\e' ) { *esc =1 ; - *key =BKEY_NONE ; + key =BKEY_NONE ; }break ;case 1 :/* Second char of ANSI '[' */ if (c =='[' ) { *esc =2 ; - *key =BKEY_NONE ; + key =BKEY_NONE ; }else {/* Alone ESC key was pressed */ - *key =BKEY_QUIT ; + key =BKEY_QUIT ; *esc = (c =='\e' ) ?1 :0 ; }break ;
@@ -524,7 +524,7 @@ void bootmenu_loop(struct bootmenu_data *menu,/* Third char of ANSI (number '1') - optional */ if (*esc ==2 && c =='1' ) { *esc =3 ; - *key =BKEY_NONE ; + key =BKEY_NONE ;break ; }
@@ -532,31 +532,33 @@ void bootmenu_loop(struct bootmenu_data *menu,/* ANSI 'A' - key up was pressed */ if (c =='A' ) - *key =BKEY_UP ; + key =BKEY_UP ;/* ANSI 'B' - key down was pressed */ else if (c =='B' ) - *key =BKEY_DOWN ; + key =BKEY_DOWN ;/* other key was pressed */ else - *key =BKEY_NONE ; + key =BKEY_NONE ;break ; }/* enter key was pressed */ if (c =='\r' ) - *key =BKEY_SELECT ; + key =BKEY_SELECT ;/* ^C was pressed */ if (c ==0x3 ) - *key =BKEY_QUIT ; + key =BKEY_QUIT ;if (c =='+' ) - *key =BKEY_PLUS ; + key =BKEY_PLUS ;if (c =='-' ) - *key =BKEY_MINUS ; + key =BKEY_MINUS ;if (c ==' ' ) - *key =BKEY_SPACE ; + key =BKEY_SPACE ; + +return key; }
include/menu.h +5 -6
@@ -83,7 +83,10 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc);* character is recognised * * @menu: Menu being processed -* @key: Returns the code for the key the user pressed: +* @esc: On input, a non-zero value indicates that an escape sequence has +* resulted in that many characters so far. On exit this is updated to the +* new number of characters +* Returns: code for the key the user pressed: * enter: BKEY_SELECT * Ctrl-C: BKEY_QUIT * Up arrow: BKEY_UP
@@ -92,11 +95,7 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, int *esc);* Plus: BKEY_PLUS * Minus: BKEY_MINUS * Space: BKEY_SPACE -* @esc: On input, a non-zero value indicates that an escape sequence has -* resulted in that many characters so far. On exit this is updated to the -* new number of characters */ -void bootmenu_loop (struct bootmenu_data *menu, -enum bootmenu_key *key,int *esc); +enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu,int *esc);#endif /* __MENU_H__ */
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 7/24 menu: Use a switch statement
In reply to Simon GlassConvert the long line of if() statements to a switch() since this makes better use of the C language.
---
common/menu.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
common/menu.c +20 -11
@@ -543,22 +543,31 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc)break ; } -/* enter key was pressed */ -if (c =='\r' ) +switch (c) { +case '\r' : +/* enter key was pressed */ key =BKEY_SELECT ; - -/* ^C was pressed */ -if (c ==0x3 ) +break ; +case CTL_CH ('c' ): +/* ^C was pressed */ key =BKEY_QUIT ; - -if (c =='+' ) +break ; +case CTL_CH ('p' ): + key =BKEY_UP ; +break ; +case CTL_CH ('n' ): + key =BKEY_DOWN ; +break ; +case '+' : key =BKEY_PLUS ; - -if (c =='-' ) +break ; +case '-' : key =BKEY_MINUS ; - -if (c ==' ' ) +break ; +case ' ' : key =BKEY_SPACE ; +break ; + }return key; }
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 07/24] menu: Use a switch statement
Quoted 43 lines · Simon Glass
Convert the long line of
if()statements to aswitch()since this makes better use of the C language.Signed-off-by Simon Glass <[email protected]>---
common/menu.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)common/menu.c +14
-9@@ -543,22 +543,31 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc)break ; } -/* enter key was pressed */ -if (c =='\r' ) +switch (c) { +case '\r' : +/* enter key was pressed */ key =BKEY_SELECT ; - -/* ^C was pressed */ -if (c ==0x3 ) +break ; +case CTL_CH ('c' ): +/* ^C was pressed */ key =BKEY_QUIT ; - -if (c =='+' ) +break ; +case CTL_CH ('p' ): + key =BKEY_UP ; +break ; +case CTL_CH ('n' ): + key =BKEY_DOWN ; +break ; +case '+' : key =BKEY_PLUS ; - -if (c =='-' )
common/menu.c enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc) · line 570
Quoted 10 lines
common/menu.c +6
-2+break ; +case '-' : key =BKEY_MINUS ; - -if (c ==' ' ) +break ; +case ' ' : key =BKEY_SPACE ; +break ; + }
The whole code is not well suited to parse all of the many different escape sequences that can be sent to convey modifier keys or non-character keys (think of <CTRL><ALT><F12> or <HOME>).
We should move the of logic of efi_cin_read_key_stroke_ex() to a library function which is used both by bootmenu and UEFI and remove duplicate code.
Best regards
Heinrich
Quoted 3 lines
common/menu.c +0
-0return key; }
Re: [PATCH 07/24] menu: Use a switch statement
Hi Heinrich,
Quoted 60 lines · Heinrich Schuchardt
Quoted 43 lines · Simon Glass
Convert the long line of
if()statements to aswitch()since this makes better use of the C language.Signed-off-by Simon Glass <[email protected]>---
common/menu.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)common/menu.c +14
-9@@ -543,22 +543,31 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc)break ; } -/* enter key was pressed */ -if (c =='\r' ) +switch (c) { +case '\r' : +/* enter key was pressed */ key =BKEY_SELECT ; - -/* ^C was pressed */ -if (c ==0x3 ) +break ; +case CTL_CH ('c' ): +/* ^C was pressed */ key =BKEY_QUIT ; - -if (c =='+' ) +break ; +case CTL_CH ('p' ): + key =BKEY_UP ; +break ; +case CTL_CH ('n' ): + key =BKEY_DOWN ; +break ; +case '+' : key =BKEY_PLUS ; - -if (c =='-' )common/menu.c enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu, int *esc) · line 570
Quoted 10 lines
common/menu.c +6
-2+break ; +case '-' : key =BKEY_MINUS ; - -if (c ==' ' ) +break ; +case ' ' : key =BKEY_SPACE ; +break ; + }The whole code is not well suited to parse all of the many different escape sequences that can be sent to convey modifier keys or non-character keys (think of <CTRL><ALT><F12> or <HOME>).
Quoted 2 lines
We should move the of logic of
efi_cin_read_key_stroke_ex()to a library function which is used both by bootmenu and UEFI and remove duplicate code.
Sorry I am not about to put effort into the EFI code :-)
Also I did create a library to handle keystrokes. See cli_getch.c
Regards,
Simon
PATCH 9/24 image: Add a function to find a script in an image
In reply to Simon GlassSplit this functionality out of the 'source' command so it can be used from another place.
---
cmd/source.c | 173 ++++++++++++++++++++++++++---------------------- include/image.h | 13 ++++ 2 files changed, 107 insertions(+), 79 deletions(-)
cmd/source.c +94 -79
@@ -24,7 +24,6 @@#include <asm/byteorder.h> #include <asm/io.h> -#if defined(CONFIG_FIT )/** * get_default_image() - Return default property from /images *
@@ -40,123 +39,139 @@ static const char *get_default_image(const void *fit)return fdt_getprop (fit, images_noffset,FIT_DEFAULT_PROP ,NULL ); } -#endif -int image_source_script (ulong addr,const char *fit_uname) +int image_locate_script (void *buf,int size,const char *fit_uname, +char **datap,uint *lenp) {ulong len; -#if defined(CONFIG_LEGACY_IMAGE_FORMAT )const struct legacy_img_hdr *hdr; -#endif u32 *data;int verify; -void *buf; -#if defined(CONFIG_FIT )const void * fit_hdr;int noffset;const void *fit_data;size_t fit_len; -#endif verify =env_get_yesno ("verify" ); - buf =map_sysmem (addr,0 );switch (genimg_get_format (buf)) { -#if defined(CONFIG_LEGACY_IMAGE_FORMAT )case IMAGE_FORMAT_LEGACY : - hdr = buf; +if (IS_ENABLED (CONFIG_LEGACY_IMAGE_FORMAT )) { + hdr = buf; -if (!image_check_magic (hdr)) { -puts ("Bad magic number\n" ); -return 1 ; - } +if (!image_check_magic (hdr)) { +puts ("Bad magic number\n" ); +return 1 ; + } -if (!image_check_hcrc (hdr)) { -puts ("Bad header crc\n" ); -return 1 ; - } +if (!image_check_hcrc (hdr)) { +puts ("Bad header crc\n" ); +return 1 ; + } + +if (verify) { +if (!image_check_dcrc (hdr)) { +puts ("Bad data crc\n" ); +return 1 ; + } + } -if (verify) { -if (!image_check_dcrc (hdr)) { -puts ("Bad data crc\n" ); +if (!image_check_type (hdr,IH_TYPE_SCRIPT )) { +puts ("Bad image type\n" );return 1 ; } - } -if (!image_check_type (hdr,IH_TYPE_SCRIPT )) { -puts ("Bad image type\n" ); -return 1 ; - } +/* get length of script */ + data = (u32 *)image_get_data (hdr); -/* get length of script */ - data = (u32 *)image_get_data (hdr); + len =uimage_to_cpu (*data); +if (!len) { +puts ("Empty Script\n" ); +return 1 ; + } -if ((len =uimage_to_cpu (*data)) ==0 ) { -puts ("Empty Script\n" ); -return 1 ; +/* +* scripts are just multi-image files with one +* component, so seek past the zero-terminated sequence +* of image lengths to get to the actual image data +*/ +while (*data++); } - -/* -* scripts are just multi-image files with one component, seek -* past the zero-terminated sequence of image lengths to get -* to the actual image data -*/ -while (*data++);break ; -#endif -#if defined(CONFIG_FIT )case IMAGE_FORMAT_FIT : - fit_hdr = buf; -if (fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) { -puts ("Bad FIT image format\n" ); -return 1 ; - } +if (IS_ENABLED (CONFIG_FIT )) { + fit_hdr = buf; +if (fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) { +puts ("Bad FIT image format\n" ); +return 1 ; + } -if (!fit_uname) - fit_uname =get_default_image (fit_hdr); +if (!fit_uname) + fit_uname =get_default_image (fit_hdr); -if (!fit_uname) { -puts ("No FIT subimage unit name\n" ); -return 1 ; - } +if (!fit_uname) { +puts ("No FIT subimage unit name\n" ); +return 1 ; + } -/* get script component image node offset */ - noffset =fit_image_get_node (fit_hdr, fit_uname); -if (noffset <0 ) { -printf ("Can't find '%s' FIT subimage\n" , fit_uname); -return 1 ; - } +/* get script component image node offset */ + noffset =fit_image_get_node (fit_hdr, fit_uname); +if (noffset <0 ) { +printf ("Can't find '%s' FIT subimage\n" , + fit_uname); +return 1 ; + } -if (!fit_image_check_type (fit_hdr, noffset,IH_TYPE_SCRIPT )) { -puts ("Not a image image\n" ); -return 1 ; - } +if (!fit_image_check_type (fit_hdr, noffset, +IH_TYPE_SCRIPT )) { +puts ("Not a image image\n" ); +return 1 ; + } + +/* verify integrity */ +if (verify) { +if (!fit_image_verify (fit_hdr, noffset)) { +puts ("Bad Data Hash\n" ); +return 1 ; + } + } -/* verify integrity */ -if (verify) { -if (!fit_image_verify (fit_hdr, noffset)) { -puts ("Bad Data Hash\n" ); +/* get script subimage data address and length */ +if (fit_image_get_data (fit_hdr, noffset, &fit_data, &fit_len)) { +puts ("Could not find script subimage data\n" );return 1 ; } - } -/* get script subimage data address and length */ -if (fit_image_get_data (fit_hdr, noffset, &fit_data, &fit_len)) { -puts ("Could not find script subimage data\n" ); -return 1 ; + data = (u32 *)fit_data; + len = (ulong )fit_len; } - - data = (u32 *)fit_data; - len = (ulong )fit_len;break ; -#endif default : -puts ("Wrong image format for \"source\" command\n" ); -return 1 ; +puts ("Wrong image format for \"source\" command\n" ); +return -EPERM ; } -debug ("** Script length: %ld\n" , len); -return run_command_list ((char *)data, len,0 ); + *datap = (char *)data; + *lenp = len; + +return 0 ; +} + +int image_source_script (ulong addr,const char *fit_uname) +{ +char *data; +void *buf; +uint len; +int ret; + + buf =map_sysmem (addr,0 ); + ret =image_locate_script (buf,0 , fit_uname, &data, &len); +unmap_sysmem (buf); +if (ret) +return CMD_RET_FAILURE ; + +debug ("** Script length: %d\n" , len); +return run_command_list (data, len,0 ); }/**************************************************/
include/image.h +13 -0
@@ -720,6 +720,19 @@ int fit_image_load(struct bootm_headers *images, ulong addr,*/ int image_source_script (ulong addr,const char *fit_uname); +/** +* image_locate_script() - Locate the raw script in an image +* +* @buf: Address of image +* @size: Size of image in bytes +* @fit_uname: Node name of FIT image to read +* @datap: Returns pointer to raw script on success +* @lenp: Returns size of raw script on success +* @return 0 if OK, non-zero on error +*/ +int image_locate_script (void *buf,int size,const char *fit_uname, +char **datap,uint *lenp); +/** * fit_get_node_from_config() - Look up an image a FIT by type *
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 09/24] image: Add a function to find a script in an image
Quoted 2 lines · Simon Glass
Split this functionality out of the 'source' command so it can be used from another place.
It is not obvious how this relates to changing the series.
Please, provide a description of the future use of the extracted library function.
Quoted 6 lines
Signed-off-by Simon Glass <[email protected]>---
cmd/source.c | 173 ++++++++++++++++++++++++++---------------------- include/image.h | 13 ++++
If you extract a library function, it should not live in cmd/source.c.
Best regards
Heinrich
Quoted 256 lines
2 files changed, 107 insertions(+), 79 deletions(-)cmd/source.c +94
-79@@ -24,7 +24,6 @@#include <asm/byteorder.h> #include <asm/io.h> -#if defined(CONFIG_FIT )/** * get_default_image() - Return default property from /images * @@ -40,123 +39,139 @@ static const char *get_default_image(const void *fit)return fdt_getprop (fit, images_noffset,FIT_DEFAULT_PROP ,NULL ); } -#endif -int image_source_script (ulong addr,const char *fit_uname) +int image_locate_script (void *buf,int size,const char *fit_uname, +char **datap,uint *lenp) {ulong len; -#if defined(CONFIG_LEGACY_IMAGE_FORMAT )const struct legacy_img_hdr *hdr; -#endif u32 *data;int verify; -void *buf; -#if defined(CONFIG_FIT )const void * fit_hdr;int noffset;const void *fit_data;size_t fit_len; -#endif verify =env_get_yesno ("verify" ); - buf =map_sysmem (addr,0 );switch (genimg_get_format (buf)) { -#if defined(CONFIG_LEGACY_IMAGE_FORMAT )case IMAGE_FORMAT_LEGACY : - hdr = buf; +if (IS_ENABLED (CONFIG_LEGACY_IMAGE_FORMAT )) { + hdr = buf; -if (!image_check_magic (hdr)) { -puts ("Bad magic number\n" ); -return 1 ; - } +if (!image_check_magic (hdr)) { +puts ("Bad magic number\n" ); +return 1 ; + } -if (!image_check_hcrc (hdr)) { -puts ("Bad header crc\n" ); -return 1 ; - } +if (!image_check_hcrc (hdr)) { +puts ("Bad header crc\n" ); +return 1 ; + } + +if (verify) { +if (!image_check_dcrc (hdr)) { +puts ("Bad data crc\n" ); +return 1 ; + } + } -if (verify) { -if (!image_check_dcrc (hdr)) { -puts ("Bad data crc\n" ); +if (!image_check_type (hdr,IH_TYPE_SCRIPT )) { +puts ("Bad image type\n" );return 1 ; } - } -if (!image_check_type (hdr,IH_TYPE_SCRIPT )) { -puts ("Bad image type\n" ); -return 1 ; - } +/* get length of script */ + data = (u32 *)image_get_data (hdr); -/* get length of script */ - data = (u32 *)image_get_data (hdr); + len =uimage_to_cpu (*data); +if (!len) { +puts ("Empty Script\n" ); +return 1 ; + } -if ((len =uimage_to_cpu (*data)) ==0 ) { -puts ("Empty Script\n" ); -return 1 ; +/* +* scripts are just multi-image files with one +* component, so seek past the zero-terminated sequence +* of image lengths to get to the actual image data +*/ +while (*data++); } - -/* -* scripts are just multi-image files with one component, seek -* past the zero-terminated sequence of image lengths to get -* to the actual image data -*/ -while (*data++);break ; -#endif -#if defined(CONFIG_FIT )case IMAGE_FORMAT_FIT : - fit_hdr = buf; -if (fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) { -puts ("Bad FIT image format\n" ); -return 1 ; - } +if (IS_ENABLED (CONFIG_FIT )) { + fit_hdr = buf; +if (fit_check_format (fit_hdr,IMAGE_SIZE_INVAL )) { +puts ("Bad FIT image format\n" ); +return 1 ; + } -if (!fit_uname) - fit_uname =get_default_image (fit_hdr); +if (!fit_uname) + fit_uname =get_default_image (fit_hdr); -if (!fit_uname) { -puts ("No FIT subimage unit name\n" ); -return 1 ; - } +if (!fit_uname) { +puts ("No FIT subimage unit name\n" ); +return 1 ; + } -/* get script component image node offset */ - noffset =fit_image_get_node (fit_hdr, fit_uname); -if (noffset <0 ) { -printf ("Can't find '%s' FIT subimage\n" , fit_uname); -return 1 ; - } +/* get script component image node offset */ + noffset =fit_image_get_node (fit_hdr, fit_uname); +if (noffset <0 ) { +printf ("Can't find '%s' FIT subimage\n" , + fit_uname); +return 1 ; + } -if (!fit_image_check_type (fit_hdr, noffset,IH_TYPE_SCRIPT )) { -puts ("Not a image image\n" ); -return 1 ; - } +if (!fit_image_check_type (fit_hdr, noffset, +IH_TYPE_SCRIPT )) { +puts ("Not a image image\n" ); +return 1 ; + } + +/* verify integrity */ +if (verify) { +if (!fit_image_verify (fit_hdr, noffset)) { +puts ("Bad Data Hash\n" ); +return 1 ; + } + } -/* verify integrity */ -if (verify) { -if (!fit_image_verify (fit_hdr, noffset)) { -puts ("Bad Data Hash\n" ); +/* get script subimage data address and length */ +if (fit_image_get_data (fit_hdr, noffset, &fit_data, &fit_len)) { +puts ("Could not find script subimage data\n" );return 1 ; } - } -/* get script subimage data address and length */ -if (fit_image_get_data (fit_hdr, noffset, &fit_data, &fit_len)) { -puts ("Could not find script subimage data\n" ); -return 1 ; + data = (u32 *)fit_data; + len = (ulong )fit_len; } - - data = (u32 *)fit_data; - len = (ulong )fit_len;break ; -#endif default : -puts ("Wrong image format for \"source\" command\n" ); -return 1 ; +puts ("Wrong image format for \"source\" command\n" ); +return -EPERM ; } -debug ("** Script length: %ld\n" , len); -return run_command_list ((char *)data, len,0 ); + *datap = (char *)data; + *lenp = len; + +return 0 ; +} + +int image_source_script (ulong addr,const char *fit_uname) +{ +char *data; +void *buf; +uint len; +int ret; + + buf =map_sysmem (addr,0 ); + ret =image_locate_script (buf,0 , fit_uname, &data, &len); +unmap_sysmem (buf); +if (ret) +return CMD_RET_FAILURE ; + +debug ("** Script length: %d\n" , len); +return run_command_list (data, len,0 ); }/**************************************************/ include/image.h +13
-0@@ -720,6 +720,19 @@ int fit_image_load(struct bootm_headers *images, ulong addr,*/ int image_source_script (ulong addr,const char *fit_uname); +/** +* image_locate_script() - Locate the raw script in an image +* +* @buf: Address of image +* @size: Size of image in bytes +* @fit_uname: Node name of FIT image to read +* @datap: Returns pointer to raw script on success +* @lenp: Returns size of raw script on success +* @return 0 if OK, non-zero on error +*/ +int image_locate_script (void *buf,int size,const char *fit_uname, +char **datap,uint *lenp); +/** * fit_get_node_from_config() - Look up an image a FIT by type *
Re: [PATCH 09/24] image: Add a function to find a script in an image
Hi Heinrich,
Quoted 11 lines · Heinrich Schuchardt
Quoted 2 lines · Simon Glass
Split this functionality out of the 'source' command so it can be used from another place.
It is not obvious how this relates to changing the series.
Please, provide a description of the future use of the extracted library function.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Signed-off-by Simon Glass <[email protected]>---
cmd/source.c | 173 ++++++++++++++++++++++++++---------------------- include/image.h | 13 ++++If you extract a library function, it should not live in
cmd/source.c.
I can put it in boot/image*.c perhaps.
Regards,
Simon
PATCH 10/24 video: Enable VIDEO_ANSI by default only with EFI
In reply to Simon GlassThis is not generally needed unless EFI_LOADER is used. Adjust the default setting to reduce the size of the U-Boot build.
---
drivers/video/Kconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/video/Kconfig +5 -2
@@ -118,10 +118,13 @@ config VIDEO_BPP32 config VIDEO_ANSI bool "Support ANSI escape sequences in video console" depends on DM_VIDEO - default y + default y if EFI_LOADER help Enable ANSI escape sequence decoding for a more fully functional - console. + console. Functionality includes changing the text colour and moving + the cursor. These date from the 1970s and are still widely used today + to control a text terminal. U-Boot implements these by decoding the + sequences and performing the appropriate operation. config VIDEO_MIPI_DSI bool "Support MIPI DSI interface"
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 10/24] video: Enable VIDEO_ANSI by default only with EFI
Quoted 14 lines · Simon Glass
This is not generally needed unless
EFI_LOADERis used. Adjust the default setting to reduce the size of the U-Boot build.Signed-off-by Simon Glass <[email protected]>---
drivers/video/Kconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/video/Kconfig +0
-0
drivers/video/Kconfig config VIDEO_BPP32 · line 121
Quoted 5 lines
drivers/video/Kconfig +1
-1@@ -118,10 +118,13 @@ config VIDEO_BPP32 config VIDEO_ANSI bool "Support ANSI escape sequences in video console" depends on DM_VIDEO - default y + default y if EFI_LOADER
This will cripple the CLS command.
Best regards
Heinrich
Quoted 10 lines
drivers/video/Kconfig +4
-1help Enable ANSI escape sequence decoding for a more fully functional - console. + console. Functionality includes changing the text colour and moving + the cursor. These date from the 1970s and are still widely used today + to control a text terminal. U-Boot implements these by decoding the + sequences and performing the appropriate operation. config VIDEO_MIPI_DSI bool "Support MIPI DSI interface"
Re: [PATCH 10/24] video: Enable VIDEO_ANSI by default only with EFI
Hi Heinrich,
Quoted 11 lines · Heinrich Schuchardt
Quoted 9 lines · Simon Glass
This is not generally needed unless
EFI_LOADERis used. Adjust the default setting to reduce the size of the U-Boot build.Signed-off-by Simon Glass <[email protected]>---
drivers/video/Kconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 12 lines
drivers/video/Kconfig config VIDEO_BPP32 · line 121
Quoted 10 lines
drivers/video/Kconfig +1
-1@@ -118,10 +118,13 @@ config VIDEO_BPP32 config VIDEO_ANSI bool "Support ANSI escape sequences in video console" depends on DM_VIDEO - default y + default y if EFI_LOADERThis will cripple the CLS command.
I can add that as a dependency.
I actually don't like using cls as it makes debugging hard. You can't see the previous output on the terminal!
Regards,
Simon
PATCH 12/24 video: Fix unchnaged typo
In reply to Simon GlassFix this typo in the header file.
---
include/video.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/video.h +1 -1
@@ -248,7 +248,7 @@ void video_bmp_get_info(void *bmp_image, ulong *widthp, ulong *heightp,* that direction * - if a coordinate is -ve then it will be offset to the * left/top of the centre by that many pixels -* - if a coordinate is positive it will be used unchnaged. +* - if a coordinate is positive it will be used unchanged. * Return: 0 if OK, -ve on error */ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 12/24] video: Fix unchnaged typo
Quoted 3 lines · Simon Glass
Fix this typo in the header file.
Signed-off-by Simon Glass <[email protected]>
Quoted 18 lines
---
include/video.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/video.h +1
-1@@ -248,7 +248,7 @@ void video_bmp_get_info(void *bmp_image, ulong *widthp, ulong *heightp,* that direction * - if a coordinate is -ve then it will be offset to the * left/top of the centre by that many pixels -* - if a coordinate is positive it will be used unchnaged. +* - if a coordinate is positive it will be used unchanged. * Return: 0 if OK, -ve on error */ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
PATCH 14/24 bootstd: Read the Operating System name for distro/scripts
In reply to Simon GlassAdd the concept of an OS name to the bootflow. This typically includes the OS name, version and kernel version.
Implement this for the distro and script bootmeths so that it works with Armbian and older version of Fedora.
---
boot/bootflow.c | 1 + boot/bootmeth_distro.c | 36 ++++++++++++++++++++++++++++++++++++ boot/bootmeth_script.c | 34 ++++++++++++++++++++++++++++++++++ cmd/bootflow.c | 1 + include/bootflow.h | 3 +++ test/boot/bootflow.c | 1 + 6 files changed, 76 insertions(+)
boot/bootflow.c +1 -0
@@ -354,6 +354,7 @@ void bootflow_free(struct bootflow *bflow)free (bflow->subdir);free (bflow->fname);free (bflow->buf); +free (bflow->os_name); }void bootflow_remove (struct bootflow *bflow)
boot/bootmeth_distro.c +36 -0
@@ -66,6 +66,38 @@ static int distro_check(struct udevice *dev, struct bootflow_iter *iter)return 0 ; } +/** +* distro_fill_info() - Decode the extlinux file to find out distro info +* +* @bflow: Bootflow to process +* @return 0 if OK, -ve on error +*/ +static int distro_fill_info (struct bootflow *bflow) +{ +struct membuff mb; +char line[200 ]; +char *data; +int len; + +log_debug ("parsing bflow file size %x\n" , bflow->size); +membuff_init (&mb, bflow->buf, bflow->size); +membuff_putraw (&mb, bflow->size, true, &data); +while (len =membuff_readline (&mb, line,sizeof (line) -1 ,' ' ), len) { +char *tok, *p = line; + + tok =strsep (&p," " ); +if (p) { +if (!strcmp ("label" , tok)) { + bflow->os_name =strdup (p); +if (!bflow->os_name) +return log_msg_ret ("os" , -ENOMEM ); + } + } + } + +return 0 ; +} +static int distro_read_bootflow (struct udevice *dev,struct bootflow *bflow) {struct blk_desc *desc;
@@ -99,6 +131,10 @@ static int distro_read_bootflow(struct udevice *dev, struct bootflow *bflow)if (ret)return log_msg_ret ("read" , ret); + ret =distro_fill_info (bflow); +if (ret) +return log_msg_ret ("inf" , ret); +return 0 ; }
boot/bootmeth_script.c +34 -0
@@ -35,6 +35,36 @@ static int script_check(struct udevice *dev, struct bootflow_iter *iter)return 0 ; } +/** +* script_fill_info() - Decode the U-Boot script to find out distro info +* +* @bflow: Bootflow to process +* @return 0 if OK, -ve on error +*/ +static int script_fill_info (struct bootflow *bflow) +{ +char *name =NULL ; +char *data; +uint len; +int ret; + +log_debug ("parsing bflow file size %x\n" , bflow->size); + + ret =image_locate_script (bflow->buf, bflow->size,NULL , &data, &len); +if (!ret) { +if (strstr (data,"armbianEnv" )) + name ="Armbian" ; + } + +if (name) { + bflow->os_name =strdup (name); +if (!bflow->os_name) +return log_msg_ret ("os" , -ENOMEM ); + } + +return 0 ; +} +static int script_read_bootflow (struct udevice *dev,struct bootflow *bflow) {struct blk_desc *desc =NULL ;
@@ -75,6 +105,10 @@ static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow)if (ret)return log_msg_ret ("read" , ret); + ret =script_fill_info (bflow); +if (ret) +return log_msg_ret ("inf" , ret); +return 0 ; }
cmd/bootflow.c +1 -0
@@ -337,6 +337,7 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,printf ("Filename: %s\n" , bflow->fname);printf ("Buffer: %lx\n" , (ulong )map_to_sysmem (bflow->buf));printf ("Size: %x (%d bytes)\n" , bflow->size, bflow->size); +printf ("OS: %s\n" , bflow->os_name ? bflow->os_name :"(none)" );printf ("Error: %d\n" , bflow->err);if (dump && bflow->buf) {/* Set some sort of maximum on the size */
include/bootflow.h +3 -0
@@ -52,6 +52,8 @@ enum bootflow_state_t {* @buf: Bootflow file contents (allocated) * @size: Size of bootflow file in bytes * @err: Error number received (0 if OK) +* @os_name: Name of the OS / distro being booted, or NULL if not known +* (allocated) */ struct bootflow {struct list_head bm_node;
@@ -68,6 +70,7 @@ struct bootflow {char *buf;int size;int err; +char *os_name; };/**
test/boot/bootflow.c +1 -0
@@ -188,6 +188,7 @@ static int bootflow_cmd_info(struct unit_test_state *uts)ut_assert_nextline ("Filename: /extlinux/extlinux.conf" );ut_assert_nextlinen ("Buffer: " );ut_assert_nextline ("Size: 253 (595 bytes)" ); +ut_assert_nextline ("OS: Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)" );ut_assert_nextline ("Error: 0" );ut_assert_console_end ();
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 14/24] bootstd: Read the Operating System name for distro/scripts
Quoted 5 lines · Simon Glass
Add the concept of an OS name to the bootflow. This typically includes the OS name, version and kernel version.
Implement this for the distro and script bootmeths so that it works with Armbian and older version of Fedora.
How do you plan to detect the distro?
Best regards
Heinrich
Quoted 175 lines
Signed-off-by Simon Glass <[email protected]>---
boot/bootflow.c | 1 + boot/bootmeth_distro.c | 36 ++++++++++++++++++++++++++++++++++++ boot/bootmeth_script.c | 34 ++++++++++++++++++++++++++++++++++ cmd/bootflow.c | 1 + include/bootflow.h | 3 +++ test/boot/bootflow.c | 1 + 6 files changed, 76 insertions(+)boot/bootflow.c +1
-0@@ -354,6 +354,7 @@ void bootflow_free(struct bootflow *bflow)free (bflow->subdir);free (bflow->fname);free (bflow->buf); +free (bflow->os_name); }void bootflow_remove (struct bootflow *bflow)boot/bootmeth_distro.c +36
-0@@ -66,6 +66,38 @@ static int distro_check(struct udevice *dev, struct bootflow_iter *iter)return 0 ; } +/** +* distro_fill_info() - Decode the extlinux file to find out distro info +* +* @bflow: Bootflow to process +* @return 0 if OK, -ve on error +*/ +static int distro_fill_info (struct bootflow *bflow) +{ +struct membuff mb; +char line[200 ]; +char *data; +int len; + +log_debug ("parsing bflow file size %x\n" , bflow->size); +membuff_init (&mb, bflow->buf, bflow->size); +membuff_putraw (&mb, bflow->size, true, &data); +while (len =membuff_readline (&mb, line,sizeof (line) -1 ,' ' ), len) { +char *tok, *p = line; + + tok =strsep (&p," " ); +if (p) { +if (!strcmp ("label" , tok)) { + bflow->os_name =strdup (p); +if (!bflow->os_name) +return log_msg_ret ("os" , -ENOMEM ); + } + } + } + +return 0 ; +} +static int distro_read_bootflow (struct udevice *dev,struct bootflow *bflow) {struct blk_desc *desc;@@ -99,6 +131,10 @@ static int distro_read_bootflow(struct udevice *dev, struct bootflow *bflow)if (ret)return log_msg_ret ("read" , ret); + ret =distro_fill_info (bflow); +if (ret) +return log_msg_ret ("inf" , ret); +return 0 ; }boot/bootmeth_script.c +34
-0@@ -35,6 +35,36 @@ static int script_check(struct udevice *dev, struct bootflow_iter *iter)return 0 ; } +/** +* script_fill_info() - Decode the U-Boot script to find out distro info +* +* @bflow: Bootflow to process +* @return 0 if OK, -ve on error +*/ +static int script_fill_info (struct bootflow *bflow) +{ +char *name =NULL ; +char *data; +uint len; +int ret; + +log_debug ("parsing bflow file size %x\n" , bflow->size); + + ret =image_locate_script (bflow->buf, bflow->size,NULL , &data, &len); +if (!ret) { +if (strstr (data,"armbianEnv" )) + name ="Armbian" ; + } + +if (name) { + bflow->os_name =strdup (name); +if (!bflow->os_name) +return log_msg_ret ("os" , -ENOMEM ); + } + +return 0 ; +} +static int script_read_bootflow (struct udevice *dev,struct bootflow *bflow) {struct blk_desc *desc =NULL ;@@ -75,6 +105,10 @@ static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow)if (ret)return log_msg_ret ("read" , ret); + ret =script_fill_info (bflow); +if (ret) +return log_msg_ret ("inf" , ret); +return 0 ; }cmd/bootflow.c +1
-0@@ -337,6 +337,7 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,printf ("Filename: %s\n" , bflow->fname);printf ("Buffer: %lx\n" , (ulong )map_to_sysmem (bflow->buf));printf ("Size: %x (%d bytes)\n" , bflow->size, bflow->size); +printf ("OS: %s\n" , bflow->os_name ? bflow->os_name :"(none)" );printf ("Error: %d\n" , bflow->err);if (dump && bflow->buf) {/* Set some sort of maximum on the size */ include/bootflow.h +3
-0@@ -52,6 +52,8 @@ enum bootflow_state_t {* @buf: Bootflow file contents (allocated) * @size: Size of bootflow file in bytes * @err: Error number received (0 if OK) +* @os_name: Name of the OS / distro being booted, or NULL if not known +* (allocated) */ struct bootflow {struct list_head bm_node;@@ -68,6 +70,7 @@ struct bootflow {char *buf;int size;int err; +char *os_name; };/** test/boot/bootflow.c +1
-0@@ -188,6 +188,7 @@ static int bootflow_cmd_info(struct unit_test_state *uts)ut_assert_nextline ("Filename: /extlinux/extlinux.conf" );ut_assert_nextlinen ("Buffer: " );ut_assert_nextline ("Size: 253 (595 bytes)" ); +ut_assert_nextline ("OS: Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)" );ut_assert_nextline ("Error: 0" );ut_assert_console_end ();
Re: [PATCH 14/24] bootstd: Read the Operating System name for distro/scripts
Hi Heinrich,
Quoted 9 lines · Heinrich Schuchardt
Quoted 5 lines · Simon Glass
Add the concept of an OS name to the bootflow. This typically includes the OS name, version and kernel version.
Implement this for the distro and script bootmeths so that it works with Armbian and older version of Fedora.
How do you plan to detect the distro?
Just by reading the information it provides. For Armbian you can tell from the script. For Fedora there is a name in the boot file.
I hope we can standardise this at some point.
Regards,
Simon
PATCH 15/24 bootstd: Allow reading a logo for the OS
In reply to Simon GlassSome operating systems provide a logo in bmp format. Read this in if present so it can be displayed in the menu.
---
boot/bootmeth-uclass.c | 69 ++++++++++++++++++++++++++++++++++++------ boot/bootmeth_script.c | 4 +++ cmd/bootflow.c | 6 ++++ include/bootflow.h | 4 +++ include/bootmeth.h | 16 ++++++++++ test/boot/bootflow.c | 1 + 6 files changed, 91 insertions(+), 9 deletions(-)
boot/bootmeth-uclass.c +60 -9
@@ -290,25 +290,19 @@ int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc,return 0 ; } -int bootmeth_alloc_file (struct bootflow *bflow,uint size_limit,uint align) +static int alloc_file (const char *fname,uint size,void **bufp) {loff_t bytes_read;ulong addr;char *buf; -uint size;int ret; - size = bflow->size; -log_debug (" - script file size %x\n" , size); -if (size > size_limit) -return log_msg_ret ("chk" , -E2BIG ); - - buf =memalign (align, size +1 ); + buf =malloc (size +1 );if (!buf)return log_msg_ret ("buf" , -ENOMEM ); addr =map_to_sysmem (buf); - ret =fs_read (bflow->fname, addr,0 ,0 , &bytes_read); + ret =fs_read (fname, addr,0 , size, &bytes_read);if (ret) {free (buf);return log_msg_ret ("read" , ret);
@@ -316,12 +310,69 @@ int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align)if (size != bytes_read)return log_msg_ret ("bread" , -EINVAL ); buf[size] ='\0' ; + + *bufp = buf; + +return 0 ; +} + +int bootmeth_alloc_file (struct bootflow *bflow,uint size_limit,uint align) +{ +void *buf; +uint size; +int ret; + + size = bflow->size; +log_debug (" - script file size %x\n" , size); +if (size > size_limit) +return log_msg_ret ("chk" , -E2BIG ); + + ret =alloc_file (bflow->fname, bflow->size, &buf); +if (ret) +return log_msg_ret ("all" , ret); + bflow->state =BOOTFLOWST_READY ; bflow->buf = buf;return 0 ; } +int bootmeth_alloc_other (struct bootflow *bflow,const char *fname, +void **bufp,uint *sizep) +{ +struct blk_desc *desc =NULL ; +char path[200 ]; +loff_t size; +void *buf; +int ret; + +snprintf (path,sizeof (path),"%s%s" , bflow->subdir, fname); +log_debug ("trying: %s\n" , path); + +if (bflow->blk) + desc =dev_get_uclass_plat (bflow->blk); + + ret =setup_fs (bflow, desc); +if (ret) +return log_msg_ret ("fs" , ret); + + ret =fs_size (path, &size); +log_debug (" %s - err=%d\n" , path, ret); + + ret =setup_fs (bflow, desc); +if (ret) +return log_msg_ret ("fs" , ret); + + ret =alloc_file (path, size, &buf); +if (ret) +return log_msg_ret ("all" , ret); + + *bufp = buf; + *sizep = size; + +return 0 ; +} +int bootmeth_common_read_file (struct udevice *dev,struct bootflow *bflow,const char *file_path,ulong addr,ulong *sizep) {
boot/bootmeth_script.c +4 -0
@@ -109,6 +109,10 @@ static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow)if (ret)return log_msg_ret ("inf" , ret); + ret =bootmeth_alloc_other (bflow,"boot.bmp" , &bflow->logo, + &bflow->logo_size); +/* ignore error */ +return 0 ; }
cmd/bootflow.c +6 -0
@@ -338,6 +338,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,printf ("Buffer: %lx\n" , (ulong )map_to_sysmem (bflow->buf));printf ("Size: %x (%d bytes)\n" , bflow->size, bflow->size);printf ("OS: %s\n" , bflow->os_name ? bflow->os_name :"(none)" ); +printf ("Logo: %s\n" , bflow->logo ? +simple_xtoa ((ulong )map_to_sysmem (bflow->logo)) :"(none)" ); +if (bflow->logo) { +printf ("Logo size: %x (%d bytes)\n" , bflow->logo_size, + bflow->logo_size); + }printf ("Error: %d\n" , bflow->err);if (dump && bflow->buf) {/* Set some sort of maximum on the size */
include/bootflow.h +4 -0
@@ -49,6 +49,8 @@ enum bootflow_state_t {* @state: Current state (enum bootflow_state_t) * @subdir: Subdirectory to fetch files from (with trailing /), or NULL if none * @fname: Filename of bootflow file (allocated) +* @logo: Logo to display for this bootflow (BMP format) +* @logo_size: Size of the logo in bytes * @buf: Bootflow file contents (allocated) * @size: Size of bootflow file in bytes * @err: Error number received (0 if OK)
@@ -67,6 +69,8 @@ struct bootflow {enum bootflow_state_t state;char *subdir;char *fname; +void *logo; +uint logo_size;char *buf;int size;int err;
include/bootmeth.h +16 -0
@@ -265,6 +265,22 @@ int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc,*/ int bootmeth_alloc_file (struct bootflow *bflow,uint size_limit,uint align); +/** +* bootmeth_alloc_other() - Allocate and read a file for a bootflow +* +* This reads an arbitrary file in the same directory as the bootflow, +* allocating memory for it. The buffer is one byte larger than the file length, +* so that it can be nul-terminated. +* +* @bflow: Information about file to read +* @fname: Filename to read from (within bootflow->subdir) +* @bufp: Returns a pointer to the allocated buffer +* @sizep: Returns the size of the buffer +* Return: 0 if OK, -ENOMEM if out of memory, other -ve on other error +*/ +int bootmeth_alloc_other (struct bootflow *bflow,const char *fname, +void **bufp,uint *sizep); +/** * bootmeth_common_read_file() - Common handler for reading a file *
test/boot/bootflow.c +1 -0
@@ -189,6 +189,7 @@ static int bootflow_cmd_info(struct unit_test_state *uts)ut_assert_nextlinen ("Buffer: " );ut_assert_nextline ("Size: 253 (595 bytes)" );ut_assert_nextline ("OS: Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)" ); +ut_assert_nextline ("Logo: (none)" );ut_assert_nextline ("Error: 0" );ut_assert_console_end ();
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 16/24 menu: Factor out menu-keypress decoding
In reply to Simon GlassMove this code into a separate function so that it can be used in the new VBE menu.
---
common/menu.c | 48 ++++++++++++++++++++++++++++++------------------ include/menu.h | 10 ++++++++++ 2 files changed, 40 insertions(+), 18 deletions(-)
common/menu.c +30 -18
@@ -483,26 +483,11 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,return key; } -enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu, -struct cli_ch_state *cch) +enum bootmenu_key bootmenu_conv_key (int ichar) { -enum bootmenu_key key =BKEY_NONE ; -int c; - - c =cli_ch_process (cch,0 ); -if (!c) { -while (!c && !tstc ()) { -WATCHDOG_RESET (); -mdelay (10 ); - c =cli_ch_process (cch, -ETIMEDOUT ); - } -if (!c) { - c =getchar (); - c =cli_ch_process (cch, c); - } - } +enum bootmenu_key key; -switch (c) { +switch (ichar) {case '\n' :/* enter key was pressed */ key =BKEY_SELECT ;
@@ -527,7 +512,34 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,case ' ' : key =BKEY_SPACE ;break ; +default : + key =BKEY_NONE ; +break ; + } + +return key; +} + +enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu, +struct cli_ch_state *cch) +{ +enum bootmenu_key key; +int c; + + c =cli_ch_process (cch,0 ); +if (!c) { +while (!c && !tstc ()) { +WATCHDOG_RESET (); +mdelay (10 ); + c =cli_ch_process (cch, -ETIMEDOUT ); + } +if (!c) { + c =getchar (); + c =cli_ch_process (cch, c); + } } + key =bootmenu_conv_key (c); +return key; }
include/menu.h +10 -0
@@ -53,6 +53,8 @@ enum bootmenu_key {BKEY_PLUS ,BKEY_MINUS ,BKEY_SPACE , + + BKEY_COUNT, };/**
@@ -101,4 +103,12 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu,struct cli_ch_state *cch); +/** +* bootmenu_conv_key() - Convert a U-Boot keypress into a menu key +* +* @ichar: Keypress to convert (ASCII, including control characters) +* Returns: Menu key that corresponds to @ichar, or BKEY_NONE if none +*/ +enum bootmenu_key bootmenu_conv_key (int ichar); +#endif /* __MENU_H__ */
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Re: [PATCH 16/24] menu: Factor out menu-keypress decoding
Quoted 15 lines · Simon 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]>---
common/menu.c | 48 ++++++++++++++++++++++++++++++------------------ include/menu.h | 10 ++++++++++ 2 files changed, 40 insertions(+), 18 deletions(-)common/menu.c +0
-0
common/menu.c enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, · line 487
Quoted 7 lines
common/menu.c +1
-2@@ -483,26 +483,11 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,return key; } -enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu, -struct cli_ch_state *cch) +enum bootmenu_key bootmenu_conv_key (int ichar) {
Please, extract a common library function from efi_cin_read_key_stroke_ex(). We should avoid code duplication.
Best regards
Heinrich
Quoted 83 lines
common/menu.c +29
-16-enum bootmenu_key key =BKEY_NONE ; -int c; - - c =cli_ch_process (cch,0 ); -if (!c) { -while (!c && !tstc ()) { -WATCHDOG_RESET (); -mdelay (10 ); - c =cli_ch_process (cch, -ETIMEDOUT ); - } -if (!c) { - c =getchar (); - c =cli_ch_process (cch, c); - } - } +enum bootmenu_key key; -switch (c) { +switch (ichar) {case '\n' :/* enter key was pressed */ key =BKEY_SELECT ;@@ -527,7 +512,34 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,case ' ' : key =BKEY_SPACE ;break ; +default : + key =BKEY_NONE ; +break ; + } + +return key; +} + +enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu, +struct cli_ch_state *cch) +{ +enum bootmenu_key key; +int c; + + c =cli_ch_process (cch,0 ); +if (!c) { +while (!c && !tstc ()) { +WATCHDOG_RESET (); +mdelay (10 ); + c =cli_ch_process (cch, -ETIMEDOUT ); + } +if (!c) { + c =getchar (); + c =cli_ch_process (cch, c); + } } + key =bootmenu_conv_key (c); +return key; }include/menu.h +10
-0@@ -53,6 +53,8 @@ enum bootmenu_key {BKEY_PLUS ,BKEY_MINUS ,BKEY_SPACE , + + BKEY_COUNT, };/** @@ -101,4 +103,12 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu,struct cli_ch_state *cch); +/** +* bootmenu_conv_key() - Convert a U-Boot keypress into a menu key +* +* @ichar: Keypress to convert (ASCII, including control characters) +* Returns: Menu key that corresponds to @ichar, or BKEY_NONE if none +*/ +enum bootmenu_key bootmenu_conv_key (int ichar); +#endif /* __MENU_H__ */
Re: [PATCH 16/24] menu: Factor out menu-keypress decoding
Hi Heinrich,
Quoted 20 lines · Heinrich Schuchardt
Quoted 18 lines · Simon 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]>---
common/menu.c | 48 ++++++++++++++++++++++++++++++------------------ include/menu.h | 10 ++++++++++ 2 files changed, 40 insertions(+), 18 deletions(-)common/menu.c +0
-0@@ -483,26 +483,11 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,return key; }
Quoted 7 lines
common/menu.c enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu, · line 487
Quoted 4 lines
common/menu.c +1
-2-enum bootmenu_key bootmenu_loop (struct bootmenu_data *menu, -struct cli_ch_state *cch) +enum bootmenu_key bootmenu_conv_key (int ichar) {Please, extract a common library function from
efi_cin_read_key_stroke_ex(). We should avoid code duplication.
No, that is EFI code. It also seems to use unicode somehow. We should have EFI code using normal U-Boot functions, not duplicating functionality elsewhere.
As you can see, my approach here is to refactor the common code to do what is needed. Please update the EFI code to do the same.
Re unicode, we need to be very careful...what is the use case for unicode keyboard input?
Regards,
SImon
PATCH 17/24 expo: Add basic implementation
In reply to Simon GlassAn expo is a way of presenting and collecting information from the user. It consists of a collection of 'scenes' of which only one is presented at a time. An expo is typically used to show a boot menu and allow settings to be changed.
One created, the same expo can be automatically presented in graphical form using a vidconsole, or in text form on a serial console.
Add an initial implementation of the expo itself. Supports for scenes and objects is provided later.
---
boot/Kconfig | 12 + boot/expo.c | 133 ++++++++++ configs/tools-only_defconfig | 2 + include/expo.h | 474 +++++++++++++++++++++++++++++++++++ 4 files changed, 621 insertions(+) create mode 100644 boot/expo.c create mode 100644 include/expo.h
boot/Kconfig +12 -0
@@ -566,6 +566,18 @@ config VPL_BOOTMETH_VBE_SIMPLE_FW endif # BOOTMETH_VBE +config EXPO + bool "Support for expos - groups of scenes displaying a UI" + default y if BOOTMETH_VBE + help + An expo is a way of presenting and collecting information from the + user. It consists of a collection of 'scenes' of which only one is + presented at a time. An expo is typically used to show a boot menu + and allow settings to be changed. + + The expo can be presented in graphics form using a vidconsole, or in + text form on a serial console. + config BOOTMETH_SANDBOX def_bool y depends on SANDBOX
boot/expo.c new file +133 -0
133 lines not on this page · raw message
configs/tools-only_defconfig +2 -0
@@ -7,6 +7,8 @@ CONFIG_ANDROID_BOOT_IMAGE=y CONFIG_FIT=y CONFIG_TIMESTAMP=y CONFIG_FIT_SIGNATURE=y +# CONFIG_BOOTSTD_FULL is not set +# CONFIG_BOOTMETH_VBE is not set CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="run distro_bootcmd" # CONFIG_CMD_BOOTD is not set
include/expo.h new file +474 -0
474 lines not on this page · raw message
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 18/24 expo: Add support for scenes
In reply to Simon GlassA scene is a single screen within an expo. It is possible to move between scenes but only one can be displayed at once.
Add a basic implementation.
---
boot/scene.c | 385 ++++++++++++++++++++++++++++++++++++++++++ boot/scene_internal.h | 123 ++++++++++++++ 2 files changed, 508 insertions(+) create mode 100644 boot/scene.c create mode 100644 boot/scene_internal.h
boot/scene.c new file +385 -0
@@ -0,0 +1,385 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Implementation of a scene, a collection of text/image/menu items in an expo +* +* Copyright 2022 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#include <common.h> +#include <dm.h> +#include <expo.h> +#include <malloc.h> +#include <mapmem.h> +#include <video.h> +#include <video_console.h> +#include <linux/input.h> +#include "scene_internal.h" + +uint resolve_id (struct expo *exp,uint id) +{ +if (!id) + id = exp->next_id++; +else if (id >= exp->next_id) + exp->next_id = id +1 ; + +return id; +} + +int scene_new (struct expo *exp,const char *name,uint id,struct scene **scnp) +{ +struct scene *scn; + + scn =calloc (1 ,sizeof (struct scene )); +if (!scn) +return log_msg_ret ("expo" , -ENOMEM ); + scn->name =strdup (name); +if (!scn->name) { +free (scn); +return log_msg_ret ("name" , -ENOMEM ); + } + +INIT_LIST_HEAD (&scn->obj_head); + scn->id =resolve_id (exp, id); + scn->expo = exp; +list_add_tail (&scn->sibling, &exp->scene_head); + + *scnp = scn; + +return scn->id; +} + +void scene_obj_destroy (struct scene_obj *obj) +{ +if (obj->type ==SCENEOBJT_MENU ) +scene_menu_destroy ((struct scene_obj_menu *)obj); +free (obj->name); +free (obj); +} + +void scene_destroy (struct scene *scn) +{ +struct scene_obj *obj, *next; + +list_for_each_entry_safe (obj, next, &scn->obj_head, sibling) +scene_obj_destroy (obj); + +free (scn->name); +free (scn->title); +free (scn); +} + +int scene_title_set (struct scene *scn,const char *title) +{ +free (scn->title); + scn->title =strdup (title); +if (!scn->title) +return log_msg_ret ("tit" , -ENOMEM ); + +return 0 ; +} + +int scene_obj_count (struct scene *scn) +{ +struct scene_obj *obj; +int count =0 ; + +list_for_each_entry (obj, &scn->obj_head, sibling) + count++; + +return count; +} + +void *scene_obj_find (struct scene *scn,uint id,enum scene_obj_t type) +{ +struct scene_obj *obj; + +list_for_each_entry (obj, &scn->obj_head, sibling) { +if (obj->id == id && + (type ==SCENEOBJT_NONE || obj->type == type)) +return obj; + } + +return NULL ; +} + +int scene_obj_add (struct scene *scn,const char *name,uint id, +enum scene_obj_t type,uint size,struct scene_obj **objp) +{ +struct scene_obj *obj; + + obj =calloc (1 , size); +if (!obj) +return log_msg_ret ("obj" , -ENOMEM ); + obj->name =strdup (name); +if (!obj->name) { +free (obj); +return log_msg_ret ("name" , -ENOMEM ); + } + + obj->id =resolve_id (scn->expo, id); + obj->scene = scn; + obj->type = type; +list_add_tail (&obj->sibling, &scn->obj_head); + *objp = obj; + +return obj->id; +} + +int scene_img_add (struct scene *scn,const char *name,uint id,char *data, +struct scene_obj_img **imgp) +{ +struct scene_obj_img *img; +int ret; + + ret =scene_obj_add (scn, name, id,SCENEOBJT_IMAGE , +sizeof (struct scene_obj_img ), + (struct scene_obj **)&img); +if (ret <0 ) +return log_msg_ret ("obj" , -ENOMEM ); + + img->data = data; + +if (imgp) + *imgp = img; + +return img->obj.id; +} + +int scene_txt_add (struct scene *scn,const char *name,uint id,char *str, +struct scene_obj_txt **txtp) +{ +struct scene_obj_txt *txt; +int ret; + + ret =scene_obj_add (scn, name, id,SCENEOBJT_TEXT , +sizeof (struct scene_obj_txt ), + (struct scene_obj **)&txt); +if (ret <0 ) +return log_msg_ret ("obj" , -ENOMEM ); + + txt->str = str; + +if (txtp) + *txtp = txt; + +return txt->obj.id; +} + +int scene_txt_set_font (struct scene *scn,uint id,const char *font_name, +uint font_size) +{ +struct scene_obj_txt *txt; + + txt =scene_obj_find (scn, id,SCENEOBJT_TEXT ); +if (!txt) +return log_msg_ret ("find" , -ENOENT ); + txt->font_name = font_name; + txt->font_size = font_size; + +return 0 ; +} + +int scene_obj_set_pos (struct scene *scn,uint id,int x,int y) +{ +struct scene_obj *obj; + + obj =scene_obj_find (scn, id,SCENEOBJT_NONE ); +if (!obj) +return log_msg_ret ("find" , -ENOENT ); + obj->x = x; + obj->y = y; +if (obj->type ==SCENEOBJT_MENU ) +scene_menu_arrange (scn, (struct scene_obj_menu *)obj); + +return 0 ; +} + +int scene_obj_set_hide (struct scene *scn,uint id,bool hide) +{ +struct scene_obj *obj; + + obj =scene_obj_find (scn, id,SCENEOBJT_NONE ); +if (!obj) +return log_msg_ret ("find" , -ENOENT ); + obj->hide = hide; + +return 0 ; +} + +int scene_obj_get_hw (struct scene *scn,uint id,int *widthp) +{ +struct scene_obj *obj; + + obj =scene_obj_find (scn, id,SCENEOBJT_NONE ); +if (!obj) +return log_msg_ret ("find" , -ENOENT ); + +switch (obj->type) { +case SCENEOBJT_NONE : +case SCENEOBJT_MENU : +break ; +case SCENEOBJT_IMAGE : { +struct scene_obj_img *img = (struct scene_obj_img *)obj; +ulong width, height; +uint bpix; + +video_bmp_get_info (img->data, &width, &height, &bpix); +if (widthp) + *widthp = width; +return height; + } +case SCENEOBJT_TEXT : { +struct scene_obj_txt *txt = (struct scene_obj_txt *)obj; +struct expo *exp = scn->expo; + +if (widthp) + *widthp =16 ;/* fake value for now */ +if (txt->font_size) +return txt->font_size; +if (exp->display) +return video_default_font_height (exp->display); + +/* use a sensible default */ +return 16 ; + } + } + +return 0 ; +} + +/** +* scene_obj_render() - Render an object +* +*/ +static int scene_obj_render (struct scene_obj *obj,bool text_mode) +{ +struct scene *scn = obj->scene; +struct expo *exp = scn->expo; +struct udevice *cons, *dev = exp->display; +int x, y, ret; + + cons =NULL ; +if (!text_mode) { + ret =device_find_first_child_by_uclass (dev, +UCLASS_VIDEO_CONSOLE , + &cons); + } + + x = obj->x; + y = obj->y; + +switch (obj->type) { +case SCENEOBJT_NONE : +break ; +case SCENEOBJT_IMAGE : { +struct scene_obj_img *img = (struct scene_obj_img *)obj; + +if (!cons) +return -ENOTSUPP ; + ret =video_bmp_display (dev,map_to_sysmem (img->data), x, y, + true); +if (ret <0 ) +return log_msg_ret ("img" , ret); +break ; + } +case SCENEOBJT_TEXT : { +struct scene_obj_txt *txt = (struct scene_obj_txt *)obj; + +if (!cons) +return -ENOTSUPP ; + +if (txt->font_name || txt->font_size) { + ret =vidconsole_select_font (cons, + txt->font_name, + txt->font_size); + }else { + ret =vidconsole_select_font (cons,NULL ,0 ); + } +if (ret && ret != -ENOSYS ) +return log_msg_ret ("font" , ret); +vidconsole_set_cursor_pos (cons, x, y); +vidconsole_put_string (cons, txt->str); +break ; + } +case SCENEOBJT_MENU : { +struct scene_obj_menu *menu = (struct scene_obj_menu *)obj; +/* +* With a vidconsole, the text and item pointer are rendered as +* normal objects so we don't need to do anything here. The menu +* simply controls where they are positioned. +*/ +if (cons) +return -ENOTSUPP ; + + ret =scene_menu_display (menu); +if (ret <0 ) +return log_msg_ret ("img" , ret); + +break ; + } + } + +return 0 ; +} + +int scene_arrange (struct scene *scn) +{ +struct scene_obj *obj; +int ret; + +list_for_each_entry (obj, &scn->obj_head, sibling) { +if (obj->type ==SCENEOBJT_MENU ) { +struct scene_obj_menu *menu; + + menu = (struct scene_obj_menu *)obj, + ret =scene_menu_arrange (scn, menu); +if (ret) +return log_msg_ret ("arr" , ret); + } + } + +return 0 ; +} + +int scene_render (struct scene *scn) +{ +struct expo *exp = scn->expo; +struct scene_obj *obj; +int ret; + +list_for_each_entry (obj, &scn->obj_head, sibling) { +if (!obj->hide) { + ret =scene_obj_render (obj, exp->text_mode); +if (ret && ret != -ENOTSUPP ) +return log_msg_ret ("ren" , ret); + } + } + +return 0 ; +} + +int scene_send_key (struct scene *scn,int key,struct expo_action *event) +{ +struct scene_obj *obj; +int ret; + +list_for_each_entry (obj, &scn->obj_head, sibling) { +if (obj->type ==SCENEOBJT_MENU ) { +struct scene_obj_menu *menu; + + menu = (struct scene_obj_menu *)obj, + ret =scene_menu_send_key (scn, menu, key, event); +if (ret) +return log_msg_ret ("key" , ret); + +/* only allow one menu */ + ret =scene_menu_arrange (scn, menu); +if (ret) +return log_msg_ret ("arr" , ret); +break ; + } + } + +return 0 ; +}
boot/scene_internal.h new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 19/24 expo: Add support for scene menus
In reply to Simon GlassA menu is a key part of the expo design. It consists of a number of items which the user can select from.
Add the initial implementation of this.
---
boot/Makefile | 2 + boot/scene_menu.c | 372 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 374 insertions(+) create mode 100644 boot/scene_menu.c
boot/Makefile +2 -0
@@ -47,6 +47,8 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o endif +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += expo.o scene.o scene_menu.o + obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += vbe.o vbe_request.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE) += vbe_simple.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE_FW) += vbe_simple_fw.o
boot/scene_menu.c new file +372 -0
372 lines not on this page · raw message
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 20/24 expo: Add basic tests
In reply to Simon GlassAdd some tests for the expo, including setting up and rendering an expo.
---
test/boot/Makefile | 2 + test/boot/expo.c | 510 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 512 insertions(+) create mode 100644 test/boot/expo.c
test/boot/Makefile +2 -0
@@ -5,6 +5,8 @@ obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o obj-$(CONFIG_FIT) += image.o +obj-$(CONFIG_EXPO) += expo.o + ifdef CONFIG_OF_LIVE obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o endif
test/boot/expo.c new file +510 -0
510 lines not on this page · raw message
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 21/24 bootstd: Support creating a boot menu
In reply to Simon GlassCreate an expo to handle the boot menu. For now this is quite simple, with just a header, some menu items and a pointer to show the current one.
---
boot/Makefile | 1 + boot/bootflow_internal.h | 37 ++++++ boot/bootflow_menu.c | 238 +++++++++++++++++++++++++++++++++++++++ cmd/bootflow.c | 37 +++++- include/bootflow.h | 23 ++++ 5 files changed, 334 insertions(+), 2 deletions(-) create mode 100644 boot/bootflow_internal.h create mode 100644 boot/bootflow_menu.c
boot/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow_menu.o endif obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
boot/bootflow_internal.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Internal header file for bootflow +* +* Copyright 2022 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#ifndef __BOOTFLOW_INTERNAL_H +#define __BOOTFLOW_INTERNAL_H + +/* expo IDs for elements of the bootflow menu */ +enum { +START , + +/* scene */ +MAIN , + +/* objects */ +OBJ_U_BOOT_LOGO , +OBJ_MENU , +OBJ_PROMPT , +OBJ_MENU_TITLE , +OBJ_POINTER , + +/* menu items / components (bootflow number is added to these) */ +ITEM =100 , +ITEM_LABEL =200 , +ITEM_DESC =300 , +ITEM_KEY =400 , +ITEM_PREVIEW =500 , + +/* left margin for the main menu */ +MARGIN_LEFT =100 , +}; + +#endif /* __BOOTFLOW_INTERNAL_H */
boot/bootflow_menu.c new file +238 -0
238 lines not on this page · raw message
cmd/bootflow.c +35 -2
@@ -389,6 +389,37 @@ static int do_bootflow_boot(struct cmd_tbl *cmdtp, int flag, int argc,return 0 ; } + +static int do_bootflow_menu (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]) +{ +struct bootstd_priv *std; +struct bootflow *bflow; +bool text_mode = false; +int ret; + +if (argc >1 && *argv[1 ] =='-' ) + text_mode =strchr (argv[1 ],'t' ); + + ret =bootstd_get_priv (&std); +if (ret) +return CMD_RET_FAILURE ; + + ret =bootflow_menu_run (std, text_mode, &bflow); +if (ret) { +if (ret == -EAGAIN ) +printf ("Nothing chosen\n" ); +else +printf ("Menu failed (err=%d)\n" , ret); + +return CMD_RET_FAILURE ; + } + +printf ("Selected: %s\n" , bflow->os_name ? bflow->os_name : bflow->name); + std->cur_bootflow = bflow; + +return 0 ; +}#endif /* CONFIG_CMD_BOOTFLOW_FULL */ #ifdef CONFIG_SYS_LONGHELP
@@ -398,7 +429,8 @@ static char bootflow_help_text[] ="bootflow list [-e] - list scanned bootflows (-e errors)\n" "bootflow select [<num>|<name>] - select a bootflow\n" "bootflow info [-d] - show info on current bootflow (-d dump bootflow)\n" -"bootflow boot - boot current bootflow (or first available if none selected)" ; +"bootflow boot - boot current bootflow (or first available if none selected)\n" +"bootflow menu [-t] - show a menu of available bootflows" ;#else "scan - boot first available bootflow\n" ;#endif
@@ -410,6 +442,7 @@ U_BOOT_CMD_WITH_SUBCMDS(bootflow, "Boot flows", bootflow_help_text,U_BOOT_SUBCMD_MKENT (list,2 ,1 , do_bootflow_list),U_BOOT_SUBCMD_MKENT (select,2 ,1 , do_bootflow_select),U_BOOT_SUBCMD_MKENT (info,2 ,1 , do_bootflow_info), -U_BOOT_SUBCMD_MKENT (boot,1 ,1 , do_bootflow_boot) +U_BOOT_SUBCMD_MKENT (boot,1 ,1 , do_bootflow_boot), + U_BOOT_SUBCMD_MKENT(menu, 2, 1, do_bootflow_menu), #endif );
include/bootflow.h +23 -0
@@ -9,6 +9,9 @@#include <linux/list.h> +struct bootstd_priv ; +struct expo ; +/** * enum bootflow_state_t - states that a particular bootflow can be in *
@@ -336,4 +339,24 @@ int bootflow_iter_uses_network(const struct bootflow_iter *iter);*/ int bootflow_iter_uses_system (const struct bootflow_iter *iter); +/** +* bootflow_menu_new() - Create a new bootflow menu +* +* @expp: Returns the expo created +* Returns 0 on success, -ve on error +*/ +int bootflow_menu_new (struct expo **expp); + +/** +* bootflow_menu_run() - Create and run a menu of available bootflows +* +* @std: Bootstd information +* @text_mode: Uses a text-based menu suitable for a serial port +* @bflowp: Returns chosen bootflow (set to NULL if nothing is chosen) +* @return 0 if an option was chosen, -EAGAIN if nothing was chosen, -ve on +* error +*/ +int bootflow_menu_run (struct bootstd_priv *std,bool text_mode, +struct bootflow **bflowp); +#endif
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 22/24 bootstd: Add a test for the bootstd menu
In reply to Simon GlassAdd a test which checks that two operating systems can be displayed in a menu, allowing one to be selected.
Enable a few things on snow so that the unit tests build.
---
arch/sandbox/dts/test.dts | 11 ++ configs/snow_defconfig | 4 + test/boot/bootflow.c | 51 +++++++ test/py/tests/bootstd/armbian.bmp.xz | Bin 0 -> 1384 bytes test/py/tests/bootstd/mmc4.img.xz | Bin 0 -> 7072 bytes test/py/tests/test_ut.py | 216 ++++++++++++++++++++++++--- 6 files changed, 264 insertions(+), 18 deletions(-) create mode 100644 test/py/tests/bootstd/armbian.bmp.xz create mode 100644 test/py/tests/bootstd/mmc4.img.xz
arch/sandbox/dts/test.dts +11 -0
@@ -94,6 +94,10 @@ compatible = "u-boot,distro-efi"; }; + theme { + font-size = <30>; + }; + /* * This is used for the VBE OS-request tests. A FAT filesystem * created in a partition with the VBE information appearing
@@ -1003,6 +1007,13 @@ non-removable; }; + /* This is used for bootstd bootmenu tests */ + mmc4 { + status = "disabled"; + compatible = "sandbox,mmc"; + filename = "mmc4.img"; + }; + pch { compatible = "sandbox,pch"; };
configs/snow_defconfig +4 -0
@@ -28,7 +28,11 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2050000 CONFIG_FIT=y CONFIG_FIT_BEST_MATCH=y +CONFIG_BOOTSTD_FULL=y CONFIG_SILENT_CONSOLE=y +CONFIG_BLOBLIST=y +# CONFIG_SPL_BLOBLIST is not set +CONFIG_BLOBLIST_ADDR=0x43d00000 # CONFIG_SPL_FRAMEWORK is not set CONFIG_SPL_FOOTPRINT_LIMIT=y CONFIG_SPL_MAX_FOOTPRINT=0x3800
test/boot/bootflow.c +51 -0
69 lines not on this page · raw message
test/py/tests/bootstd/armbian.bmp.xz new file binary +0 -0
test/py/tests/bootstd/mmc4.img.xz new file binary +0 -0
test/py/tests/test_ut.py +198 -18
251 lines not on this page · raw message
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 23/24 bootstd: Support setting a theme for the menu
In reply to Simon GlassAllow a theme to be set. For now this is very simple, just a default font size to use for all elements.
---
boot/bootflow_menu.c | 43 ++++++++++++++++++++++ boot/bootstd-uclass.c | 2 ++ include/bootflow.h | 10 ++++++ include/bootstd.h | 4 +++ test/boot/bootflow.c | 83 +++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 139 insertions(+), 3 deletions(-)
boot/bootflow_menu.c +43 -0
@@ -126,6 +126,43 @@ int bootflow_menu_new(struct expo **expp)return 0 ; } +int bootflow_menu_apply_theme (struct expo *exp,ofnode node) +{ +struct menu_priv *priv = exp->priv; +struct scene *scn; +u32 font_size; +int ret; + +log_debug ("Applying theme %s\n" ,ofnode_get_name (node)); + scn =expo_lookup_scene_id (exp,MAIN ); +if (!scn) +return log_msg_ret ("scn" , -ENOENT ); + +/* Avoid error-checking optional items */ +if (!ofnode_read_u32 (node,"font-size" , &font_size)) { +int i; + +log_debug ("font size %d\n" , font_size); +scene_txt_set_font (scn,OBJ_PROMPT ,NULL , font_size); +scene_txt_set_font (scn,OBJ_POINTER ,NULL , font_size); +for (i =0 ; i < priv->num_bootflows; i++) { + ret =scene_txt_set_font (scn,ITEM_DESC + i,NULL , + font_size); +if (ret) +return log_msg_ret ("des" , ret); +scene_txt_set_font (scn,ITEM_KEY + i,NULL , font_size); +scene_txt_set_font (scn,ITEM_LABEL + i,NULL , + font_size); + } + } + + ret =scene_arrange (scn); +if (ret) +return log_msg_ret ("arr" , ret); + +return 0 ; +} +int bootflow_menu_run (struct bootstd_priv *std,bool text_mode,struct bootflow **bflowp) {
@@ -146,6 +183,12 @@ int bootflow_menu_run(struct bootstd_priv *std, bool text_mode,if (ret)return log_msg_ret ("exp" , ret); +if (ofnode_valid (std->theme)) { + ret =bootflow_menu_apply_theme (exp, std->theme); +if (ret) +return log_msg_ret ("thm" , ret); + } +/* For now we only support a video console */ ret =uclass_first_device_err (UCLASS_VIDEO , &dev);if (ret)
boot/bootstd-uclass.c +2 -0
@@ -33,6 +33,8 @@ static int bootstd_of_to_plat(struct udevice *dev) &priv->prefixes);dev_read_string_list (dev,"bootdev-order" , &priv->bootdev_order); + + priv->theme =ofnode_find_subnode (dev_ofnode (dev),"theme" ); }return 0 ;
include/bootflow.h +10 -0
@@ -7,6 +7,7 @@#ifndef __bootflow_h#define __bootflow_h +#include <dm/ofnode_decl.h> #include <linux/list.h> struct bootstd_priv ;
@@ -347,6 +348,15 @@ int bootflow_iter_uses_system(const struct bootflow_iter *iter);*/ int bootflow_menu_new (struct expo **expp); +/** +* bootflow_menu_apply_theme() - Apply a theme to a bootmenu +* +* @exp: Expo to update +* @node: Node containing the theme information +* Returns 0 on success, -ve on error +*/ +int bootflow_menu_apply_theme (struct expo *exp,ofnode node); +/** * bootflow_menu_run() - Create and run a menu of available bootflows *
include/bootstd.h +4 -0
@@ -9,6 +9,8 @@#ifndef __bootstd_h#define __bootstd_h +#include <dm/ofnode_decl.h> +struct udevice ;/**
@@ -27,6 +29,7 @@ struct udevice;* @bootmeth_count: Number of bootmeth devices in @bootmeth_order * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none +* @theme: Node containing the theme information */ struct bootstd_priv {const char **prefixes;
@@ -37,6 +40,7 @@ struct bootstd_priv {int bootmeth_count;struct udevice **bootmeth_order;struct udevice *vbe_bootmeth; +ofnode theme; };/**
test/boot/bootflow.c +80 -3
115 lines not on this page · raw message
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
PATCH 24/24 expo: Add documentation
In reply to Simon GlassAdd some documentation for the expo feature.
---
doc/develop/expo.rst | 184 ++++++++++++++++++++++++++++++++++++++++++ doc/develop/index.rst | 1 + 2 files changed, 185 insertions(+) create mode 100644 doc/develop/expo.rst
doc/develop/expo.rst new file +184 -0
@@ -0,0 +1,184 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Expo menu +========= + +U-Boot provides a menu implementation for use with selecting bootflows and +changing U-Boot settings. This is in early stages of development. + +Motivation +---------- + +U-Boot already has a text-based menu system accessed via the +:doc:`../usage/cmd/bootmenu`. This works using environment variables, or via +some EFI-specific hacks. + +The command makes use of a lower-level `menu` implementation, which is quite +flexible and can be used to make menu hierarchies. + +However this system is not flexible enough for use with standard boot. It does +not support a graphical user interface and cannot currently support anything +more than a very simple list of items. While it does support multiple menus in +hierarchies, these are implemented by the caller. See for example `eficonfig.c`. + +Another challenge with the current menu implementation is that it controls +the event loop, such that bootmenu_loop() does not return until a key is +pressed. This makes it difficult to implement dynamic displays or to do other +things while the menu is running, such as searching for more bootflows. + +For these reasons an attempt has been made to develop a more flexible system +which can handle menus as well as other elements. This is called 'expo', short +for exposition, in an attempt to avoid common words like display, screen, menu +and the like. The primary goal is to support Verified Boot for Embedded (VBE), +although it is available to any boot method, using the 'bootflow menu' command. + +Efforts have been made to use common code with the existing menu, including +key processing in particular. + +Previous work looked at integrating Nuklear into U-Boot. This works fine and +could provide a way to provide a more flexible UI, perhaps with expo dealing +with the interface to Nuklear. But this is quite a big step and it may be years +before this becomes desirable, if at all. For now, U-Boot only needs a fairly +simple set of menus and options, so rendering them directly is fairly +straightforward. + +Concepts +-------- + +The creator of the expo is here called a `controller` and it controls most +aspects of the expo. This is the code that you must write to use expo. + +An `expo` is a set of scenes which can be presented to the user one at a time, +to show information and obtain input from the user. + +A `scene` is a collection of objects which are displayed together on the screen. +Only one scene is visible at a time and scenes do not share objects. + +A `scene object` is something that appears in the scene, such as some text, an +image or a menu. Objects can be positioned and hidden. + +A `menu object` contains a title, a set of `menu items` and a pointer to the +current item. Menu items consist of a keypress (indicating what to press to +select the item), label and description. All three are shown in a single line +within the menu. Items can also have a preview image, which is shown when the +item is highlighted. + +All components have a name. This is purely for debugging, so it is easy to see +what object is referred to. Of course the ID numbers can help as well, but they +are less easy to distinguish. + +While the expo implementation provides support for handling keypresses and +rendering on the display or serial port, it does not actually deal with reading +input from the user, nor what should be done when a particular menu item is +selected. This is deliberate since having the event loop outside the expo is +more flexible, particularly in a single-threaded environment like U-Boot. + +Everything within an expo has a unique ID number. This is done so that it is +easy to refer to things after the expo has been created. The expectation is that +the controller declares an enum containing all of the elements in the expo, +passing the ID of each object as it is created. When a menu item is selected, +its ID is returned. When a object's font or position needs to change, the ID is +passed to expo functions to indicate which object it is. It is possible for expo +to auto-allocate IDs, but this is not recommended. The use of IDs is a +convenience, removing the need for the controller to store pointers to objects, +or even the IDs of objects. Programmatic creation of many items in a loop can be +handled by allocating space in the enum for a maximum number of items, then +adding the loop count to the enum values to obtain unique IDs. + +Menu objects do not have their own text and image objects. Instead they simply +refer to objects which have been created. So a menu item is just a collection +of IDs of text and image objects. When adding a menu item you must create these +objects first, then create the menu item, passing in the relevant IDs. + +Creating an expo +---------------- + +To create an expo, use `expo_new()` followed by `scene_new()` to create a scene. +Then add objects to the scene, using functions like `scene_txt_add()` and +`scene_menu_add()`. For every menu item, add text and image objects, then create +the menu item with `scene_menuitem_add()`, referring to those objects. + +Layout +------ + +Individual objects can be positioned using `scene_obj_set_pos()`. Menu items +cannot be positioned manually: this is done by `scene_arrange()` which is called +automatically when something changes. The menu itself determines the position of +its items. + +Rendering +--------- + +Rendering is performed by calling `expo_render()`. This uses either the +vidconsole, if present, or the serial console in `text mode`. Expo handles +presentation automatically in either case, without any change in how the expo is +created. + +For the vidconsole, Truetype fonts can be used if enabled, to enhance the +quality of the display. For text mode, each menu item is shown in a single line, +allowing easy selection using arrow keys. + +Input +----- + +The controller is responsible for collecting keyboard input. A good way to do +this is to use `cli_ch_process()`, since it handles conversion of escape +sequences into keys. However, expo has some special menu-key codes for +navigating the interface. These are defined in `enum bootmenu_key` and include +`BKEY_UP` for moving up and `BKEY_SELECT` for selecting an item. You can use +`bootmenu_conv_key()` to convert an ASCII key into one of these. + +Once a keypress is decoded, call `expo_send_key()` to send it to the expo. This +may cause an update to the expo state and may produce an action. + +Actions +------- + +Call `expo_action_get()` in the event loop to check for any actions that the +expo wants to report. These can include selecting a particular menu item, or +quitting the menu. Processing of these is the resposibility of your controller. + +Event loop +---------- + +Expo is intended to be used in an event loop. For an example loop, see +`bootflow_menu_run()`. It is possible to perform other work in your event loop, +such as scanning devices for more bootflows. + +Themes +------ + +Expo does not itself support themes. The bootflow_menu implement supposed a +basic theme, applying font sizes to the various text objects in the expo. + +API documentation +----------------- + +.. kernel-doc:: include/expo.h + +Future ideas +------------ + +Some ideas for future work: + +- Default menu item and a timeout +- Higher-level / automatic / more flexible layout of objects +- Image formats other than BMP +- Use of ANSI sequences to control a serial terminal +- Colour selection +- Better support for handling lots of settings, e.g. with multiple menus and + radio/option widgets +- Mouse support +- Integrate Nuklear or some other library for a richer UI +- Optimise rendering by only updating the display with changes since last render +- Use expo to replace the existing menu implementation +- Add a Kconfig option to drop the names to save code / data space +- Add a Kconfig option to disable vidconsole support to save code / data space +- Support both graphical and text menus at the same time on different devices +- Implement proper measurement of object bounding boxes, to permit more exact + layout. This would tidy up the layout when Truetype is not used +- Support unicode +- Support curses for proper serial-terminal menus + +.. Simon Glass <[email protected]> +.. 7-Oct-22
doc/develop/index.rst +1 -0
@@ -32,6 +32,7 @@ Implementation distro driver-model/index environment + expo event global_data logging
Signature · 1 line
2.38.0.413.g74048e4d9e-goog
Quoted 28 lines · Simon Glass
So far standard boot lacks a boot menu, although it is possible to create a rudimentary one using the existing 'bootmenu' command.
Even then, this text-based menu offer only basic functionality and does not take full advantage of the displays which are common on many devices.
This series provides a 'bootflow menu' command which allows the user to select from the available bootflows. An attempt is made to show the name of the available operating systems, by reading more information into the bootflow. A logo can be read also, where supported, so that this can be presented to the user when an option is highlighted.
Full use is made of TrueType fonts, if enabled. For cases where only a serial console is available, it falls back to a simple text-based menu.
All of this is implementing using a new 'expo' construct, a collection of scenes (like menu screens) which can be navigated by the user to view information and select option. This is fairly general and should be able to cope with a wider array of use cases, with less hacking of the menu code, such as is currently needed for
CMD_BOOTEFI_BOOTMGR.Of course it would be possible to enhance the existing menu rather than creating a new setup. Instead it seems better to make the existing menu use expo, if code space permits. It avoids the event-loop problem and should be more extensible, given its loosely coupled components and use of IDs instead of pointers. Further motivation is provided in the documentation.
Quoted 5 lines
For now the CLI keypress-decoding code is split out to be used by the new menu. The key codes defined by
menu.hare reused also.This is of course just a starting point. Some ideas for future work are included in the documentation.
Hello Simon,
Linaro's implementation of a boot menu for UEFI booting showed that the current basis of bootmenu is inadequate for properly designing a GUI like user interface.
With your patch set you try to overcome this. Your design document in patch 24 identifies a hierarchy of objects expo - scene - design element but otherwise remains rather sketchy to me.
Before investing into code we should a more holistic design perspective.
First thing we need to define is our requirements, e.g.
** Which input devices do we want to support in future **
- keyboard
- mouse
** What type of GUI do we want to support **
- text terminal
- graphical output
** Which design elements do we need **
- lists
- trees
- grids
- menus
- labels
- buttons
- drop down lists
- combo boxes
- bitmaps
- screens (you call them scene)
- transactions (you call them expo)
** How do we want to structure our GUI **
- Good practice is to clearly separate model, view, and controller.
** Which constraints do we have to observe? **
- How much is the code base allowed to grow?
- Who will be the long term sponsor and maintainer?
After having this rough cut overview we may start with a draft implementation and detail our design document.
How do you plan to organize the design work?
Best regards
Heinrich
Hi Heinrich,
Quoted 38 lines · Heinrich Schuchardt
Quoted 28 lines · Simon Glass
So far standard boot lacks a boot menu, although it is possible to create a rudimentary one using the existing 'bootmenu' command.
Even then, this text-based menu offer only basic functionality and does not take full advantage of the displays which are common on many devices.
This series provides a 'bootflow menu' command which allows the user to select from the available bootflows. An attempt is made to show the name of the available operating systems, by reading more information into the bootflow. A logo can be read also, where supported, so that this can be presented to the user when an option is highlighted.
Full use is made of TrueType fonts, if enabled. For cases where only a serial console is available, it falls back to a simple text-based menu.
All of this is implementing using a new 'expo' construct, a collection of scenes (like menu screens) which can be navigated by the user to view information and select option. This is fairly general and should be able to cope with a wider array of use cases, with less hacking of the menu code, such as is currently needed for
CMD_BOOTEFI_BOOTMGR.Of course it would be possible to enhance the existing menu rather than creating a new setup. Instead it seems better to make the existing menu use expo, if code space permits. It avoids the event-loop problem and should be more extensible, given its loosely coupled components and use of IDs instead of pointers. Further motivation is provided in the documentation.
Quoted 5 lines
For now the CLI keypress-decoding code is split out to be used by the new menu. The key codes defined by
menu.hare reused also.This is of course just a starting point. Some ideas for future work are included in the documentation.
Hello Simon,
Quoted 7 lines
Linaro's implementation of a boot menu for UEFI booting showed that the current basis of bootmenu is inadequate for properly designing a GUI like user interface.
With your patch set you try to overcome this. Your design document in patch 24 identifies a hierarchy of objects expo - scene - design element but otherwise remains rather sketchy to me.
For now the doc is here:
Quoted 9 lines
Before investing into code we should a more holistic design perspective.
First thing we need to define is our requirements, e.g.
** Which input devices do we want to support in future **
- keyboard
- mouse
I have patches for mouse, actually.
Quoted 8 lines
** What type of GUI do we want to support **
- text terminal
- graphical output** Which design elements do we need **
Quoted 11 lines
- lists
- trees
- grids
- menus
- labels
- buttons
- drop down lists
- combo boxes
- bitmaps
- screens (you call them scene)
- transactions (you call them expo)
(this series has rudimentary menus, labels and bitmaps, but does not support the others)
Quoted 4 lines
** How do we want to structure our GUI **
- Good practice is to clearly separate model, view, and controller.
Expo is the view. Controller is the client code. Model is currently the expo, updated by the controller. That part of it needs though if we are to expand the capabilities of this effort.
Quoted 10 lines
** Which constraints do we have to observe? **
- How much is the code base allowed to grow?
- Who will be the long term sponsor and maintainer?After having this rough cut overview we may start with a draft implementation and detail our design document.
How do you plan to organize the design work?
See also the bottom of the docs for some future work, also whether we should consider using a GUI library like Nuklear in the future:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
It has evolved since that doc. The doc needs to evolve further. Perhaps we can start by agreeing the requirements.
Regards,
Simon
Hi Heinrich,
Quoted 109 lines · Simon Glass
Hi Heinrich,
Quoted 38 lines · Heinrich Schuchardt
Quoted 28 lines · Simon Glass
So far standard boot lacks a boot menu, although it is possible to create a rudimentary one using the existing 'bootmenu' command.
Even then, this text-based menu offer only basic functionality and does not take full advantage of the displays which are common on many devices.
This series provides a 'bootflow menu' command which allows the user to select from the available bootflows. An attempt is made to show the name of the available operating systems, by reading more information into the bootflow. A logo can be read also, where supported, so that this can be presented to the user when an option is highlighted.
Full use is made of TrueType fonts, if enabled. For cases where only a serial console is available, it falls back to a simple text-based menu.
All of this is implementing using a new 'expo' construct, a collection of scenes (like menu screens) which can be navigated by the user to view information and select option. This is fairly general and should be able to cope with a wider array of use cases, with less hacking of the menu code, such as is currently needed for
CMD_BOOTEFI_BOOTMGR.Of course it would be possible to enhance the existing menu rather than creating a new setup. Instead it seems better to make the existing menu use expo, if code space permits. It avoids the event-loop problem and should be more extensible, given its loosely coupled components and use of IDs instead of pointers. Further motivation is provided in the documentation.
Quoted 5 lines
For now the CLI keypress-decoding code is split out to be used by the new menu. The key codes defined by
menu.hare reused also.This is of course just a starting point. Some ideas for future work are included in the documentation.
Hello Simon,
Quoted 7 lines
Linaro's implementation of a boot menu for UEFI booting showed that the current basis of bootmenu is inadequate for properly designing a GUI like user interface.
With your patch set you try to overcome this. Your design document in patch 24 identifies a hierarchy of objects expo - scene - design element but otherwise remains rather sketchy to me.
For now the doc is here:
Quoted 9 lines
Before investing into code we should a more holistic design perspective.
First thing we need to define is our requirements, e.g.
** Which input devices do we want to support in future **
- keyboard
- mouseI have patches for mouse, actually.
Quoted 8 lines
** What type of GUI do we want to support **
- text terminal
- graphical output** Which design elements do we need **
Quoted 11 lines
- lists
- trees
- grids
- menus
- labels
- buttons
- drop down lists
- combo boxes
- bitmaps
- screens (you call them scene)
- transactions (you call them expo)(this series has rudimentary menus, labels and bitmaps, but does not support the others)
Quoted 4 lines
** How do we want to structure our GUI **
- Good practice is to clearly separate model, view, and controller.
Expo is the view. Controller is the client code. Model is currently the expo, updated by the controller. That part of it needs though if we are to expand the capabilities of this effort.
Quoted 10 lines
** Which constraints do we have to observe? **
- How much is the code base allowed to grow?
- Who will be the long term sponsor and maintainer?After having this rough cut overview we may start with a draft implementation and detail our design document.
How do you plan to organize the design work?
Quoted 7 lines
See also the bottom of the docs for some future work, also whether we should consider using a GUI library like Nuklear in the future:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
It has evolved since that doc. The doc needs to evolve further. Perhaps we can start by agreeing the requirements.
I have updated the doc to accommodate some of your comments and to indicate exactly how unicode and languages might be supported.
Please add any comments to the doc, or put them in this thread.
I'll rework the patches a little and send out a new version.
Regards,
Simon