From: Jan Kiszka <
jan.k...@siemens.com>
Introduce a build-time switch that signals whether there are watchdog
drivers available for a target. If not set, we can drop more bits from
the build and print more precise output.
Makefile.am | 34 +++++++++++++++++++---------------
configure.ac | 6 ++++++
main.c | 11 +++++++++++
scripts/cppcheck.sh | 2 +-
4 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index fe1b07c..9025241 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -207,6 +207,20 @@ efi_loadername = efibootguard$(MACHINE_TYPE_NAME).efi
if BOOTLOADER
+efi_sources = \
+ env/syspart.c \
+ env/fatvars.c \
+ print.c \
+ utils.c \
+ loader_interface.c \
+ main.c
+
+watchdog_sources = \
+ drivers/watchdog/wdfuncs_start.c \
+ $(efi_sources_watchdogs) \
+ drivers/watchdog/wdfuncs_end.c \
+ watchdog.c
+
# NOTE: wdat.c is placed first so it is tried before any other drivers
# NOTE: ipcbx21a.c must be *before* itco.c
# NOTE: ipc4x7e_wdt.c must be *before* itco.c
@@ -226,22 +240,12 @@ watchdog_sources_x86 = \
drivers/utils/simatic.c \
drivers/utils/smbios.c
if ARCH_IS_X86
-efi_sources_watchdogs = $(watchdog_sources_x86)
-else
-efi_sources_watchdogs =
+watchdog_sources += $(watchdog_sources_x86)
endif
-efi_sources = \
- drivers/watchdog/wdfuncs_start.c \
- $(efi_sources_watchdogs) \
- drivers/watchdog/wdfuncs_end.c \
- watchdog.c \
- env/syspart.c \
- env/fatvars.c \
- print.c \
- utils.c \
- loader_interface.c \
- main.c
+if HAVE_WATCHDOGS
+efi_sources += $(watchdog_sources)
+endif
kernel_stub_name = kernel-stub$(MACHINE_TYPE_NAME).efi
@@ -331,7 +335,7 @@ kernel_stub_solib = $(top_builddir)/kernel-stub/kernel-stub$(MACHINE_TYPE_NAME).
efibootguard_DATA = $(efi_loadername) $(kernel_stub_name)
CLEANFILES += $(efi_objects) $(efi_solib) $(efi_loadername)
CLEANFILES += $(kernel_stub_objects) $(kernel_stub_solib) $(kernel_stub_name)
-EXTRA_DIST += $(efi_sources) $(watchdog_sources_x86) $(kernel_stub_sources)
+EXTRA_DIST += $(efi_sources) $(watchdog_sources) $(watchdog_sources_x86) $(kernel_stub_sources)
define gnuefi_compile
$(AM_V_CC) $(MKDIR_P) $(shell dirname $@)/; \
diff --git a/
configure.ac b/
configure.ac
index 9f41b30..1779661 100644
--- a/
configure.ac
+++ b/
configure.ac
@@ -225,6 +225,12 @@ if test "x$silent_boot" != "xno"; then
AC_DEFINE([SILENT_BOOT], [] , [Silent Boot])
fi
+# Signal to build whether there are watchdog drivers available
+AM_CONDITIONAL([HAVE_WATCHDOGS], [test -z "$ARCH_IS_X86_TRUE"])
+if test -z "$HAVE_WATCHDOGS_TRUE"; then
+ AC_DEFINE([HAVE_WATCHDOGS], [] , [Target provides watchdog drivers])
+fi
+
dnl pkg-config
PKG_PROG_PKG_CONFIG()
if test "x$PKG_CONFIG" = "xno"; then
diff --git a/main.c b/main.c
index 988efa5..b3fe340 100644
--- a/main.c
+++ b/main.c
@@ -97,10 +97,17 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
WARNING(L"Cannot close volumes.\n", status);
}
+#if defined(HAVE_WATCHDOGS)
status = probe_watchdogs(bg_loader_params.timeout);
if (EFI_ERROR(status)) {
error_exit(L"Cannot probe watchdog", status);
}
+#else
+ if (bg_loader_params.timeout > 0) {
+ error_exit(L"No watchdog drivers available, but timeout is non-zero",
+ EFI_UNSUPPORTED);
+ }
+#endif
/* Load and start image */
status = BS->LoadImage(FALSE, this_image, payload_dev_path, NULL, 0,
@@ -152,8 +159,12 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table)
loaded_image->LoadOptionsSize =
(StrLen(bg_loader_params.payload_options) + 1) * sizeof(CHAR16);
+#if defined(HAVE_WATCHDOGS)
INFO(L"Starting %s with watchdog set to %d seconds ...\n",
bg_loader_params.payload_path, bg_loader_params.timeout);
+#else
+ INFO(L"Starting %s ...\n", bg_loader_params.payload_path);
+#endif
BS->Stall(1000 * 1000 * ENV_BOOT_DELAY);
diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh
index 8fbaf23..93298a2 100755
--- a/scripts/cppcheck.sh
+++ b/scripts/cppcheck.sh
@@ -71,7 +71,7 @@ includes="-I . \
-I /usr/include/x86_64-linux-gnu \
-I /usr/lib/gcc/x86_64-linux-gnu/9/include"
-cpp_conf="-U__WINT_TYPE__ -U__GNUC__"
+cpp_conf="-U__WINT_TYPE__ -U__GNUC__ -DHAVE_WATCHDOGS"
path=${1-.}
build_tmp=$(mktemp -d)
--
2.47.3