[PATCH 0/7] Improved kernel stub outputs, minor cleanups

2 views
Skip to first unread message

Jan Kiszka

unread,
Apr 7, 2026, 2:29:14 AM (8 days ago) Apr 7
to efibootg...@googlegroups.com
This primarily aligns output of main EBG and kernel stub, make the
services and control logic (--enable-silent-boot) of the former usable
by the latter.

It also brings a small bug fix in an EBG error path and several
code cleanups.

Jan

Jan Kiszka (7):
kernel-stub: Set error code alignment overflow
.gitignore: Add more generated m4 files
Pull print helpers into separate module
Rename GetBootMediumPath to GetMediumPath
Fold bootguard module into utils
Separate internal from external headers on include
kernel-stub: Use common print services

.gitignore | 2 ++
Makefile.am | 4 ++-
bootguard.c | 22 --------------
configure.ac | 2 +-
drivers/utils/simatic.c | 1 +
drivers/utils/smbios.c | 2 +-
drivers/watchdog/amdfch_wdt.c | 4 ++-
drivers/watchdog/atom-quark.c | 2 ++
drivers/watchdog/eiois200_wdt.c | 4 ++-
drivers/watchdog/hpwdt.c | 2 ++
drivers/watchdog/i6300esb.c | 2 ++
drivers/watchdog/ipc4x7e_wdt.c | 4 ++-
drivers/watchdog/ipcbx21a.c | 2 ++
drivers/watchdog/ipmi_wdt.c | 2 ++
drivers/watchdog/itco.c | 4 ++-
drivers/watchdog/w83627hf_wdt.c | 4 ++-
drivers/watchdog/wdat.c | 2 ++
drivers/watchdog/wdfuncs_end.c | 1 +
drivers/watchdog/wdfuncs_start.c | 1 +
env/env_config_file.c | 1 +
env/env_disk_utils.c | 3 +-
env/fatvars.c | 10 ++++---
env/syspart.c | 1 +
env/uservars.c | 1 +
include/bootguard.h | 2 --
include/configuration.h | 3 +-
include/env_api.h | 3 +-
include/env_config_file.h | 2 ++
include/env_config_partitions.h | 1 +
include/env_disk_utils.h | 1 +
include/print.h | 43 +++++++++++++++++++++++++++
include/syspart.h | 1 +
include/utils.h | 24 ++-------------
kernel-stub/fdt.c | 15 ++++++----
kernel-stub/initrd.c | 1 +
kernel-stub/kernel-stub.h | 4 ---
kernel-stub/main.c | 50 ++++++++++++--------------------
loader_interface.c | 1 +
main.c | 15 +++++-----
print.c | 42 +++++++++++++++++++++++++++
utils.c | 29 ++++--------------
41 files changed, 188 insertions(+), 132 deletions(-)
delete mode 100644 bootguard.c
create mode 100644 include/print.h
create mode 100644 print.c

--
2.47.3

Jan Kiszka

unread,
Apr 7, 2026, 2:29:15 AM (8 days ago) Apr 7
to efibootg...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Avoid reporting an error but then not returning a proper error code to
the firmware. Impact is rather cosmetic, latest the watchdog will catch
this early termination.

Fixes: 4b76201933bf ("kernel-stub: Check for overflow when casting to VOID *")
Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
kernel-stub/main.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel-stub/main.c b/kernel-stub/main.c
index 7da9009..5b83eba 100644
--- a/kernel-stub/main.c
+++ b/kernel-stub/main.c
@@ -200,6 +200,7 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
align_addr(kernel_buffer, pe_header->Opt.SectionAlignment);
if ((uintptr_t) aligned_kernel_buffer != aligned_kernel_buffer) {
error(L"Alignment overflow for kernel image", EFI_LOAD_ERROR);
+ status = EFI_LOAD_ERROR;
goto cleanup_buffer;
}

--
2.47.3

Jan Kiszka

unread,
Apr 7, 2026, 2:29:15 AM (8 days ago) Apr 7
to efibootg...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index 713902e..50b8d04 100644
--- a/.gitignore
+++ b/.gitignore
@@ -84,6 +84,8 @@ Makefile.in
.deps/
m4/libtool.m4
m4/lt*
+m4/pkg.m4
+m4/ax_*
version.h
libtool
.libs
--
2.47.3

Jan Kiszka

unread,
Apr 7, 2026, 2:29:15 AM (8 days ago) Apr 7
to efibootg...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

This is retrieving the medium path from the input string, irrespective
if this is where the system booted from.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
include/utils.h | 2 +-
main.c | 2 +-
utils.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/utils.h b/include/utils.h
index 8b99553..982630f 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -38,7 +38,7 @@ EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN *count);
EFI_STATUS close_volumes(VOLUME_DESC *volumes, UINTN count);
EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
CHAR16 *payloadpath);
-CHAR16 *GetBootMediumPath(const CHAR16 *input);
+CHAR16 *GetMediumPath(const CHAR16 *input);

typedef EFI_STATUS (*WATCHDOG_PROBE)(EFI_PCI_IO *, UINT16, UINT16, UINTN);

diff --git a/main.c b/main.c
index aa9ca9b..3db2c91 100644
--- a/main.c
+++ b/main.c
@@ -155,7 +155,7 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
}

tmp = DevicePathToStr(DevicePathFromHandle(loaded_image->DeviceHandle));
- boot_medium_path = GetBootMediumPath(tmp);
+ boot_medium_path = GetMediumPath(tmp);
FreePool(tmp);
INFO(L"Boot medium: %s\n", boot_medium_path);

diff --git a/utils.c b/utils.c
index 178f4a8..c0feb61 100644
--- a/utils.c
+++ b/utils.c
@@ -26,7 +26,7 @@ static BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp)
BOOLEAN result = FALSE;

tmp = DevicePathToStr(dp);
- device_path = GetBootMediumPath(tmp);
+ device_path = GetMediumPath(tmp);
FreePool(tmp);

if (StrCmp(device_path, boot_medium_path) == 0) {
@@ -262,7 +262,7 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
return appendeddevpath;
}

-CHAR16 *GetBootMediumPath(const CHAR16 *input)
+CHAR16 *GetMediumPath(const CHAR16 *input)
{
CHAR16 *dst;
UINTN len;
--
2.47.3

Jan Kiszka

unread,
Apr 7, 2026, 2:29:15 AM (8 days ago) Apr 7
to efibootg...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Will allow reuse by kernel stub.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
Makefile.am | 2 ++
bootguard.c | 2 --
drivers/watchdog/amdfch_wdt.c | 1 +
drivers/watchdog/atom-quark.c | 1 +
drivers/watchdog/eiois200_wdt.c | 1 +
drivers/watchdog/hpwdt.c | 1 +
drivers/watchdog/i6300esb.c | 1 +
drivers/watchdog/ipc4x7e_wdt.c | 1 +
drivers/watchdog/ipcbx21a.c | 1 +
drivers/watchdog/ipmi_wdt.c | 1 +
drivers/watchdog/itco.c | 1 +
drivers/watchdog/w83627hf_wdt.c | 1 +
drivers/watchdog/wdat.c | 1 +
env/fatvars.c | 1 +
env/syspart.c | 1 +
include/bootguard.h | 2 --
include/print.h | 43 +++++++++++++++++++++++++++++++++
include/utils.h | 21 ----------------
main.c | 1 +
print.c | 42 ++++++++++++++++++++++++++++++++
utils.c | 22 +----------------
21 files changed, 102 insertions(+), 46 deletions(-)
create mode 100644 include/print.h
create mode 100644 print.c

diff --git a/Makefile.am b/Makefile.am
index 6dc1df8..9d49828 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -144,6 +144,7 @@ noinst_HEADERS = \
include/syspart.h \
include/test-interface.h \
include/uservars.h \
+ include/print.h \
include/utils.h

#
@@ -236,6 +237,7 @@ efi_sources = \
drivers/watchdog/wdfuncs_end.c \
env/syspart.c \
env/fatvars.c \
+ print.c \
utils.c \
loader_interface.c \
bootguard.c \
diff --git a/bootguard.c b/bootguard.c
index c9c5328..124f333 100644
--- a/bootguard.c
+++ b/bootguard.c
@@ -15,8 +15,6 @@
#include "bootguard.h"
#include "utils.h"

-EFI_HANDLE this_image;
-
VOLUME_DESC *volumes = NULL;
UINTN volume_count = 128;
CHAR16 *boot_medium_path;
diff --git a/drivers/watchdog/amdfch_wdt.c b/drivers/watchdog/amdfch_wdt.c
index 0576892..d7082f1 100644
--- a/drivers/watchdog/amdfch_wdt.c
+++ b/drivers/watchdog/amdfch_wdt.c
@@ -17,6 +17,7 @@
#include <pci/header.h>
#include <sys/io.h>
#include <mmio.h>
+#include "print.h"
#include "utils.h"

/* #define AMDFCH_WDT_DEBUG */
diff --git a/drivers/watchdog/atom-quark.c b/drivers/watchdog/atom-quark.c
index 813eab9..ef891fa 100644
--- a/drivers/watchdog/atom-quark.c
+++ b/drivers/watchdog/atom-quark.c
@@ -16,6 +16,7 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
+#include "print.h"
#include "utils.h"

#define PCI_DEVICE_ID_INTEL_ITC 0x8186
diff --git a/drivers/watchdog/eiois200_wdt.c b/drivers/watchdog/eiois200_wdt.c
index 61855d0..6fd61e9 100644
--- a/drivers/watchdog/eiois200_wdt.c
+++ b/drivers/watchdog/eiois200_wdt.c
@@ -18,6 +18,7 @@
#include <pci/header.h>
#include <sys/io.h>
#include <mmio.h>
+#include "print.h"
#include "smbios.h"
#include "utils.h"

diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 8987558..becea61 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -14,6 +14,7 @@

#include <efi.h>
#include <pci/header.h>
+#include "print.h"
#include "utils.h"

#define PCI_VENDOR_ID_HP 0x103c
diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c
index b19063c..626709b 100644
--- a/drivers/watchdog/i6300esb.c
+++ b/drivers/watchdog/i6300esb.c
@@ -15,6 +15,7 @@
#include <efi.h>
#include <efilib.h>
#include <pci/header.h>
+#include "print.h"
#include "utils.h"

#define PCI_DEVICE_ID_INTEL_ESB_9 0x25ab
diff --git a/drivers/watchdog/ipc4x7e_wdt.c b/drivers/watchdog/ipc4x7e_wdt.c
index c09ddc8..b0bb54f 100644
--- a/drivers/watchdog/ipc4x7e_wdt.c
+++ b/drivers/watchdog/ipc4x7e_wdt.c
@@ -18,6 +18,7 @@
#include <pci/header.h>
#include <sys/io.h>
#include <mmio.h>
+#include "print.h"
#include "simatic.h"
#include "utils.h"

diff --git a/drivers/watchdog/ipcbx21a.c b/drivers/watchdog/ipcbx21a.c
index a1b8a9a..c9f50ea 100644
--- a/drivers/watchdog/ipcbx21a.c
+++ b/drivers/watchdog/ipcbx21a.c
@@ -16,6 +16,7 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
+#include "print.h"
#include "simatic.h"
#include "utils.h"

diff --git a/drivers/watchdog/ipmi_wdt.c b/drivers/watchdog/ipmi_wdt.c
index 610c798..faaab01 100644
--- a/drivers/watchdog/ipmi_wdt.c
+++ b/drivers/watchdog/ipmi_wdt.c
@@ -15,6 +15,7 @@
#include <efi.h>
#include <pci/header.h>
#include <sys/io.h>
+#include "print.h"
#include "smbios.h"
#include "utils.h"

diff --git a/drivers/watchdog/itco.c b/drivers/watchdog/itco.c
index ccd3dfe..d967c5b 100644
--- a/drivers/watchdog/itco.c
+++ b/drivers/watchdog/itco.c
@@ -18,6 +18,7 @@
#include <pci/header.h>
#include <sys/io.h>
#include <mmio.h>
+#include "print.h"
#include "utils.h"

#define SMI_EN_REG 0x30
diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c
index e88182e..94f985b 100644
--- a/drivers/watchdog/w83627hf_wdt.c
+++ b/drivers/watchdog/w83627hf_wdt.c
@@ -41,6 +41,7 @@
#include <pci/header.h>
#include <sys/io.h>
#include <mmio.h>
+#include "print.h"
#include "simatic.h"
#include "utils.h"

diff --git a/drivers/watchdog/wdat.c b/drivers/watchdog/wdat.c
index 15e1e18..975d5b8 100644
--- a/drivers/watchdog/wdat.c
+++ b/drivers/watchdog/wdat.c
@@ -19,6 +19,7 @@
#include <efilib.h>
#include <mmio.h>
#include <sys/io.h>
+#include "print.h"
#include "utils.h"

#define EFI_ACPI_TABLE_GUID \
diff --git a/env/fatvars.c b/env/fatvars.c
index 07c9e85..242d38b 100644
--- a/env/fatvars.c
+++ b/env/fatvars.c
@@ -16,6 +16,7 @@
#include <efilib.h>
#include <efiapi.h>
#include <bootguard.h>
+#include "print.h"
#include <utils.h>
#include <syspart.h>
#include <envdata.h>
diff --git a/env/syspart.c b/env/syspart.c
index 1bcde24..8d89e16 100644
--- a/env/syspart.c
+++ b/env/syspart.c
@@ -13,6 +13,7 @@
*/

#include <syspart.h>
+#include "print.h"
#include <utils.h>
#include <envdata.h>

diff --git a/include/bootguard.h b/include/bootguard.h
index af0f54a..f36740c 100644
--- a/include/bootguard.h
+++ b/include/bootguard.h
@@ -31,8 +31,6 @@ typedef int BG_STATUS;
#define BG_CONFIG_ERROR BGERR(110)
#define BG_NOT_IMPLEMENTED BGERR(200)

-extern EFI_HANDLE this_image;
-
typedef struct _BG_LOADER_PARAMS {
CHAR16 *payload_path;
CHAR16 *payload_options;
diff --git a/include/print.h b/include/print.h
new file mode 100644
index 0000000..2478407
--- /dev/null
+++ b/include/print.h
@@ -0,0 +1,43 @@
+/*
+ * EFI Boot Guard
+ *
+ * Copyright (c) Siemens AG, 2017-2026
+ *
+ * Authors:
+ * Jan Kiszka <jan.k...@siemens.com>
+ * Andreas Reichel <andreas.r...@siemens.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ */
+
+#pragma once
+
+#include <efi.h>
+
+extern EFI_HANDLE this_image;
+
+VOID __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status);
+
+VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...);
+
+#define ERROR(fmt, ...) \
+ do { \
+ PrintC(EFI_LIGHTRED, L"ERROR: "); \
+ PrintC(EFI_LIGHTGRAY, fmt, ##__VA_ARGS__); \
+ } while (0)
+
+#define WARNING(fmt, ...) \
+ do { \
+ PrintC(EFI_YELLOW, L"WARNING: "); \
+ 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/include/utils.h b/include/utils.h
index 54b9a42..8b99553 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -33,7 +33,6 @@ extern UINTN volume_count;

typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE;

-VOID __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status);
CHAR16 *get_volume_label(EFI_FILE_HANDLE fh);
EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN *count);
EFI_STATUS close_volumes(VOLUME_DESC *volumes, UINTN count);
@@ -57,24 +56,4 @@ VOID register_watchdog(WATCHDOG_DRIVER *driver);
register_watchdog(&this_driver); \
}

-VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...);
-#define ERROR(fmt, ...) \
- do { \
- PrintC(EFI_LIGHTRED, L"ERROR: "); \
- PrintC(EFI_LIGHTGRAY, fmt, ##__VA_ARGS__); \
- } while (0)
-
-#define WARNING(fmt, ...) \
- do { \
- PrintC(EFI_YELLOW, L"WARNING: "); \
- 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
-
#define BIT(x) (1UL << (x))
diff --git a/main.c b/main.c
index 83cbcab..aa9ca9b 100644
--- a/main.c
+++ b/main.c
@@ -21,6 +21,7 @@
#include <bootguard.h>
#include <configuration.h>
#include "version.h"
+#include "print.h"
#include "utils.h"
#include "loader_interface.h"

diff --git a/print.c b/print.c
new file mode 100644
index 0000000..cbc1faf
--- /dev/null
+++ b/print.c
@@ -0,0 +1,42 @@
+/*
+ * EFI Boot Guard
+ *
+ * Copyright (c) Siemens AG, 2017-2026
+ *
+ * Authors:
+ * Jan Kiszka <jan.k...@siemens.com>
+ * Andreas Reichel <andreas.r...@siemens.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ *
+ * SPDX-License-Identifier: GPL-2.0-only
+ */
+
+#include <efi.h>
+#include <efilib.h>
+
+#include "print.h"
+
+EFI_HANDLE this_image;
+
+VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...)
+{
+ INT32 attr = ST->ConOut->Mode->Attribute;
+ (VOID) ST->ConOut->SetAttribute(ST->ConOut, color);
+
+ va_list args;
+ va_start(args, fmt);
+ (VOID)VPrint(fmt, args);
+ va_end(args);
+
+ (VOID) ST->ConOut->SetAttribute(ST->ConOut, attr);
+}
+
+VOID __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status)
+{
+ ERROR(L"%s (%r).\n", message, status);
+ (VOID) BS->Stall(3 * 1000 * 1000);
+ (VOID) BS->Exit(this_image, status, 0, NULL);
+ __builtin_unreachable();
+}
diff --git a/utils.c b/utils.c
index 30f8513..178f4a8 100644
--- a/utils.c
+++ b/utils.c
@@ -16,21 +16,9 @@
#include <efi.h>
#include <efilib.h>
#include <bootguard.h>
+#include "print.h"
#include <utils.h>

-VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...)
-{
- INT32 attr = ST->ConOut->Mode->Attribute;
- (VOID) ST->ConOut->SetAttribute(ST->ConOut, color);
-
- va_list args;
- va_start(args, fmt);
- (VOID)VPrint(fmt, args);
- va_end(args);
-
- (VOID) ST->ConOut->SetAttribute(ST->ConOut, attr);
-}
-
static BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp)
{
extern CHAR16 *boot_medium_path;
@@ -49,14 +37,6 @@ static BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp)
return result;
}

-VOID __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status)
-{
- ERROR(L"%s (%r).\n", message, status);
- (VOID) BS->Stall(3 * 1000 * 1000);
- (VOID) BS->Exit(this_image, status, 0, NULL);
- __builtin_unreachable();
-}
-
CHAR16 *get_volume_label(EFI_FILE_HANDLE fh)
{
EFI_FILE_SYSTEM_INFO *fsi;
--
2.47.3

Jan Kiszka

unread,
Apr 7, 2026, 2:29:16 AM (8 days ago) Apr 7
to efibootg...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Make it easier to spot where headers are coming from: External ones are
included via angle brackets, internal ones are put in quotes - even if
not technically needed - and separated into an own include block.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
drivers/utils/simatic.c | 1 +
drivers/utils/smbios.c | 2 +-
drivers/watchdog/amdfch_wdt.c | 3 ++-
drivers/watchdog/atom-quark.c | 1 +
drivers/watchdog/eiois200_wdt.c | 3 ++-
drivers/watchdog/hpwdt.c | 1 +
drivers/watchdog/i6300esb.c | 1 +
drivers/watchdog/ipc4x7e_wdt.c | 3 ++-
drivers/watchdog/ipcbx21a.c | 1 +
drivers/watchdog/ipmi_wdt.c | 1 +
drivers/watchdog/itco.c | 3 ++-
drivers/watchdog/w83627hf_wdt.c | 3 ++-
drivers/watchdog/wdat.c | 1 +
drivers/watchdog/wdfuncs_end.c | 1 +
drivers/watchdog/wdfuncs_start.c | 1 +
env/env_config_file.c | 1 +
env/env_disk_utils.c | 3 ++-
env/fatvars.c | 9 +++++----
env/uservars.c | 1 +
include/configuration.h | 3 ++-
include/env_api.h | 3 ++-
include/env_config_file.h | 2 ++
include/env_config_partitions.h | 1 +
include/env_disk_utils.h | 1 +
include/syspart.h | 1 +
loader_interface.c | 1 +
main.c | 9 +++++----
27 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/drivers/utils/simatic.c b/drivers/utils/simatic.c
index 777fc1a..46db70f 100644
--- a/drivers/utils/simatic.c
+++ b/drivers/utils/simatic.c
@@ -16,6 +16,7 @@

#include <efi.h>
#include <efilib.h>
+
#include "simatic.h"
#include "smbios.h"
#include "utils.h"
diff --git a/drivers/utils/smbios.c b/drivers/utils/smbios.c
index 8b75132..18a052f 100644
--- a/drivers/utils/smbios.c
+++ b/drivers/utils/smbios.c
@@ -13,7 +13,7 @@
* SPDX-License-Identifier: GPL-2.0-only
*/

-#include <smbios.h>
+#include "smbios.h"

SMBIOS_STRUCTURE_POINTER smbios_find_struct(SMBIOS_STRUCTURE_TABLE *table,
UINT16 type)
diff --git a/drivers/watchdog/amdfch_wdt.c b/drivers/watchdog/amdfch_wdt.c
index d7082f1..15b5bdd 100644
--- a/drivers/watchdog/amdfch_wdt.c
+++ b/drivers/watchdog/amdfch_wdt.c
@@ -16,7 +16,8 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
-#include <mmio.h>
+
+#include "mmio.h"
#include "print.h"
#include "utils.h"

diff --git a/drivers/watchdog/atom-quark.c b/drivers/watchdog/atom-quark.c
index ef891fa..a4c88e1 100644
--- a/drivers/watchdog/atom-quark.c
+++ b/drivers/watchdog/atom-quark.c
@@ -16,6 +16,7 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
+
#include "print.h"
#include "utils.h"

diff --git a/drivers/watchdog/eiois200_wdt.c b/drivers/watchdog/eiois200_wdt.c
index 6fd61e9..b7be223 100644
--- a/drivers/watchdog/eiois200_wdt.c
+++ b/drivers/watchdog/eiois200_wdt.c
@@ -17,7 +17,8 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
-#include <mmio.h>
+
+#include "mmio.h"
#include "print.h"
#include "smbios.h"
#include "utils.h"
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index becea61..64af90b 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -14,6 +14,7 @@

#include <efi.h>
#include <pci/header.h>
+
#include "print.h"
#include "utils.h"

diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c
index 626709b..b60dbbe 100644
--- a/drivers/watchdog/i6300esb.c
+++ b/drivers/watchdog/i6300esb.c
@@ -15,6 +15,7 @@
#include <efi.h>
#include <efilib.h>
#include <pci/header.h>
+
#include "print.h"
#include "utils.h"

diff --git a/drivers/watchdog/ipc4x7e_wdt.c b/drivers/watchdog/ipc4x7e_wdt.c
index b0bb54f..899756e 100644
--- a/drivers/watchdog/ipc4x7e_wdt.c
+++ b/drivers/watchdog/ipc4x7e_wdt.c
@@ -17,7 +17,8 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
-#include <mmio.h>
+
+#include "mmio.h"
#include "print.h"
#include "simatic.h"
#include "utils.h"
diff --git a/drivers/watchdog/ipcbx21a.c b/drivers/watchdog/ipcbx21a.c
index c9f50ea..92d83f3 100644
--- a/drivers/watchdog/ipcbx21a.c
+++ b/drivers/watchdog/ipcbx21a.c
@@ -16,6 +16,7 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
+
#include "print.h"
#include "simatic.h"
#include "utils.h"
diff --git a/drivers/watchdog/ipmi_wdt.c b/drivers/watchdog/ipmi_wdt.c
index faaab01..b088c61 100644
--- a/drivers/watchdog/ipmi_wdt.c
+++ b/drivers/watchdog/ipmi_wdt.c
@@ -15,6 +15,7 @@
#include <efi.h>
#include <pci/header.h>
#include <sys/io.h>
+
#include "print.h"
#include "smbios.h"
#include "utils.h"
diff --git a/drivers/watchdog/itco.c b/drivers/watchdog/itco.c
index d967c5b..c6ef030 100644
--- a/drivers/watchdog/itco.c
+++ b/drivers/watchdog/itco.c
@@ -17,7 +17,8 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
-#include <mmio.h>
+
+#include "mmio.h"
#include "print.h"
#include "utils.h"

diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c
index 94f985b..5e037a4 100644
--- a/drivers/watchdog/w83627hf_wdt.c
+++ b/drivers/watchdog/w83627hf_wdt.c
@@ -40,7 +40,8 @@
#include <efilib.h>
#include <pci/header.h>
#include <sys/io.h>
-#include <mmio.h>
+
+#include "mmio.h"
#include "print.h"
#include "simatic.h"
#include "utils.h"
diff --git a/drivers/watchdog/wdat.c b/drivers/watchdog/wdat.c
index 975d5b8..0dfc581 100644
--- a/drivers/watchdog/wdat.c
+++ b/drivers/watchdog/wdat.c
@@ -19,6 +19,7 @@
#include <efilib.h>
#include <mmio.h>
#include <sys/io.h>
+
#include "print.h"
#include "utils.h"

diff --git a/drivers/watchdog/wdfuncs_end.c b/drivers/watchdog/wdfuncs_end.c
index f90ffc7..97bd6a1 100644
--- a/drivers/watchdog/wdfuncs_end.c
+++ b/drivers/watchdog/wdfuncs_end.c
@@ -15,6 +15,7 @@
#if GNU_EFI_VERSION < 3000016

#include <efi.h>
+
#include "utils.h"

/* Section .init_array's end address for watchdog probing function pointers
diff --git a/drivers/watchdog/wdfuncs_start.c b/drivers/watchdog/wdfuncs_start.c
index c627050..b564fff 100644
--- a/drivers/watchdog/wdfuncs_start.c
+++ b/drivers/watchdog/wdfuncs_start.c
@@ -15,6 +15,7 @@
#if GNU_EFI_VERSION < 3000016

#include <efi.h>
+
#include "utils.h"

/* Section .init_array's sentinel value and start address for watchdog probing
diff --git a/env/env_config_file.c b/env/env_config_file.c
index 03c618a..a81be35 100644
--- a/env/env_config_file.c
+++ b/env/env_config_file.c
@@ -14,6 +14,7 @@

#include <stdlib.h>
#include <stdio.h>
+
#include "env_api.h"
#include "env_disk_utils.h"
#include "env_config_file.h"
diff --git a/env/env_disk_utils.c b/env/env_disk_utils.c
index bcf9f80..25e7ce9 100644
--- a/env/env_disk_utils.c
+++ b/env/env_disk_utils.c
@@ -12,9 +12,10 @@
* SPDX-License-Identifier: GPL-2.0-only
*/

-#include <stdlib.h>
#include <mntent.h>
+#include <stdlib.h>
#include <string.h>
+
#include "env_api.h"
#include "env_disk_utils.h"

diff --git a/env/fatvars.c b/env/fatvars.c
index 242d38b..76934f5 100644
--- a/env/fatvars.c
+++ b/env/fatvars.c
@@ -15,11 +15,12 @@
#include <efi.h>
#include <efilib.h>
#include <efiapi.h>
-#include <bootguard.h>
+
+#include "bootguard.h"
+#include "envdata.h"
#include "print.h"
-#include <utils.h>
-#include <syspart.h>
-#include <envdata.h>
+#include "syspart.h"
+#include "utils.h"

static int current_partition = 0;
static BG_ENVDATA *env;
diff --git a/env/uservars.c b/env/uservars.c
index 145ed5d..2fafa7d 100644
--- a/env/uservars.c
+++ b/env/uservars.c
@@ -13,6 +13,7 @@
*/

#include <string.h>
+
#include "env_api.h"
#include "uservars.h"

diff --git a/include/configuration.h b/include/configuration.h
index b172943..92ed0ef 100644
--- a/include/configuration.h
+++ b/include/configuration.h
@@ -18,7 +18,8 @@
#include <efilib.h>
#include <efiprot.h>
#include <efipciio.h>
-#include <bootguard.h>
+
+#include "bootguard.h"

BG_STATUS load_config(BG_LOADER_PARAMS *bg_loader_params);
BG_STATUS save_config(BG_LOADER_PARAMS *bg_loader_params);
diff --git a/include/env_api.h b/include/env_api.h
index 24b2414..5778d84 100644
--- a/include/env_api.h
+++ b/include/env_api.h
@@ -25,12 +25,13 @@
#include <argp.h>
#include <mntent.h>
#include <fcntl.h>
+#include <uchar.h>
#include <sys/file.h>
#include <sys/mount.h>
+
#include "config.h"
#include "envdata.h"
#include "ebgenv.h"
-#include <uchar.h>

#ifdef DEBUG
#define printf_debug(fmt, ...) printf(fmt, __VA_ARGS__)
diff --git a/include/env_config_file.h b/include/env_config_file.h
index a95b395..91ed089 100644
--- a/include/env_config_file.h
+++ b/include/env_config_file.h
@@ -13,7 +13,9 @@
*/

#pragma once
+
#include <stdio.h>
+
#include "env_api.h"

FILE *open_config_file_from_part(const CONFIG_PART *cfgpart, const char *mode);
diff --git a/include/env_config_partitions.h b/include/env_config_partitions.h
index 4b6d2d9..bef5f15 100644
--- a/include/env_config_partitions.h
+++ b/include/env_config_partitions.h
@@ -15,6 +15,7 @@
#pragma once

#include <stdbool.h>
+
#include "env_api.h"

bool probe_config_partitions(CONFIG_PART *cfgpart, bool search_all_devices);
diff --git a/include/env_disk_utils.h b/include/env_disk_utils.h
index cec93c1..f1c1ce2 100644
--- a/include/env_disk_utils.h
+++ b/include/env_disk_utils.h
@@ -15,6 +15,7 @@
#pragma once

#include <stdbool.h>
+
#include "env_api.h"

char *get_mountpoint(const char *devpath);
diff --git a/include/syspart.h b/include/syspart.h
index e7686e9..21d5750 100644
--- a/include/syspart.h
+++ b/include/syspart.h
@@ -18,6 +18,7 @@
#include <efilib.h>
#include <efiprot.h>
#include <efipciio.h>
+
#include "bootguard.h"

#define open_cfg_file(root, file, mode) \
diff --git a/loader_interface.c b/loader_interface.c
index e4d5d05..8d9e6ea 100644
--- a/loader_interface.c
+++ b/loader_interface.c
@@ -14,6 +14,7 @@

#include <efi.h>
#include <efilib.h>
+
#include "loader_interface.h"
#include "utils.h"

diff --git a/main.c b/main.c
index 5d28d08..5e9142c 100644
--- a/main.c
+++ b/main.c
@@ -18,12 +18,13 @@
#include <efiprot.h>
#include <efipciio.h>
#include <pci/header.h>
-#include <bootguard.h>
-#include <configuration.h>
-#include "version.h"
+
+#include "bootguard.h"
+#include "configuration.h"
+#include "loader_interface.h"
#include "print.h"
#include "utils.h"
-#include "loader_interface.h"
+#include "version.h"

extern const unsigned long wdfuncs_start[];
extern const unsigned long wdfuncs_end[];
--
2.47.3

Jan Kiszka

unread,
Apr 7, 2026, 2:29:17 AM (8 days ago) Apr 7
to efibootg...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

No need for a separate module to hold those three global variables. Keep
them in utils where they are already referenced, besides main.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
Makefile.am | 1 -
bootguard.c | 20 --------------------
configure.ac | 2 +-
include/utils.h | 1 +
main.c | 3 +--
utils.c | 5 ++++-
6 files changed, 7 insertions(+), 25 deletions(-)
delete mode 100644 bootguard.c

diff --git a/Makefile.am b/Makefile.am
index 9d49828..a4cf201 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -240,7 +240,6 @@ efi_sources = \
print.c \
utils.c \
loader_interface.c \
- bootguard.c \
main.c

kernel_stub_name = kernel-stub$(MACHINE_TYPE_NAME).efi
diff --git a/bootguard.c b/bootguard.c
deleted file mode 100644
index 124f333..0000000
--- a/bootguard.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * EFI Boot Guard
- *
- * Copyright (c) Siemens AG, 2017
- *
- * Authors:
- * Andreas Reichel <andreas.r...@siemens.com>
- *
- * This work is licensed under the terms of the GNU GPL, version 2. See
- * the COPYING file in the top-level directory.
- *
- * SPDX-License-Identifier: GPL-2.0-only
- */
-
-#include "bootguard.h"
-#include "utils.h"
-
-VOLUME_DESC *volumes = NULL;
-UINTN volume_count = 128;
-CHAR16 *boot_medium_path;
diff --git a/configure.ac b/configure.ac
index 8f78875..9f41b30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ AC_INIT([efibootguard],
[efibootguard],
[])

-AC_CONFIG_SRCDIR([bootguard.c])
+AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
diff --git a/include/utils.h b/include/utils.h
index 982630f..2860258 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -30,6 +30,7 @@ typedef struct _VOLUME_DESC {

extern VOLUME_DESC *volumes;
extern UINTN volume_count;
+extern CHAR16 *boot_medium_path;

typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE;

diff --git a/main.c b/main.c
index 3db2c91..5d28d08 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,7 @@
/*
* EFI Boot Guard
*
- * Copyright (c) Siemens AG, 2017-2025
+ * Copyright (c) Siemens AG, 2017-2026
*
* Authors:
* Jan Kiszka <jan.k...@siemens.com>
@@ -27,7 +27,6 @@

extern const unsigned long wdfuncs_start[];
extern const unsigned long wdfuncs_end[];
-extern CHAR16 *boot_medium_path;

#define PCI_GET_VENDOR_ID(id) (UINT16)(id)
#define PCI_GET_PRODUCT_ID(id) (UINT16)((id) >> 16)
diff --git a/utils.c b/utils.c
index c0feb61..99813be 100644
--- a/utils.c
+++ b/utils.c
@@ -19,9 +19,12 @@
#include "print.h"
#include <utils.h>

+VOLUME_DESC *volumes;
+UINTN volume_count;
+CHAR16 *boot_medium_path;
+
static BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp)
{
- extern CHAR16 *boot_medium_path;
CHAR16 *device_path, *tmp;
BOOLEAN result = FALSE;

--
2.47.3

Jan Kiszka

unread,
Apr 7, 2026, 2:29:17 AM (8 days ago) Apr 7
to efibootg...@googlegroups.com
From: Jan Kiszka <jan.k...@siemens.com>

Align the kernel stub to the print services that the EBG core uses as
well. That brings coloring, silent boot, and avoids duplicating
logic between both.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
Makefile.am | 1 +
kernel-stub/fdt.c | 15 +++++++-----
kernel-stub/initrd.c | 1 +
kernel-stub/kernel-stub.h | 4 ----
kernel-stub/main.c | 49 ++++++++++++++-------------------------
5 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a4cf201..7c87244 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -246,6 +246,7 @@ kernel_stub_name = kernel-stub$(MACHINE_TYPE_NAME).efi

kernel_stub_sources = \
loader_interface.c \
+ print.c \
kernel-stub/fdt.c \
kernel-stub/initrd.c \
kernel-stub/main.c
diff --git a/kernel-stub/fdt.c b/kernel-stub/fdt.c
index e10b891..90a27cd 100644
--- a/kernel-stub/fdt.c
+++ b/kernel-stub/fdt.c
@@ -1,7 +1,7 @@
/*
* EFI Boot Guard, unified kernel stub
*
- * Copyright (c) Siemens AG, 2022
+ * Copyright (c) Siemens AG, 2022-2026
*
* Authors:
* Jan Kiszka <jan.k...@siemens.com>
@@ -18,6 +18,7 @@
#include <endian.h>

#include "kernel-stub.h"
+#include "print.h"

#if __BYTE_ORDER == __LITTLE_ENDIAN
#define BE32_TO_HOST(val) bswap_32(val)
@@ -163,7 +164,7 @@ static EFI_STATUS clone_fdt(const VOID *fdt, UINTN size,
status = BS->AllocatePages(AllocateAnyPages, EfiACPIReclaimMemory,
SIZE_IN_PAGES(size), fdt_buffer);
if (EFI_ERROR(status)) {
- error(L"Error allocating device tree buffer", status);
+ ERROR(L"Failed to allocate device tree buffer\n");
return status;
}
CopyMem((VOID *)(uintptr_t)*fdt_buffer, (VOID*)fdt,
@@ -182,7 +183,7 @@ EFI_STATUS replace_fdt(const VOID *fdt)
if (EFI_ERROR(status)) {
const FDT_HEADER *header = fdt;

- info(L"Firmware does not provide device tree fixup protocol");
+ WARNING(L"Firmware does not provide device tree fixup protocol\n");

size = BE32_TO_HOST(header->TotalSize);
status = clone_fdt(fdt, size, &fdt_buffer);
@@ -195,7 +196,8 @@ EFI_STATUS replace_fdt(const VOID *fdt)
status = protocol->Fixup(protocol, (VOID *) fdt, &size,
EFI_DT_APPLY_FIXUPS);
if (status != EFI_BUFFER_TOO_SMALL) {
- error(L"Device tree fixup: unexpected error", status);
+ ERROR(L"Early device tree fixup failure (%r)\n",
+ status);
return status;
}

@@ -210,7 +212,7 @@ EFI_STATUS replace_fdt(const VOID *fdt)
EFI_DT_RESERVE_MEMORY);
if (EFI_ERROR(status)) {
(VOID) BS->FreePages(fdt_buffer, SIZE_IN_PAGES(size));
- error(L"Device tree fixup failed", status);
+ ERROR(L"Device tree fixup failed (%r)\n", status);
return status;
}
}
@@ -219,7 +221,8 @@ EFI_STATUS replace_fdt(const VOID *fdt)
(VOID *)(uintptr_t)fdt_buffer);
if (EFI_ERROR(status)) {
(VOID) BS->FreePages(fdt_buffer, SIZE_IN_PAGES(size));
- error(L"Failed to install alternative device tree", status);
+ ERROR(L"Failed to install alternative device tree (%r)\n",
+ status);
}

return status;
diff --git a/kernel-stub/initrd.c b/kernel-stub/initrd.c
index 969acca..346ac8d 100644
--- a/kernel-stub/initrd.c
+++ b/kernel-stub/initrd.c
@@ -16,6 +16,7 @@
#include <efilib.h>

#include "kernel-stub.h"
+#include "print.h"

typedef struct {
VENDOR_DEVICE_PATH vendor;
diff --git a/kernel-stub/kernel-stub.h b/kernel-stub/kernel-stub.h
index b0f10df..fd6322c 100644
--- a/kernel-stub/kernel-stub.h
+++ b/kernel-stub/kernel-stub.h
@@ -14,10 +14,6 @@

#include <efi.h>

-VOID error(CHAR16 *message, EFI_STATUS status);
-VOID __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status);
-VOID info(CHAR16 *message);
-
const VOID *get_fdt_compatible(VOID);
BOOLEAN match_fdt(const VOID *fdt, const CHAR8 *compatible);
EFI_STATUS replace_fdt(const VOID *fdt);
diff --git a/kernel-stub/main.c b/kernel-stub/main.c
index 5b83eba..9d77dcf 100644
--- a/kernel-stub/main.c
+++ b/kernel-stub/main.c
@@ -16,8 +16,9 @@
#include <efilib.h>

#include "kernel-stub.h"
-#include "version.h"
#include "loader_interface.h"
+#include "print.h"
+#include "version.h"

typedef struct {
UINT8 Ignore[60];
@@ -55,7 +56,6 @@ typedef struct {
UINT8 Ignore[24];
} __attribute__((packed)) SECTION;

-static EFI_HANDLE this_image;
static EFI_LOADED_IMAGE kernel_image;

EFI_PHYSICAL_ADDRESS align_addr(EFI_PHYSICAL_ADDRESS ptr,
@@ -64,24 +64,6 @@ EFI_PHYSICAL_ADDRESS align_addr(EFI_PHYSICAL_ADDRESS ptr,
return (ptr + align - 1) & ~(align - 1);
}

-VOID info(CHAR16 *message)
-{
- Print(L"Unified kernel stub: %s\n", message);
-}
-
-VOID error(CHAR16 *message, EFI_STATUS status)
-{
- Print(L"Unified kernel stub: %s (%r).\n", message, status);
- (VOID) BS->Stall(3 * 1000 * 1000);
-}
-
-VOID __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status)
-{
- error(message, status);
- (VOID) BS->Exit(this_image, status, 0, NULL);
- __builtin_unreachable();
-}
-
static const PE_HEADER *get_pe_header(const VOID *image)
{
const DOS_HEADER *dos_header = image;
@@ -119,8 +101,10 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
this_image = image_handle;
InitializeLib(image_handle, system_table);

- Print(L"Unified kernel stub (EFI Boot Guard %s)\n",
- L"" EFIBOOTGUARD_VERSION);
+#if !defined(SILENT_BOOT)
+ PrintC(EFI_CYAN, L"Unified kernel stub (EFI Boot Guard %s)\n",
+ L"" EFIBOOTGUARD_VERSION);
+#endif

fdt_compatible = get_fdt_compatible();

@@ -133,7 +117,7 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)

/* consider zero-termination for string length */
if (stub_image->LoadOptionsSize > sizeof(CHAR16)) {
- info(L"WARNING: Passed command line options ignored, only built-in used");
+ WARNING(L"Passed command line options ignored, only built-in used\n");
}

pe_header = get_pe_header(stub_image->ImageBase);
@@ -192,14 +176,14 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData,
kernel_pages, &kernel_buffer);
if (EFI_ERROR(status)) {
- error(L"Error allocating memory for kernel image", status);
+ ERROR(L"Could not allocate memory for kernel image\n");
goto cleanup_initrd;
}

aligned_kernel_buffer =
align_addr(kernel_buffer, pe_header->Opt.SectionAlignment);
if ((uintptr_t) aligned_kernel_buffer != aligned_kernel_buffer) {
- error(L"Alignment overflow for kernel image", EFI_LOAD_ERROR);
+ ERROR(L"Alignment overflow for kernel image\n");
status = EFI_LOAD_ERROR;
goto cleanup_buffer;
}
@@ -216,7 +200,7 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
&kernel_handle, &LoadedImageProtocol, &kernel_image,
NULL);
if (EFI_ERROR(status)) {
- error(L"Error registering kernel image", status);
+ ERROR(L"Registering kernel image failed (%r)\n", status);
goto cleanup_buffer;
}

@@ -225,12 +209,12 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
if (EFI_ERROR(status)) {
goto cleanup_protocols;
}
- info(L"Using matched embedded device tree");
+ INFO(L"Using matched embedded device tree\n");
} else if (fdt_compatible) {
if (has_dtbs) {
- info(L"WARNING: No embedded device tree matched firmware-provided one");
+ WARNING(L"No embedded device tree matched firmware-provided one\n");
}
- info(L"Using firmware-provided device tree");
+ INFO(L"Using firmware-provided device tree\n");
}

UINT16 *boot_medium_uuidstr =
@@ -238,7 +222,7 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
bg_interface_params.loader_device_part_uuid = boot_medium_uuidstr;
status = set_bg_interface_vars(&bg_interface_params);
if (EFI_ERROR(status)) {
- error(L"could not set interface vars", status);
+ WARNING(L"Could not set interface vars (%r)\n", status);
}
FreePool(boot_medium_uuidstr);

@@ -253,7 +237,7 @@ cleanup_protocols:
kernel_handle, &LoadedImageProtocol, &kernel_image,
NULL);
if (EFI_ERROR(cleanup_status)) {
- error(L"Error unregistering kernel image", status);
+ ERROR(L"Unregistering kernel image failed (%r)\n", status);
if (!EFI_ERROR(status)) {
status = cleanup_status;
}
@@ -263,5 +247,8 @@ cleanup_buffer:
cleanup_initrd:
uninstall_initrd_loader();

+ if (EFI_ERROR(status)) {
+ (VOID) BS->Stall(3 * 1000 * 1000);
+ }
return status;
}
--
2.47.3

Reply all
Reply to author
Forward
0 new messages