[PATCH] Add silent boot feature

15 views
Skip to first unread message

Storm, Christian

unread,
Feb 9, 2024, 2:01:21 AM2/9/24
to efibootg...@googlegroups.com
Implemented as compile-time switch, enabling silent boot
suppresses informational messages by EFI Boot Guard so
that, e.g., EFI splash screens are not overwritten.
Warning and error messages will still be printed.

Signed-off-by: Christian Storm <christi...@siemens.com>
---
configure.ac | 10 ++++++++++
include/utils.h | 4 ++++
main.c | 2 ++
3 files changed, 16 insertions(+)

diff --git a/configure.ac b/configure.ac
index b000603..bbd6ffb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,6 +190,15 @@ AC_ARG_ENABLE([bootloader],
AS_HELP_STRING([--disable-bootloader], [Compile the bootloader disabled, only make the tools]),
, [enable_bootloader="yes"])

+AC_ARG_ENABLE([silent-boot],
+ AS_HELP_STRING([--enable-silent-boot], [Do not output informational messages while booting]),
+ [silent_boot="yes"], [silent_boot="no"]
+)
+
+if test "x$silent_boot" != "xno"; then
+ AC_DEFINE([SILENT_BOOT], [] , [Silent Boot])
+fi
+
dnl pkg-config
PKG_PROG_PKG_CONFIG()
if test "x$PKG_CONFIG" = "xno"; then
@@ -236,6 +245,7 @@ AC_MSG_RESULT([
machine type: $MACHINE_TYPE_NAME

build efi bootloader: ${enable_bootloader}
+ silent boot: ${silent_boot}
enable shell completion: ${enable_completion}

prefix: ${prefix}
diff --git a/include/utils.h b/include/utils.h
index 084796e..bb9efda 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -54,5 +54,9 @@ VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...);
PrintC(EFI_LIGHTGRAY, fmt, ##__VA_ARGS__); \
} while (0)

+#if !defined(SILENT_BOOT)
#define INFO(fmt, ...) \
PrintC(EFI_LIGHTGRAY, fmt, ##__VA_ARGS__)
+#else
+#define INFO(fmt, ...) do { } while (0)
+#endif
diff --git a/main.c b/main.c
index 0ff121a..0776eb0 100644
--- a/main.c
+++ b/main.c
@@ -122,8 +122,10 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
this_image = image_handle;
InitializeLib(this_image, system_table);

+ #if !defined(SILENT_BOOT)
(VOID) ST->ConOut->ClearScreen(ST->ConOut);
PrintC(EFI_CYAN, L"EFI Boot Guard %s\n", L"" EFIBOOTGUARD_VERSION);
+ #endif

status = BS->OpenProtocol(this_image, &LoadedImageProtocol,
(VOID **)&loaded_image, this_image, NULL,
--
2.43.0

Jan Kiszka

unread,
Feb 12, 2024, 3:28:38 AM2/12/24
to Storm, Christian, efibootg...@googlegroups.com
Wrong spot, moving to the end of the configs.

> enable shell completion: ${enable_completion}
>
> prefix: ${prefix}
> diff --git a/include/utils.h b/include/utils.h
> index 084796e..bb9efda 100644
> --- a/include/utils.h
> +++ b/include/utils.h
> @@ -54,5 +54,9 @@ VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...);
> PrintC(EFI_LIGHTGRAY, fmt, ##__VA_ARGS__); \
> } while (0)
>
> +#if !defined(SILENT_BOOT)
> #define INFO(fmt, ...) \
> PrintC(EFI_LIGHTGRAY, fmt, ##__VA_ARGS__)
> +#else
> +#define INFO(fmt, ...) do { } while (0)
> +#endif
> diff --git a/main.c b/main.c
> index 0ff121a..0776eb0 100644
> --- a/main.c
> +++ b/main.c
> @@ -122,8 +122,10 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
> this_image = image_handle;
> InitializeLib(this_image, system_table);
>
> + #if !defined(SILENT_BOOT)

Wrong indention, fixing up.

> (VOID) ST->ConOut->ClearScreen(ST->ConOut);
> PrintC(EFI_CYAN, L"EFI Boot Guard %s\n", L"" EFIBOOTGUARD_VERSION);
> + #endif
>
> status = BS->OpenProtocol(this_image, &LoadedImageProtocol,
> (VOID **)&loaded_image, this_image, NULL,

Applied with the adjustments above.

Thanks,
Jan

--
Siemens AG, Technology
Linux Expert Center

Reply all
Reply to author
Forward
0 new messages