Skip to content

add options that allow hiding entries depending of firmware/architecture#560

Merged
iczelia merged 10 commits intoLimine-Bootloader:trunkfrom
PatrickHechler:trunk
Apr 26, 2026
Merged

add options that allow hiding entries depending of firmware/architecture#560
iczelia merged 10 commits intoLimine-Bootloader:trunkfrom
PatrickHechler:trunk

Conversation

@PatrickHechler
Copy link
Copy Markdown

@PatrickHechler PatrickHechler commented Apr 26, 2026

the new option if_fw_type can be set to either bios or efi/uefi.

  • bios: hide the entry, unless booted from bios
  • efi/uefi: hide the entry, unless booted from uefi

the new option if_arch is interpreted as a space seperated list of permitted architectures.
the entry will be hidden if ${ARCH} is not inside the list.
note that for 32-bit executables the 64-bit architecutre and the 32-bit architecture needs to be in the list (i.e. ia-32 x86-64)

this is requested by #541 and #537

PatrickHechler and others added 2 commits April 26, 2026 16:23
IF_FW_TYPE allows to hide menu entries according to the
firmware type (bios/uefi)
  if IF_FW_TYPE is present and does not match the firmware
  the entry will be hidden

IF_ARCH allows to hide menu entries according to the
processor architecture (x86-64/ia-32/aarch64/...)
  if IF_ARCH is present it must contain a space seperated
  list of allowed architectures
    (ie. IF_ARCH: x86-64 ia-32)
Copy link
Copy Markdown
Member

@iczelia iczelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch. Unfortunately, by my understanding, this is completely wrong. Three main issues:

  • The IF_FW_TYPE block in should_skip_entry compares cur_entry_protocol instead of cur_entry_if_fw_type; the new option is never actually read, and entries without a PROTOCOL key will crash on the dereference of a NULL pointer.
  • I don't understand the purpose or even the origin of the wait macro and the val declaration above it.
  • You have not documented your changes in CONFIG.md. The architecture detection block also seems to be a verbatim copy-paste of common/lib/config.c:415-434, perhaps a shared helper is in order.

@PatrickHechler
Copy link
Copy Markdown
Author

thanks for the quick response

Thanks for the patch. Unfortunately, by understanding, this is completely wrong. Three main issues:

* The `IF_FW_TYPE` block in `should_skip_entry` compares `cur_entry_protocol` instead of `cur_entry_if_fw_type`; the new option is never actually read, and entries without a `PROTOCOL` key will crash on the dereference of a `NULL` pointer.

sorry for that, should be fixed now

* I don't understand the purpose or even the origin of the wait macro and the val declaration above it.

sorry for that, the wait macro was just a breakpoint for debugging

* You have not documented your changes in CONFIG.md. The architecture detection block also seems to be a verbatim copy-paste of common/lib/config.c:415-434, perhaps a shared helper is in order.

I have added documentation to CONFIG.md now.
I didn't want to modify some other place, but yes, it is mostly copy-pasted from config.c and a #define ARCH somewhere may be better (where?).

@PatrickHechler PatrickHechler requested a review from iczelia April 26, 2026 17:09
Copy link
Copy Markdown
Member

@iczelia iczelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other outstanding issues.

Comment thread CONFIG.md Outdated
* `if_fw_type` - Hide the entry if the firmware does not match. Valid values
are: `bios`, `efi` (or `uefi`)
* `if_arch` - Hide the entry if the current CPU architecture is not in the
space seperated list of permitted architecutres
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seperated -> separated.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

architecutres -> architectures

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed now

Comment thread common/menu.c Outdated
if (cur_entry_if_fw_type) {
#if defined (UEFI)
if (strcmp(cur_entry_if_fw_type, "efi") != 0
&& strcmp(cur_entry_if_fw_type, "uefi") != 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new option accepts bios/efi/uefi but the existing FW_TYPE produces BIOS/UEFI. Please either accept both (case-insensitive compare) or switch to the canonical spellings.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using the same value as FW_TYPE makes sense, I just used the bios/efi protocol values (except for the _chainloading values).
should this then too be extracted into a function? (for now I have placed the function current_firmware in misc.h)

Comment thread common/menu.c Outdated
}
char *cur_entry_if_arch = config_get_value(entry->body, 0, "IF_ARCH");
if (cur_entry_if_arch) {
const char *arch;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the deduplicated function can likely take the prototype of static inline const char *current_arch(void) in common/sys/cpu.h.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be now now

Copy link
Copy Markdown
Member

@iczelia iczelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is good enough now.

@PatrickHechler
Copy link
Copy Markdown
Author

thanks for the help

@iczelia iczelia merged commit b2848fb into Limine-Bootloader:trunk Apr 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants