Skip to content

Commit f35cd2c

Browse files
committed
menu: Hide BIOS chainloading entries on UEFI and vice-versa. Fixes #484
1 parent 80912a3 commit f35cd2c

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

CONFIG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ Editor control options:
190190
> **NOTE:** `uefi` and `efi_chainload` are aliases of the `efi` protocol
191191
> option. `bios_chainload` is an alias of the `bios` protocol option.
192192
193+
> **NOTE:** BIOS chainloading entries will be hidden when booting using UEFI
194+
> and vice-versa.
195+
193196
*Locally assignable (protocol specific) options* are:
194197

195198
* Linux protocol:

common/menu.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,27 @@ static size_t print_tree(size_t offset, size_t window, const char *shift, size_t
556556
size_t cur_len = 0;
557557
if (current_entry == NULL)
558558
break;
559+
if (current_entry->sub == NULL) {
560+
bool skip_entry = false;
561+
char *cur_entry_protocol = config_get_value(current_entry->body, 0, "PROTOCOL");
562+
if (cur_entry_protocol) {
563+
#if defined (UEFI)
564+
if (strcmp(cur_entry_protocol, "bios") == 0
565+
|| strcmp(cur_entry_protocol, "bios_chainload") == 0) {
566+
#elif defined (BIOS)
567+
if (strcmp(cur_entry_protocol, "efi") == 0
568+
|| strcmp(cur_entry_protocol, "uefi") == 0
569+
|| strcmp(cur_entry_protocol, "efi_chainload") == 0) {
570+
#endif
571+
skip_entry = true;
572+
}
573+
pmm_free(cur_entry_protocol, strlen(cur_entry_protocol) + 1);
574+
if (skip_entry) {
575+
current_entry = current_entry->next;
576+
continue;
577+
}
578+
}
579+
}
559580
if (!no_print && base_index + max_entries < offset) {
560581
goto skip_line;
561582
}

0 commit comments

Comments
 (0)