From 52e039e00be77016a752ff77ee7e6e1d4a3f1c00 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 15 Mar 2024 22:35:07 +0300 Subject: [PATCH] efi: Enable CMOS on x86 EFI platforms The CMOS actually exists on most EFI platforms and in some cases is used to store useful data that makes it justifiable for GRUB to read/write it. As for date and time keep using EFI API and not CMOS one. Signed-off-by: Vladimir Serbinenko Reviewed-by: Daniel Kiper --- grub-core/Makefile.core.def | 4 ++++ grub-core/commands/i386/cmostest.c | 6 +++--- include/grub/x86_64/cmos.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 include/grub/x86_64/cmos.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 1571421d7..007ff628e 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -714,12 +714,16 @@ module = { name = cmostest; common = commands/i386/cmostest.c; enable = cmos; + enable = i386_efi; + enable = x86_64_efi; }; module = { name = cmosdump; common = commands/i386/cmosdump.c; enable = cmos; + enable = i386_efi; + enable = x86_64_efi; }; module = { diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c index 9f6b56a2f..1f0c5341d 100644 --- a/grub-core/commands/i386/cmostest.c +++ b/grub-core/commands/i386/cmostest.c @@ -104,13 +104,13 @@ static grub_command_t cmd, cmd_clean, cmd_set; GRUB_MOD_INIT(cmostest) { - cmd = grub_register_command ("cmostest", grub_cmd_cmostest, + cmd = grub_register_command_lockdown ("cmostest", grub_cmd_cmostest, N_("BYTE:BIT"), N_("Test bit at BYTE:BIT in CMOS.")); - cmd_clean = grub_register_command ("cmosclean", grub_cmd_cmosclean, + cmd_clean = grub_register_command_lockdown ("cmosclean", grub_cmd_cmosclean, N_("BYTE:BIT"), N_("Clear bit at BYTE:BIT in CMOS.")); - cmd_set = grub_register_command ("cmosset", grub_cmd_cmosset, + cmd_set = grub_register_command_lockdown ("cmosset", grub_cmd_cmosset, N_("BYTE:BIT"), /* TRANSLATORS: A bit may be either set (1) or clear (0). */ N_("Set bit at BYTE:BIT in CMOS.")); diff --git a/include/grub/x86_64/cmos.h b/include/grub/x86_64/cmos.h new file mode 100644 index 000000000..03722f805 --- /dev/null +++ b/include/grub/x86_64/cmos.h @@ -0,0 +1 @@ +#include