]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Introduce DEFINE_EFI_MAIN macro
authorJan Janssen <medhefgo@web.de>
Thu, 19 Jan 2023 15:13:03 +0000 (16:13 +0100)
committerJan Janssen <medhefgo@web.de>
Fri, 20 Jan 2023 20:01:08 +0000 (21:01 +0100)
src/boot/efi/boot.c
src/boot/efi/stub.c
src/boot/efi/util.h

index e0a1ea7dd8c1f097acdd86c18c0175644c49414d..8d0d547a898d149ab188e7f5552c9d2475310a24 100644 (file)
@@ -2647,7 +2647,7 @@ static EFI_STATUS discover_root_dir(EFI_LOADED_IMAGE_PROTOCOL *loaded_image, EFI
                 return open_volume(loaded_image->DeviceHandle, ret_dir);
 }
 
-static EFI_STATUS real_main(EFI_HANDLE image) {
+static EFI_STATUS run(EFI_HANDLE image) {
         EFI_LOADED_IMAGE_PROTOCOL *loaded_image;
         _cleanup_(file_closep) EFI_FILE *root_dir = NULL;
         _cleanup_(config_free) Config config = {};
@@ -2747,12 +2747,4 @@ out:
         return err;
 }
 
-EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
-        InitializeLib(image, sys_table);
-
-        notify_debugger("systemd-boot", /*wait_for_debugger=*/false);
-
-        EFI_STATUS err = real_main(image);
-        log_wait();
-        return err;
-}
+DEFINE_EFI_MAIN_FUNCTION(run, "systemd-boot", /*wait_for_debugger=*/false);
index 5f480f14cd4b93735e39e315d09813f924af35f9..e2b5b6f53705706cf531d89383204a3388373546 100644 (file)
@@ -180,7 +180,7 @@ static bool use_load_options(
         return true;
 }
 
-static EFI_STATUS real_main(EFI_HANDLE image) {
+static EFI_STATUS run(EFI_HANDLE image) {
         _cleanup_free_ void *credential_initrd = NULL, *global_credential_initrd = NULL, *sysext_initrd = NULL, *pcrsig_initrd = NULL, *pcrpkey_initrd = NULL;
         size_t credential_initrd_size = 0, global_credential_initrd_size = 0, sysext_initrd_size = 0, pcrsig_initrd_size = 0, pcrpkey_initrd_size = 0;
         size_t linux_size, initrd_size, dt_size;
@@ -417,12 +417,4 @@ static EFI_STATUS real_main(EFI_HANDLE image) {
         return err;
 }
 
-EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
-        InitializeLib(image, sys_table);
-
-        notify_debugger("systemd-stub", /*wait_for_debugger=*/false);
-
-        EFI_STATUS err = real_main(image);
-        log_wait();
-        return err;
-}
+DEFINE_EFI_MAIN_FUNCTION(run, "systemd-stub", /*wait_for_debugger=*/false);
index 6a78215b9dbe0b4e2887a1211bf04fa36a3691ec..51cc3cc6b40233247b74af4e51808a50869d8cb7 100644 (file)
@@ -179,6 +179,15 @@ void hexdump(const char16_t *prefix, const void *data, size_t size);
 #  define notify_debugger(i, w)
 #endif
 
+#define DEFINE_EFI_MAIN_FUNCTION(func, identity, wait_for_debugger)             \
+        EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *system_table) { \
+                InitializeLib(image, system_table);                             \
+                notify_debugger((identity), (wait_for_debugger));               \
+                EFI_STATUS err = func(image);                                   \
+                log_wait();                                                     \
+                return err;                                                     \
+        }
+
 #if defined(__i386__) || defined(__x86_64__)
 void beep(UINTN beep_count);
 #else