Following the disussion in D55559, here's a (very shy) first step starting to
demonstrate the use of the UEFI Boot Manager to build a menu with Lua to let the
user pick a partition.
The patch is enabled with the WITH_LOADER_EFIBOOTMGRMENU option and require to
manually populate ESP's /EFI/FreeBSD/lua directory with the content of
stand/lua/ (creating any missing directory).
This is a PoC, so it is advised to use the BootNext mechanism to boot the
resulting loader.efi ;)
It expose BootCurrent, Timeout and BootOrder under the efibootmgr Lua
module as follow:
- boot_current: an integer, e.g., 5 for Boot0005.
- timeout: an integer for the timeout duration in seconds.
- boot_order: a table (with first index being 1) were each element is an associative array with the following keys:
- bootnum: boot number as an integer, e.g., 5 for Boot0005
- description: the description (a.k.a., label) as a string
- attributes: attributes as an integer
- is_active: boolean telling if the active attribute is set
- is_hidden: boolean telling if the hidden attribute is set
- devpath: device path as a string
It then start efibootmgr.lua instead of loader.lua.
It don't boot anything. I first wanted to validate I correctly understood the
target approach. I also need some guidance on how to convert a load option into
the required things necessary to boot a given kernel. E.g., how do I map it to
things like currdev, kernelname vfs.root.mountfrom, etc…
Some implementation notes:
- it change liblua's LUAPATH from /boot/lua (in the booted partition) to
/EFI/FreeBSD/lua in the ESP
- it conflict with LOADER_KBOOT (don't know why):
--- all_subdir_stand/kboot --- ld: error: undefined symbol: efi_global_getenv >>> referenced by lefibootmgr.c:29 (…/stand/liblua/lefibootmgr.c:29) >>> lefibootmgr.o:(luaopen_efibootmgr) in archive …/amd64.amd64/stand /liblua/liblua.a