diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 02c46c44c2..7fff880414 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -2028,6 +2028,29 @@ static VOID config_free(Config *config) { FreePool(config->entry_oneshot); } +static VOID config_write_entries_to_variable(Config *config) { + _cleanup_freepool_ CHAR16 *buffer = NULL; + UINTN i, sz = 0; + CHAR16 *p; + + for (i = 0; i < config->entry_count; i++) + sz += StrLen(config->entries[i]->id) + 1; + + p = buffer = AllocatePool(sz * sizeof(CHAR16)); + + for (i = 0; i < config->entry_count; i++) { + UINTN l; + + l = StrLen(config->entries[i]->id) + 1; + CopyMem(p, config->entries[i]->id, l * sizeof(CHAR16)); + + p += l; + } + + /* Store the full list of discovered entries. */ + (void) efivar_set_raw(&loader_guid, L"LoaderEntries", buffer, (UINT8*) p - (UINT8*) buffer, FALSE); +} + EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { _cleanup_freepool_ CHAR16 *infostr = NULL, *typestr = NULL; CHAR8 *b; @@ -2119,6 +2142,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { goto out; } + config_write_entries_to_variable(&config); + config_title_generate(&config); /* select entry by configured pattern or EFI LoaderDefaultEntry= variable */ diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index e286b14bcc..fd4be681a5 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -10,7 +10,7 @@ * the (ESP)\loader\entries\-.conf convention and the * associated EFI variables. */ -static const EFI_GUID loader_guid = { 0x4a67b082, 0x0a4c, 0x41cf, {0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f} }; +const EFI_GUID loader_guid = { 0x4a67b082, 0x0a4c, 0x41cf, {0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f} }; #ifdef __x86_64__ UINT64 ticks_read(VOID) { diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index ae06444014..40ede66d4a 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -50,3 +50,5 @@ static inline void FileHandleClosep(EFI_FILE_HANDLE *handle) { uefi_call_wrapper((*handle)->Close, 1, *handle); } + +const EFI_GUID loader_guid;