Skip to contentSkip to conversation

Detecting running platform (specifically EFI) during runtime?

DISCUSSION Andrey Borzenkov 3 participants 3 messages Jan 5, 2013 – Jan 7, 2013

lore
Share & tools
lore
#0 lore raw

Is it possible to check at run-time on which platform we are running. Specifically, any way to distinguish between EFI and legacy BIOS?

TIA

-andrey

#1 lore raw
Quoted 12 lines · Andrey Borzenkov

Is it possible to check at run-time on which platform we are running. Specifically, any way to distinguish between EFI and legacy BIOS?

TIA

-andrey

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Something like below should work (requires grub 2.00, not 1.99):

[CODE - part of grub.cfg]
if [ "${grub_platform}" == "efi" ]; then

    set _GRUB_PLATFORM="UEFI"

    if [ "${grub_cpu}" == "x86_64" ]; then
        set _UEFI_ARCH="x64"
    fi

    if [ "${grub_cpu}" == "i386" ]; then
        set _UEFI_ARCH="ia32"
    fi

    insmod efi_gop
    insmod efi_uga

fi

if [ "${grub_platform}" == "pc" ]; then
set _GRUB_PLATFORM="BIOS"

insmod vbe
insmod vga
fi
[/CODE]

Regards.

Keshav

#2 lore raw
Quoted 11 lines · Keshav P R
Quoted 2 lines · Andrey Borzenkov

Is it possible to check at run-time on which platform we are running. Specifically, any way to distinguish between EFI and legacy BIOS?

Something like below should work (requires grub 2.00, not 1.99):

[CODE - part of grub.cfg]
if [ "${grub_platform}" == "efi" ]; then

    set _GRUB_PLATFORM="UEFI"

    if [ "${grub_cpu}" == "x86_64" ]; then

I have now documented the grub_cpu and grub_platform environment variables in docs/grub.texi in trunk. (When explaining something not documented in the manual, please consider whether it would be useful to propose a documentation patch.)

Cheers,

Signature · 1 line
Colin Watson                                       [[email protected]]