]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-boot: Get rid of uefi_call_wrapper
authorJan Janssen <medhefgo@web.de>
Thu, 30 Sep 2021 10:11:56 +0000 (12:11 +0200)
committerJan Janssen <medhefgo@web.de>
Sun, 17 Oct 2021 09:55:57 +0000 (11:55 +0200)
The uefi_call_wrapper exists to convert to the right calling convention
and presumably predates compilers that can do so natively. The only
architecture where this is even needed is x86_64.
But because we are building with GNU_EFI_USE_MS_ABI defined, the
EFIAPI macro tells the compiler to use the right calling convention
for EFI functions. Our shim callback (which is called by EFI itself)
already relies on this.

This also adds a safety check to make se we are compiling with
GNU_EFI_USE_MS_ABI defined and also adds it to the compiler args
unconditionally. It is only used with x86_64 anyways, so it should
be fine to do so. EFI_FUNCTION_WRAPPER is unused in gnu-efi, so
it is dropped.

19 files changed:
src/boot/efi/assert.c
src/boot/efi/boot.c
src/boot/efi/console.c
src/boot/efi/devicetree.c
src/boot/efi/drivers.c
src/boot/efi/graphics.c
src/boot/efi/initrd.c
src/boot/efi/linux.c
src/boot/efi/linux_x86.c
src/boot/efi/measure.c
src/boot/efi/meson.build
src/boot/efi/pe.c
src/boot/efi/random-seed.c
src/boot/efi/shim.c
src/boot/efi/splash.c
src/boot/efi/stub.c
src/boot/efi/util.c
src/boot/efi/util.h
src/boot/efi/xbootldr.c

index 350b2b016772cf56bcd53f4fcde6201c4820bc31..7a25526de2f0403e17e3bacaf8bd09a70669e9a2 100644 (file)
@@ -7,9 +7,9 @@
 #include "util.h"
 
 void efi_assert(const char *expr, const char *file, unsigned line, const char *function) {
-      log_error_stall(L"systemd-boot assertion '%a' failed at %a:%u, function %a(). Halting.", expr, file, line, function);
-      for (;;)
-            uefi_call_wrapper(BS->Stall, 1, 60 * 1000 * 1000);
+        log_error_stall(L"systemd-boot assertion '%a' failed at %a:%u, function %a(). Halting.", expr, file, line, function);
+        for (;;)
+                BS->Stall(60 * 1000 * 1000);
 }
 
 #endif
index f1fbd942eb1e2c8047a2545e6b4fa139a20ed628..fcbf50fc0e0a893ec667582c664c1d6ed971ea7a 100644 (file)
 #include "util.h"
 #include "xbootldr.h"
 
+#ifndef GNU_EFI_USE_MS_ABI
+        /* We do not use uefi_call_wrapper() in systemd-boot. As such, we rely on the
+         * compiler to do the calling convention conversion for us. This is check is
+         * to make sure the -DGNU_EFI_USE_MS_ABI was passed to the comiler. */
+        #error systemd-boot requires compilation with GNU_EFI_USE_MS_ABI defined.
+#endif
+
 #ifndef EFI_OS_INDICATIONS_BOOT_TO_FW_UI
 #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL
 #endif
@@ -568,8 +575,8 @@ static BOOLEAN menu_run(
         INT64 console_mode_initial = ST->ConOut->Mode->Mode, console_mode_efivar_saved = config->console_mode_efivar;
 
         graphics_mode(FALSE);
-        uefi_call_wrapper(ST->ConIn->Reset, 2, ST->ConIn, FALSE);
-        uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE);
+        ST->ConIn->Reset(ST->ConIn, FALSE);
+        ST->ConOut->EnableCursor(ST->ConOut, FALSE);
 
         /* draw a single character to make ClearScreen work on some firmware */
         Print(L" ");
@@ -710,8 +717,8 @@ static BOOLEAN menu_run(
                         else
                                 x = 0;
                         print_at(0, y_status, COLOR_NORMAL, clearline + (x_max - x));
-                        uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, status);
-                        uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, clearline+1 + x + len);
+                        ST->ConOut->OutputString(ST->ConOut, status);
+                        ST->ConOut->OutputString(ST->ConOut, clearline + 1 + x + len);
                 }
 
                 err = console_key_read(&key, timeout_remain > 0 ? 1000 * 1000 : UINT64_MAX);
@@ -1262,7 +1269,7 @@ static void config_entry_bump_counters(
         static const EFI_GUID EfiFileInfoGuid = EFI_FILE_INFO_ID;
         _cleanup_freepool_ EFI_FILE_INFO *file_info = NULL;
         UINTN file_info_size;
-        EFI_STATUS r;
+        EFI_STATUS err;
 
         assert(entry);
         assert(root_dir);
@@ -1275,24 +1282,24 @@ static void config_entry_bump_counters(
 
         old_path = PoolPrint(L"%s\\%s", entry->path, entry->current_name);
 
-        r = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, old_path, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL);
-        if (EFI_ERROR(r))
+        err = root_dir->Open(root_dir, &handle, old_path, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL);
+        if (EFI_ERROR(err))
                 return;
 
-        r = get_file_info_harder(handle, &file_info, &file_info_size);
-        if (EFI_ERROR(r))
+        err = get_file_info_harder(handle, &file_info, &file_info_size);
+        if (EFI_ERROR(err))
                 return;
 
         /* And rename the file */
         StrCpy(file_info->FileName, entry->next_name);
-        r = uefi_call_wrapper(handle->SetInfo, 4, handle, (EFI_GUID*) &EfiFileInfoGuid, file_info_size, file_info);
-        if (EFI_ERROR(r)) {
-                log_error_stall(L"Failed to rename '%s' to '%s', ignoring: %r", old_path, entry->next_name, r);
+        err = handle->SetInfo(handle, (EFI_GUID*) &EfiFileInfoGuid, file_info_size, file_info);
+        if (EFI_ERROR(err)) {
+                log_error_stall(L"Failed to rename '%s' to '%s', ignoring: %r", old_path, entry->next_name, err);
                 return;
         }
 
         /* Flush everything to disk, just in case… */
-        (void) uefi_call_wrapper(handle->Flush, 1, handle);
+        (void) handle->Flush(handle);
 
         /* Let's tell the OS that we renamed this file, so that it knows what to rename to the counter-less name on
          * success */
@@ -1429,10 +1436,10 @@ static void config_entry_add_from_file(
                 return;
 
         /* check existence */
-        err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, entry->loader, EFI_FILE_MODE_READ, 0ULL);
+        err = root_dir->Open(root_dir, &handle, entry->loader, EFI_FILE_MODE_READ, 0ULL);
         if (EFI_ERROR(err))
                 return;
-        uefi_call_wrapper(handle->Close, 1, handle);
+        handle->Close(handle);
 
         /* add initrd= to options */
         if (entry->type == LOADER_LINUX && initrd) {
@@ -1875,10 +1882,10 @@ static BOOLEAN config_entry_add_loader_auto(
         }
 
         /* check existence */
-        err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, (CHAR16*) loader, EFI_FILE_MODE_READ, 0ULL);
+        err = root_dir->Open(root_dir, &handle, (CHAR16*) loader, EFI_FILE_MODE_READ, 0ULL);
         if (EFI_ERROR(err))
                 return FALSE;
-        uefi_call_wrapper(handle->Close, 1, handle);
+        handle->Close(handle);
 
         entry = config_entry_add_loader(config, device, LOADER_UNDEFINED, id, key, title, loader, NULL);
         if (!entry)
@@ -1911,7 +1918,7 @@ static void config_entry_add_osx(Config *config) {
                                 continue;
                         found = config_entry_add_loader_auto(config, handles[i], root, NULL, L"auto-osx", 'a', L"macOS",
                                                              L"\\System\\Library\\CoreServices\\boot.efi");
-                        uefi_call_wrapper(root->Close, 1, root);
+                        root->Close(root);
                         if (found)
                                 break;
                 }
@@ -2140,7 +2147,7 @@ static EFI_STATUS image_start(
         if (!path)
                 return log_error_status_stall(EFI_INVALID_PARAMETER, L"Error getting device path.");
 
-        err = uefi_call_wrapper(BS->LoadImage, 6, FALSE, parent_image, path, NULL, 0, &image);
+        err = BS->LoadImage(FALSE, parent_image, path, NULL, 0, &image);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Error loading %s: %r", entry->loader, err);
 
@@ -2159,8 +2166,8 @@ static EFI_STATUS image_start(
         if (options) {
                 EFI_LOADED_IMAGE *loaded_image;
 
-                err = uefi_call_wrapper(BS->OpenProtocol, 6, image, &LoadedImageProtocol, (void **)&loaded_image,
-                                        parent_image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+                err = BS->OpenProtocol(image, &LoadedImageProtocol, (void **)&loaded_image,
+                                       parent_image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
                 if (EFI_ERROR(err)) {
                         log_error_stall(L"Error getting LoadedImageProtocol handle: %r", err);
                         goto out_unload;
@@ -2173,9 +2180,9 @@ static EFI_STATUS image_start(
         }
 
         efivar_set_time_usec(LOADER_GUID, L"LoaderTimeExecUSec", 0);
-        err = uefi_call_wrapper(BS->StartImage, 3, image, NULL, NULL);
+        err = BS->StartImage(image, NULL, NULL);
 out_unload:
-        uefi_call_wrapper(BS->UnloadImage, 1, image);
+        BS->UnloadImage(image);
         return err;
 }
 
@@ -2193,7 +2200,7 @@ static EFI_STATUS reboot_into_firmware(void) {
         if (EFI_ERROR(err))
                 return err;
 
-        err = uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold, EFI_SUCCESS, 0, NULL);
+        err = RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
         return log_error_status_stall(err, L"Error calling ResetSystem: %r", err);
 }
 
@@ -2327,9 +2334,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
         InitializeLib(image, sys_table);
         init_usec = time_usec();
 
-        err = uefi_call_wrapper(
-                        BS->OpenProtocol, 6,
-                        image,
+        err = BS->OpenProtocol(image,
                         &LoadedImageProtocol,
                         (void **)&loaded_image,
                         image,
@@ -2433,6 +2438,6 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
         }
         err = EFI_SUCCESS;
 out:
-        uefi_call_wrapper(BS->CloseProtocol, 4, image, &LoadedImageProtocol, image, NULL);
+        BS->CloseProtocol(image, &LoadedImageProtocol, image, NULL);
         return err;
 }
index 2287275c148b6a0b2335246206e72c1ea41a4b08..88309484c71ac44c742dc17f8e5f9e80b812e2f5 100644 (file)
@@ -19,7 +19,7 @@ static inline void EventClosep(EFI_EVENT *event) {
         if (!*event)
                 return;
 
-        uefi_call_wrapper(BS->CloseEvent, 1, *event);
+        BS->CloseEvent(*event);
 }
 
 /*
@@ -51,8 +51,7 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
 
         if (!checked) {
                 err = LibLocateProtocol((EFI_GUID*) EFI_SIMPLE_TEXT_INPUT_EX_GUID, (void **)&TextInputEx);
-                if (EFI_ERROR(err) ||
-                    uefi_call_wrapper(BS->CheckEvent, 1, TextInputEx->WaitForKeyEx) == EFI_INVALID_PARAMETER)
+                if (EFI_ERROR(err) || BS->CheckEvent(TextInputEx->WaitForKeyEx) == EFI_INVALID_PARAMETER)
                         /* If WaitForKeyEx fails here, the firmware pretends it talks this
                          * protocol, but it really doesn't. */
                         TextInputEx = NULL;
@@ -62,7 +61,7 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
                 checked = TRUE;
         }
 
-        err = uefi_call_wrapper(BS->CreateEvent, 5, EVT_TIMER, 0, NULL, NULL, &timer);
+        err = BS->CreateEvent(EVT_TIMER, 0, NULL, NULL, &timer);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Error creating timer event: %r", err);
         events[n_events++] = timer;
@@ -74,17 +73,16 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
                        watchdog_ping_usec = watchdog_timeout_sec / 2 * 1000 * 1000;
 
                 /* SetTimer expects 100ns units for some reason. */
-                err = uefi_call_wrapper(
-                                BS->SetTimer, 3,
+                err = BS->SetTimer(
                                 timer,
                                 TimerRelative,
                                 MIN(timeout_usec, watchdog_ping_usec) * 10);
                 if (EFI_ERROR(err))
                         return log_error_status_stall(err, L"Error arming timer event: %r", err);
 
-                (void) uefi_call_wrapper(BS->SetWatchdogTimer, 4, watchdog_timeout_sec, 0x10000, 0, NULL);
-                err = uefi_call_wrapper(BS->WaitForEvent, 3, n_events, events, &index);
-                (void) uefi_call_wrapper(BS->SetWatchdogTimer, 4, watchdog_timeout_sec, 0x10000, 0, NULL);
+                (void) BS->SetWatchdogTimer(watchdog_timeout_sec, 0x10000, 0, NULL);
+                err = BS->WaitForEvent(n_events, events, &index);
+                (void) BS->SetWatchdogTimer(watchdog_timeout_sec, 0x10000, 0, NULL);
 
                 if (EFI_ERROR(err))
                         return log_error_status_stall(err, L"Error waiting for events: %r", err);
@@ -106,12 +104,12 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
         }
 
         /* TextInputEx might be ready too even if ConIn got to signal first. */
-        if (TextInputEx && !EFI_ERROR(uefi_call_wrapper(BS->CheckEvent, 1, TextInputEx->WaitForKeyEx))) {
+        if (TextInputEx && !EFI_ERROR(BS->CheckEvent(TextInputEx->WaitForKeyEx))) {
                 EFI_KEY_DATA keydata;
                 UINT64 keypress;
                 UINT32 shift = 0;
 
-                err = uefi_call_wrapper(TextInputEx->ReadKeyStrokeEx, 2, TextInputEx, &keydata);
+                err = TextInputEx->ReadKeyStrokeEx(TextInputEx, &keydata);
                 if (EFI_ERROR(err))
                         return err;
 
@@ -133,7 +131,7 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
                 return EFI_NOT_READY;
         }
 
-        err  = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &k);
+        err  = ST->ConIn->ReadKeyStroke(ST->ConIn, &k);
         if (EFI_ERROR(err))
                 return err;
 
@@ -149,17 +147,17 @@ static EFI_STATUS change_mode(INT64 mode) {
         mode = CLAMP(mode, CONSOLE_MODE_RANGE_MIN, CONSOLE_MODE_RANGE_MAX);
         old_mode = MAX(CONSOLE_MODE_RANGE_MIN, ST->ConOut->Mode->Mode);
 
-        err = uefi_call_wrapper(ST->ConOut->SetMode, 2, ST->ConOut, mode);
+        err = ST->ConOut->SetMode(ST->ConOut, mode);
         if (!EFI_ERROR(err))
                 return EFI_SUCCESS;
 
         /* Something went wrong. Output is probably borked, so try to revert to previous mode. */
-        if (!EFI_ERROR(uefi_call_wrapper(ST->ConOut->SetMode, 2, ST->ConOut, old_mode)))
+        if (!EFI_ERROR(ST->ConOut->SetMode(ST->ConOut, old_mode)))
                 return err;
 
         /* Maybe the device is on fire? */
-        uefi_call_wrapper(ST->ConOut->Reset, 2, ST->ConOut, TRUE);
-        uefi_call_wrapper(ST->ConOut->SetMode, 2, ST->ConOut, CONSOLE_MODE_RANGE_MIN);
+        ST->ConOut->Reset(ST->ConOut, TRUE);
+        ST->ConOut->SetMode(ST->ConOut, CONSOLE_MODE_RANGE_MIN);
         return err;
 }
 
@@ -254,7 +252,7 @@ EFI_STATUS console_query_mode(UINTN *x_max, UINTN *y_max) {
         assert(x_max);
         assert(y_max);
 
-        err = uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut, ST->ConOut->Mode->Mode, x_max, y_max);
+        err = ST->ConOut->QueryMode(ST->ConOut, ST->ConOut->Mode->Mode, x_max, y_max);
         if (EFI_ERROR(err)) {
                 /* Fallback values mandated by UEFI spec. */
                 switch (ST->ConOut->Mode->Mode) {
index 71c08a21ceb481d0901ca756eed936e6db636a18..30ba88c4f881591d6b5d13cf2293fb61c8a10d62 100644 (file)
@@ -14,8 +14,7 @@ static EFI_STATUS devicetree_allocate(struct devicetree_state *state, UINTN size
 
         assert(state);
 
-        err = uefi_call_wrapper(BS->AllocatePages, 4, AllocateAnyPages, EfiACPIReclaimMemory, pages,
-                                &state->addr);
+        err = BS->AllocatePages(AllocateAnyPages, EfiACPIReclaimMemory, pages, &state->addr);
         if (EFI_ERROR(err))
                 return err;
 
@@ -41,8 +40,8 @@ static EFI_STATUS devicetree_fixup(struct devicetree_state *state, UINTN len) {
                                               L"Could not locate device tree fixup protocol, skipping.");
 
         size = devicetree_allocated(state);
-        err = uefi_call_wrapper(fixup->Fixup, 4, fixup, PHYSICAL_ADDRESS_TO_POINTER(state->addr), &size,
-                                EFI_DT_APPLY_FIXUPS | EFI_DT_RESERVE_MEMORY);
+        err = fixup->Fixup(fixup, PHYSICAL_ADDRESS_TO_POINTER(state->addr), &size,
+                           EFI_DT_APPLY_FIXUPS | EFI_DT_RESERVE_MEMORY);
         if (err == EFI_BUFFER_TOO_SMALL) {
                 EFI_PHYSICAL_ADDRESS oldaddr = state->addr;
                 UINTN oldpages = state->pages;
@@ -53,13 +52,13 @@ static EFI_STATUS devicetree_fixup(struct devicetree_state *state, UINTN len) {
                         return err;
 
                 CopyMem(PHYSICAL_ADDRESS_TO_POINTER(state->addr), oldptr, len);
-                err = uefi_call_wrapper(BS->FreePages, 2, oldaddr, oldpages);
+                err = BS->FreePages(oldaddr, oldpages);
                 if (EFI_ERROR(err))
                         return err;
 
                 size = devicetree_allocated(state);
-                err = uefi_call_wrapper(fixup->Fixup, 4, fixup, PHYSICAL_ADDRESS_TO_POINTER(state->addr), &size,
-                                        EFI_DT_APPLY_FIXUPS | EFI_DT_RESERVE_MEMORY);
+                err = fixup->Fixup(fixup, PHYSICAL_ADDRESS_TO_POINTER(state->addr), &size,
+                                   EFI_DT_APPLY_FIXUPS | EFI_DT_RESERVE_MEMORY);
         }
 
         return err;
@@ -80,8 +79,7 @@ EFI_STATUS devicetree_install(struct devicetree_state *state,
         if (EFI_ERROR(err))
                 return EFI_UNSUPPORTED;
 
-        err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, name, EFI_FILE_MODE_READ,
-                                EFI_FILE_READ_ONLY);
+        err = root_dir->Open(root_dir, &handle, name, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY);
         if (EFI_ERROR(err))
                 return err;
 
@@ -98,7 +96,7 @@ EFI_STATUS devicetree_install(struct devicetree_state *state,
         if (EFI_ERROR(err))
                 return err;
 
-        err = uefi_call_wrapper(handle->Read, 3, handle, &len, PHYSICAL_ADDRESS_TO_POINTER(state->addr));
+        err = handle->Read(handle, &len, PHYSICAL_ADDRESS_TO_POINTER(state->addr));
         if (EFI_ERROR(err))
                 return err;
 
@@ -106,7 +104,7 @@ EFI_STATUS devicetree_install(struct devicetree_state *state,
         if (EFI_ERROR(err))
                 return err;
 
-        return uefi_call_wrapper(BS->InstallConfigurationTable, 2, &EfiDtbTableGuid, PHYSICAL_ADDRESS_TO_POINTER(state->addr));
+        return BS->InstallConfigurationTable(&EfiDtbTableGuid, PHYSICAL_ADDRESS_TO_POINTER(state->addr));
 }
 
 EFI_STATUS devicetree_install_from_memory(struct devicetree_state *state,
@@ -131,7 +129,7 @@ EFI_STATUS devicetree_install_from_memory(struct devicetree_state *state,
         if (EFI_ERROR(err))
                 return err;
 
-        return uefi_call_wrapper(BS->InstallConfigurationTable, 2, &EfiDtbTableGuid, PHYSICAL_ADDRESS_TO_POINTER(state->addr));
+        return BS->InstallConfigurationTable(&EfiDtbTableGuid, PHYSICAL_ADDRESS_TO_POINTER(state->addr));
 }
 
 void devicetree_cleanup(struct devicetree_state *state) {
@@ -140,11 +138,11 @@ void devicetree_cleanup(struct devicetree_state *state) {
         if (!state->pages)
                 return;
 
-        err = uefi_call_wrapper(BS->InstallConfigurationTable, 2, &EfiDtbTableGuid, state->orig);
+        err = BS->InstallConfigurationTable(&EfiDtbTableGuid, state->orig);
         /* don't free the current device tree if we can't reinstate the old one */
         if (EFI_ERROR(err))
                 return;
 
-        uefi_call_wrapper(BS->FreePages, 2, state->addr, state->pages);
+        BS->FreePages(state->addr, state->pages);
         state->pages = 0;
 }
index 5b2db2d5027cb345ff3f926b6cee06780eccf41e..f25b35ac96b5aca6e348749f74a106a4f6132137 100644 (file)
@@ -8,7 +8,7 @@
 
 static void efi_unload_image(EFI_HANDLE *h) {
         if (*h)
-                (void) uefi_call_wrapper(BS->UnloadImage, 1, *h);
+                (void) BS->UnloadImage(*h);
 }
 
 static EFI_STATUS load_one_driver(
@@ -33,21 +33,11 @@ static EFI_STATUS load_one_driver(
         if (!path)
                 return log_oom();
 
-        err = uefi_call_wrapper(
-                        BS->LoadImage, 6,
-                        FALSE,
-                        parent_image,
-                        path,
-                        NULL, 0,
-                        &image);
+        err = BS->LoadImage(FALSE, parent_image, path, NULL, 0, &image);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Failed to load image %s: %r", fname, err);
 
-        err = uefi_call_wrapper(
-                        BS->HandleProtocol, 3,
-                        image,
-                        &LoadedImageProtocol,
-                        (void **)&loaded_image);
+        err = BS->HandleProtocol(image, &LoadedImageProtocol, (void **)&loaded_image);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Failed to find protocol in driver image s: %r", fname, err);
 
@@ -55,11 +45,7 @@ static EFI_STATUS load_one_driver(
             loaded_image->ImageCodeType != EfiRuntimeServicesCode)
                 return log_error_status_stall(EFI_INVALID_PARAMETER, L"Image %s is not a driver, refusing: %r", fname);
 
-        err = uefi_call_wrapper(
-                        BS->StartImage, 3,
-                        image,
-                        NULL,
-                        NULL);
+        err = BS->StartImage(image, NULL, NULL);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Failed to start image %s: %r", fname, err);
 
@@ -74,23 +60,12 @@ static EFI_STATUS reconnect(void) {
 
           /* Reconnects all handles, so that any loaded drivers can take effect. */
 
-          err = uefi_call_wrapper(
-                          BS->LocateHandleBuffer, 5,
-                          AllHandles,
-                          NULL,
-                          NULL,
-                          &n_handles,
-                          &handles);
+          err = BS->LocateHandleBuffer(AllHandles, NULL, NULL, &n_handles, &handles);
           if (EFI_ERROR(err))
                   return log_error_status_stall(err, L"Failed to get list of handles: %r", err);
 
           for (UINTN i = 0; i < n_handles; i++) {
-                  err = uefi_call_wrapper(
-                                  BS->ConnectController, 4,
-                                  handles[i],
-                                  NULL,
-                                  NULL,
-                                  TRUE);
+                  err = BS->ConnectController(handles[i], NULL, NULL, TRUE);
                   if (err == EFI_NOT_FOUND) /* No drivers for this handle */
                           continue;
                   if (EFI_ERROR(err))
index 72b32b9bea7439a84993e3953f85583f559c10a6..62a3512fa38b26ded1f8c33b97cac27e395263dd 100644 (file)
@@ -25,7 +25,7 @@ EFI_STATUS graphics_mode(BOOLEAN on) {
                 return err == EFI_NOT_FOUND ? EFI_SUCCESS : err;
 
         /* check current mode */
-        err = uefi_call_wrapper(ConsoleControl->GetMode, 4, ConsoleControl, &current, &uga_exists, &stdin_locked);
+        err =ConsoleControl->GetMode(ConsoleControl, &current, &uga_exists, &stdin_locked);
         if (EFI_ERROR(err))
                 return err;
 
@@ -34,10 +34,10 @@ EFI_STATUS graphics_mode(BOOLEAN on) {
         if (new == current)
                 return EFI_SUCCESS;
 
-        err = uefi_call_wrapper(ConsoleControl->SetMode, 2, ConsoleControl, new);
+        err =ConsoleControl->SetMode(ConsoleControl, new);
 
         /* some firmware enables the cursor when switching modes */
-        uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE);
+        ST->ConOut->EnableCursor(ST->ConOut, FALSE);
 
         return err;
 }
index a939516d2ed0d1a35d8dbb73bf4cd4d44e2d6433..b302743adf96afaaf068f07a3b8891fae2ee7f3c 100644 (file)
@@ -84,7 +84,7 @@ EFI_STATUS initrd_register(
            LocateDevicePath checks for the "closest DevicePath" and returns its handle,
            where as InstallMultipleProtocolInterfaces only maches identical DevicePaths.
          */
-        err = uefi_call_wrapper(BS->LocateDevicePath, 3, &EfiLoadFile2Protocol, &dp, &handle);
+        err = BS->LocateDevicePath(&EfiLoadFile2Protocol, &dp, &handle);
         if (err != EFI_NOT_FOUND) /* InitrdMedia is already registered */
                 return EFI_ALREADY_STARTED;
 
@@ -99,8 +99,7 @@ EFI_STATUS initrd_register(
         };
 
         /* create a new handle and register the LoadFile2 protocol with the InitrdMediaPath on it */
-        err = uefi_call_wrapper(
-                        BS->InstallMultipleProtocolInterfaces, 8,
+        err = BS->InstallMultipleProtocolInterfaces(
                         ret_initrd_handle,
                         &DevicePathProtocol, &efi_initrd_device_path,
                         &EfiLoadFile2Protocol, loader,
@@ -119,21 +118,17 @@ EFI_STATUS initrd_unregister(EFI_HANDLE initrd_handle) {
                 return EFI_SUCCESS;
 
         /* get the LoadFile2 protocol that we allocated earlier */
-        err = uefi_call_wrapper(
-                        BS->OpenProtocol, 6,
+        err = BS->OpenProtocol(
                         initrd_handle, &EfiLoadFile2Protocol, (void **) &loader,
                         NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
         if (EFI_ERROR(err))
                 return err;
 
         /* close the handle */
-        (void) uefi_call_wrapper(
-                        BS->CloseProtocol, 4,
-                        initrd_handle, &EfiLoadFile2Protocol, NULL, NULL);
+        (void) BS->CloseProtocol(initrd_handle, &EfiLoadFile2Protocol, NULL, NULL);
 
         /* uninstall all protocols thus destroying the handle */
-        err = uefi_call_wrapper(
-                        BS->UninstallMultipleProtocolInterfaces, 6,
+        err = BS->UninstallMultipleProtocolInterfaces(
                         initrd_handle,
                         &DevicePathProtocol, &efi_initrd_device_path,
                         &EfiLoadFile2Protocol, loader,
index 882f3d02957597fa267ef4bb46583f7dc34d6a8c..f86fcc11432f8ab160a12a41bf1e19430ae59f04 100644 (file)
@@ -57,7 +57,7 @@ static EFI_STATUS loaded_image_register(
         }
 
         /* install a new LoadedImage protocol. ret_handle is a new image handle */
-        err = uefi_call_wrapper(BS->InstallMultipleProtocolInterfaces, 4,
+        err = BS->InstallMultipleProtocolInterfaces(
                         ret_image,
                         &LoadedImageProtocol, loaded_image,
                         NULL);
@@ -75,18 +75,15 @@ static EFI_STATUS loaded_image_unregister(EFI_HANDLE loaded_image_handle) {
                 return EFI_SUCCESS;
 
         /* get the LoadedImage protocol that we allocated earlier */
-        err = uefi_call_wrapper(
-                        BS->OpenProtocol, 6,
+        err = BS->OpenProtocol(
                         loaded_image_handle, &LoadedImageProtocol, (void **) &loaded_image,
                         NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
         if (EFI_ERROR(err))
                 return err;
 
         /* close the handle */
-        (void) uefi_call_wrapper(
-                        BS->CloseProtocol, 4,
-                        loaded_image_handle, &LoadedImageProtocol, NULL, NULL);
-        err = uefi_call_wrapper(BS->UninstallMultipleProtocolInterfaces, 4,
+        (void) BS->CloseProtocol(loaded_image_handle, &LoadedImageProtocol, NULL, NULL);
+        err = BS->UninstallMultipleProtocolInterfaces(
                         loaded_image_handle,
                         &LoadedImageProtocol, loaded_image,
                         NULL);
@@ -117,7 +114,7 @@ struct pages {
 static inline void cleanup_pages(struct pages *p) {
         if (p->addr == 0)
                 return;
-        (void) uefi_call_wrapper(BS->FreePages, 2, p->addr, p->num);
+        (void) BS->FreePages(p->addr, p->num);
 }
 
 EFI_STATUS linux_exec(
@@ -157,10 +154,7 @@ EFI_STATUS linux_exec(
         */
         /* allocate SizeOfImage + SectionAlignment because the new_buffer can move up to Alignment-1 bytes */
         kernel.num = EFI_SIZE_TO_PAGES(ALIGN_TO(kernel_size_of_image, kernel_alignment) + kernel_alignment);
-        err = uefi_call_wrapper(
-                BS->AllocatePages, 4,
-                AllocateAnyPages, EfiLoaderData,
-                kernel.num, &kernel.addr);
+        err = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, kernel.num, &kernel.addr);
         if (EFI_ERROR(err))
                 return EFI_OUT_OF_RESOURCES;
         new_buffer = PHYSICAL_ADDRESS_TO_POINTER(ALIGN_TO(kernel.addr, kernel_alignment));
@@ -182,5 +176,5 @@ EFI_STATUS linux_exec(
                 return err;
 
         /* call the kernel */
-        return uefi_call_wrapper(kernel_entry, 2, loaded_image_handle, ST);
+        return kernel_entry(loaded_image_handle, ST);
 }
index 63e6b86e86aa6a82c8677751733b726e7e45f962..98b2366ad28a41fc9989763e73480c4fd27c05cb 100644 (file)
@@ -147,8 +147,7 @@ EFI_STATUS linux_exec(
                 return EFI_LOAD_ERROR;
 
         addr = UINT32_MAX; /* Below the 32bit boundary */
-        err = uefi_call_wrapper(
-                        BS->AllocatePages, 4,
+        err = BS->AllocatePages(
                         AllocateMaxAddress,
                         EfiLoaderData,
                         EFI_SIZE_TO_PAGES(0x4000),
@@ -166,8 +165,7 @@ EFI_STATUS linux_exec(
         if (cmdline) {
                 addr = 0xA0000;
 
-                err = uefi_call_wrapper(
-                                BS->AllocatePages, 4,
+                err = BS->AllocatePages(
                                 AllocateMaxAddress,
                                 EfiLoaderData,
                                 EFI_SIZE_TO_PAGES(cmdline_len + 1),
index de7856bacf90c85fc8240d40367260a29f925772..220a8fbb357b296ca742fa5ed4d323e48fe99677 100644 (file)
@@ -37,8 +37,7 @@ static EFI_STATUS tpm1_measure_to_pcr_and_event_log(
         };
         CopyMem(tcg_event->Event, description, desc_len);
 
-        return uefi_call_wrapper(
-                        tcg->HashLogExtendEvent, 7,
+        return tcg->HashLogExtendEvent(
                         (EFI_TCG *) tcg,
                         buffer, buffer_size,
                         TCG_ALG_SHA,
@@ -75,8 +74,7 @@ static EFI_STATUS tpm2_measure_to_pcr_and_event_log(
 
         CopyMem(tcg_event->Event, description, desc_len);
 
-        return uefi_call_wrapper(
-                        tcg->HashLogExtendEvent, 5,
+        return tcg->HashLogExtendEvent(
                         tcg,
                         0,
                         buffer, buffer_size,
@@ -96,8 +94,7 @@ static EFI_TCG *tcg1_interface_check(void) {
         if (EFI_ERROR(status))
                 return NULL;
 
-        status = uefi_call_wrapper(
-                        tcg->StatusCheck, 5,
+        status = tcg->StatusCheck(
                         tcg,
                         &capability,
                         &features,
@@ -126,7 +123,7 @@ static EFI_TCG2 * tcg2_interface_check(void) {
         if (EFI_ERROR(status))
                 return NULL;
 
-        status = uefi_call_wrapper(tcg->GetCapability, 2, tcg, &capability);
+        status = tcg->GetCapability(tcg, &capability);
         if (EFI_ERROR(status))
                 return NULL;
 
index e3e13fec0412105aa75fa9e2367dea4784a1306f..201a9a70f3760d808df78ea67dca65f1b7fa6714 100644 (file)
@@ -205,6 +205,7 @@ if have_gnu_efi
                 '-isystem', efi_incdir / gnu_efi_path_arch,
                 '-I', fundamental_path,
                 '-DSD_BOOT',
+                '-DGNU_EFI_USE_MS_ABI',
                 '-include', efi_config_h,
                 '-include', version_h,
         ]
@@ -216,9 +217,7 @@ if have_gnu_efi
         if efi_arch == 'x86_64'
                 compile_args += ['-mno-red-zone',
                                  '-mno-sse',
-                                 '-mno-mmx',
-                                 '-DEFI_FUNCTION_WRAPPER',
-                                 '-DGNU_EFI_USE_MS_ABI']
+                                 '-mno-mmx']
         elif efi_arch == 'ia32'
                 compile_args += ['-mno-sse',
                                  '-mno-mmx']
index 2be69071f0ec00809ffbf808d914bd2ce58a4242..518f5e66d07ae3e8a590251c3009e1204cea371e 100644 (file)
@@ -241,23 +241,23 @@ EFI_STATUS pe_file_locate_sections(
         assert(offsets);
         assert(sizes);
 
-        err = uefi_call_wrapper(dir->Open, 5, dir, &handle, (CHAR16*)path, EFI_FILE_MODE_READ, 0ULL);
+        err = dir->Open(dir, &handle, (CHAR16*)path, EFI_FILE_MODE_READ, 0ULL);
         if (EFI_ERROR(err))
                 return err;
 
         len = sizeof(dos);
-        err = uefi_call_wrapper(handle->Read, 3, handle, &len, &dos);
+        err = handle->Read(handle, &len, &dos);
         if (EFI_ERROR(err))
                 return err;
         if (len != sizeof(dos) || !verify_dos(&dos))
                 return EFI_LOAD_ERROR;
 
-        err = uefi_call_wrapper(handle->SetPosition, 2, handle, dos.ExeHeader);
+        err = handle->SetPosition(handle, dos.ExeHeader);
         if (EFI_ERROR(err))
                 return err;
 
         len = sizeof(pe);
-        err = uefi_call_wrapper(handle->Read, 3, handle, &len, &pe);
+        err = handle->Read(handle, &len, &pe);
         if (EFI_ERROR(err))
                 return err;
         if (len != sizeof(pe) || !verify_pe(&pe))
@@ -268,12 +268,12 @@ EFI_STATUS pe_file_locate_sections(
         if (!section_table)
                 return EFI_OUT_OF_RESOURCES;
 
-        err = uefi_call_wrapper(handle->SetPosition, 2, handle, section_table_offset(&dos, &pe));
+        err = handle->SetPosition(handle, section_table_offset(&dos, &pe));
         if (EFI_ERROR(err))
                 return err;
 
         len = section_table_len;
-        err = uefi_call_wrapper(handle->Read, 3, handle, &len, section_table);
+        err = handle->Read(handle, &len, section_table);
         if (EFI_ERROR(err))
                 return err;
         if (len != section_table_len)
index a3d079456f77b50d99eec09940214f82b458a0b3..e829cf98b1d88020006fb38da3672a4e340f71f0 100644 (file)
@@ -36,7 +36,7 @@ static EFI_STATUS acquire_rng(UINTN size, void **ret) {
         if (!data)
                 return log_oom();
 
-        err = uefi_call_wrapper(rng->GetRNG, 3, rng, NULL, size, data);
+        err = rng->GetRNG(rng, NULL, size, data);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Failed to acquire RNG data: %r", err);
 
@@ -256,7 +256,7 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) {
         if (mode != RANDOM_SEED_ALWAYS && EFI_ERROR(err))
                 return err;
 
-        err = uefi_call_wrapper(root_dir->Open, 5, root_dir, &handle, (CHAR16*) L"\\loader\\random-seed", EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL);
+        err = root_dir->Open(root_dir, &handle, (CHAR16*) L"\\loader\\random-seed", EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL);
         if (EFI_ERROR(err)) {
                 if (err != EFI_NOT_FOUND && err != EFI_WRITE_PROTECTED)
                         log_error_stall(L"Failed to open random seed file: %r", err);
@@ -279,13 +279,13 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) {
                 return log_oom();
 
         rsize = size;
-        err = uefi_call_wrapper(handle->Read, 3, handle, &rsize, seed);
+        err = handle->Read(handle, &rsize, seed);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Failed to read random seed file: %r", err);
         if (rsize != size)
                 return log_error_status_stall(EFI_PROTOCOL_ERROR, L"Short read on random seed file.");
 
-        err = uefi_call_wrapper(handle->SetPosition, 2, handle, 0);
+        err = handle->SetPosition(handle, 0);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Failed to seek to beginning of random seed file: %r", err);
 
@@ -301,13 +301,13 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir, RandomSeedMode mode) {
 
         /* Update the random seed on disk before we use it */
         wsize = size;
-        err = uefi_call_wrapper(handle->Write, 3, handle, &wsize, new_seed);
+        err = handle->Write(handle, &wsize, new_seed);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Failed to write random seed file: %r", err);
         if (wsize != size)
                 return log_error_status_stall(EFI_PROTOCOL_ERROR, L"Short write on random seed file.");
 
-        err = uefi_call_wrapper(handle->Flush, 1, handle);
+        err = handle->Flush(handle);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Failed to flush random seed file: %r", err);
 
index 7923259c811c75816ab7a364722435444a554e78..0ccb90773a5925ffbaea67d8ff413ca14684e597 100644 (file)
@@ -38,7 +38,7 @@ struct ShimLock {
 BOOLEAN shim_loaded(void) {
         struct ShimLock *shim_lock;
 
-        return uefi_call_wrapper(BS->LocateProtocol, 3, (EFI_GUID*) SHIM_LOCK_GUID, NULL, (void**) &shim_lock) == EFI_SUCCESS;
+        return !EFI_ERROR(BS->LocateProtocol((EFI_GUID*) SHIM_LOCK_GUID, NULL, (void**) &shim_lock));
 }
 
 static BOOLEAN shim_validate(void *data, UINT32 size) {
@@ -47,13 +47,13 @@ static BOOLEAN shim_validate(void *data, UINT32 size) {
         if (!data)
                 return FALSE;
 
-        if (uefi_call_wrapper(BS->LocateProtocol, 3, (EFI_GUID*) SHIM_LOCK_GUID, NULL, (void**) &shim_lock) != EFI_SUCCESS)
+        if (EFI_ERROR(BS->LocateProtocol((EFI_GUID*) SHIM_LOCK_GUID, NULL, (void**) &shim_lock)))
                 return FALSE;
 
         if (!shim_lock)
                 return FALSE;
 
-        return shim_lock->shim_verify(data, size) == EFI_SUCCESS;
+        return !EFI_ERROR(shim_lock->shim_verify(data, size));
 }
 
 /* Handle to the original authenticator for security1 protocol */
@@ -79,7 +79,7 @@ static EFIAPI EFI_STATUS security2_policy_authentication (const EFI_SECURITY2_PR
         /* device_path and file_buffer may be NULL */
 
         /* Chain original security policy */
-        status = uefi_call_wrapper(es2fa, 5, this, device_path, file_buffer, file_size, boot_policy);
+        status = es2fa(this, device_path, file_buffer, file_size, boot_policy);
 
         /* if OK, don't bother with MOK check */
         if (!EFI_ERROR(status))
@@ -119,8 +119,8 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT
         if (!dev_path)
                 return EFI_OUT_OF_RESOURCES;
 
-        status = uefi_call_wrapper(BS->LocateDevicePath, 3, (EFI_GUID*) SIMPLE_FS_GUID, &dev_path, &h);
-        if (status != EFI_SUCCESS)
+        status = BS->LocateDevicePath((EFI_GUID*) SIMPLE_FS_GUID, &dev_path, &h);
+        if (EFI_ERROR(status))
                 return status;
 
         /* No need to check return value, this already happened in efi_main() */
@@ -132,13 +132,13 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT
         status = file_read(root, dev_path_str, 0, 0, &file_buffer, &file_size);
         if (EFI_ERROR(status))
                 return status;
-        uefi_call_wrapper(root->Close, 1, root);
+        root->Close(root);
 
         if (shim_validate(file_buffer, file_size))
                 return EFI_SUCCESS;
 
         /* Try using the platform's native policy.... */
-        return uefi_call_wrapper(esfas, 3, this, authentication_status, device_path_const);
+        return esfas(this, authentication_status, device_path_const);
 }
 
 EFI_STATUS security_policy_install(void) {
@@ -155,11 +155,11 @@ EFI_STATUS security_policy_install(void) {
          * to fail, since SECURITY2 was introduced in PI 1.2.1.
          * Use security2_protocol == NULL as indicator.
          */
-        uefi_call_wrapper(BS->LocateProtocol, 3, (EFI_GUID*) SECURITY_PROTOCOL2_GUID, NULL, (void**) &security2_protocol);
+        BS->LocateProtocol((EFI_GUID*) SECURITY_PROTOCOL2_GUID, NULL, (void**) &security2_protocol);
 
-        status = uefi_call_wrapper(BS->LocateProtocol, 3, (EFI_GUID*) SECURITY_PROTOCOL_GUID, NULL, (void**) &security_protocol);
+        status = BS->LocateProtocol((EFI_GUID*) SECURITY_PROTOCOL_GUID, NULL, (void**) &security_protocol);
          /* This one is mandatory, so there's a serious problem */
-        if (status != EFI_SUCCESS)
+        if (EFI_ERROR(status))
                 return status;
 
         esfas = security_protocol->FileAuthenticationState;
index 8cb343b50f1d65911bea7c4239d493460429257e..c27203eb8ca15b6e180d0a7416e761a6d766ca4a 100644 (file)
@@ -294,11 +294,13 @@ EFI_STATUS graphics_splash(const UINT8 *content, UINTN len, const EFI_GRAPHICS_O
         if (dib->y < GraphicsOutput->Mode->Info->VerticalResolution)
                 y_pos = (GraphicsOutput->Mode->Info->VerticalResolution - dib->y) / 2;
 
-        uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput,
-                          (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)background,
-                          EfiBltVideoFill, 0, 0, 0, 0,
-                          GraphicsOutput->Mode->Info->HorizontalResolution,
-                          GraphicsOutput->Mode->Info->VerticalResolution, 0);
+        err = GraphicsOutput->Blt(
+                        GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)background,
+                        EfiBltVideoFill, 0, 0, 0, 0,
+                        GraphicsOutput->Mode->Info->HorizontalResolution,
+                        GraphicsOutput->Mode->Info->VerticalResolution, 0);
+        if (EFI_ERROR(err))
+                return err;
 
         /* EFI buffer */
         blt_size = sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * dib->x * dib->y;
@@ -306,9 +308,10 @@ EFI_STATUS graphics_splash(const UINT8 *content, UINTN len, const EFI_GRAPHICS_O
         if (!blt)
                 return EFI_OUT_OF_RESOURCES;
 
-        err = uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput,
-                                blt, EfiBltVideoToBltBuffer, x_pos, y_pos, 0, 0,
-                                dib->x, dib->y, 0);
+        err = GraphicsOutput->Blt(
+                        GraphicsOutput, blt,
+                        EfiBltVideoToBltBuffer, x_pos, y_pos, 0, 0,
+                        dib->x, dib->y, 0);
         if (EFI_ERROR(err))
                 return err;
 
@@ -320,7 +323,8 @@ EFI_STATUS graphics_splash(const UINT8 *content, UINTN len, const EFI_GRAPHICS_O
         if (EFI_ERROR(err))
                 return err;
 
-        return uefi_call_wrapper(GraphicsOutput->Blt, 10, GraphicsOutput,
-                                 blt, EfiBltBufferToVideo, 0, 0, x_pos, y_pos,
-                                 dib->x, dib->y, 0);
+        return GraphicsOutput->Blt(
+                        GraphicsOutput, blt,
+                        EfiBltBufferToVideo, 0, 0, x_pos, y_pos,
+                        dib->x, dib->y, 0);
 }
index 27b0e04e3ce8e6fef1c18bb27db35f9f3df5ef4a..256aa21827fa46723b84421a09cd5924c22dc814 100644 (file)
@@ -47,8 +47,7 @@ static EFI_STATUS combine_initrd(
                 n += sysext_initrd_size;
         }
 
-        err = uefi_call_wrapper(
-                        BS->AllocatePages, 4,
+        err = BS->AllocatePages(
                         AllocateMaxAddress,
                         EfiLoaderData,
                         EFI_SIZE_TO_PAGES(n),
@@ -177,8 +176,13 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
 
         InitializeLib(image, sys_table);
 
-        err = uefi_call_wrapper(BS->OpenProtocol, 6, image, &LoadedImageProtocol, (void **)&loaded_image,
-                                image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+        err = BS->OpenProtocol(
+                        image,
+                        &LoadedImageProtocol,
+                        (void **)&loaded_image,
+                        image,
+                        NULL,
+                        EFI_OPEN_PROTOCOL_GET_PROTOCOL);
         if (EFI_ERROR(err))
                 return log_error_status_stall(err, L"Error getting a LoadedImageProtocol handle: %r", err);
 
index 704f1d960be3fca5591638c645f44a82a604ba7a..bbde2d8702f237b0eaea994f3368cce28dae245e 100644 (file)
@@ -42,7 +42,7 @@ UINT64 ticks_freq(void) {
         UINT64 ticks_start, ticks_end;
 
         ticks_start = ticks_read();
-        uefi_call_wrapper(BS->Stall, 1, 1000);
+        BS->Stall(1000);
         ticks_end = ticks_read();
 
         return (ticks_end - ticks_start) * 1000UL;
@@ -101,7 +101,7 @@ EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, const CHAR16 *name, const void
         assert(buf || size == 0);
 
         flags |= EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
-        return uefi_call_wrapper(RT->SetVariable, 5, (CHAR16*) name, (EFI_GUID *) vendor, flags, size, (void*) buf);
+        return RT->SetVariable((CHAR16 *) name, (EFI_GUID *) vendor, flags, size, (void *) buf);
 }
 
 EFI_STATUS efivar_set(const EFI_GUID *vendor, const CHAR16 *name, const CHAR16 *value, UINT32 flags) {
@@ -260,7 +260,7 @@ EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, const CHAR16 *name, CHAR8 **bu
         if (!buf)
                 return EFI_OUT_OF_RESOURCES;
 
-        err = uefi_call_wrapper(RT->GetVariable, 5, (CHAR16*) name, (EFI_GUID *)vendor, NULL, &l, buf);
+        err = RT->GetVariable((CHAR16 *) name, (EFI_GUID *) vendor, NULL, &l, buf);
         if (!EFI_ERROR(err)) {
 
                 if (buffer)
@@ -451,7 +451,7 @@ EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN s
         assert(name);
         assert(ret);
 
-        err = uefi_call_wrapper(dir->Open, 5, dir, &handle, (CHAR16*) name, EFI_FILE_MODE_READ, 0ULL);
+        err = dir->Open(dir, &handle, (CHAR16*) name, EFI_FILE_MODE_READ, 0ULL);
         if (EFI_ERROR(err))
                 return err;
 
@@ -466,7 +466,7 @@ EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN s
         }
 
         if (off > 0) {
-                err = uefi_call_wrapper(handle->SetPosition, 2, handle, off);
+                err = handle->SetPosition(handle, off);
                 if (EFI_ERROR(err))
                         return err;
         }
@@ -475,7 +475,7 @@ EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN s
         if (!buf)
                 return EFI_OUT_OF_RESOURCES;
 
-        err = uefi_call_wrapper(handle->Read, 3, handle, &size, buf);
+        err = handle->Read(handle, &size, buf);
         if (EFI_ERROR(err))
                 return err;
 
@@ -493,7 +493,7 @@ void log_error_stall(const CHAR16 *fmt, ...) {
 
         assert(fmt);
 
-        uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTRED|EFI_BACKGROUND_BLACK);
+        ST->ConOut->SetAttribute(ST->ConOut, EFI_LIGHTRED|EFI_BACKGROUND_BLACK);
 
         Print(L"\n");
         va_start(args, fmt);
@@ -501,7 +501,7 @@ void log_error_stall(const CHAR16 *fmt, ...) {
         va_end(args);
         Print(L"\n");
 
-        uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
+        BS->Stall(3 * 1000 * 1000);
 }
 
 EFI_STATUS log_oom(void) {
@@ -525,14 +525,14 @@ void *memmem_safe(const void *haystack, UINTN haystack_len, const void *needle,
 
 void print_at(UINTN x, UINTN y, UINTN attr, const CHAR16 *str) {
         assert(str);
-        uefi_call_wrapper(ST->ConOut->SetCursorPosition, 3, ST->ConOut, x, y);
-        uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, attr);
-        uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, (CHAR16*)str);
+        ST->ConOut->SetCursorPosition(ST->ConOut, x, y);
+        ST->ConOut->SetAttribute(ST->ConOut, attr);
+        ST->ConOut->OutputString(ST->ConOut, (CHAR16*)str);
 }
 
 void clear_screen(UINTN attr) {
-        uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, attr);
-        uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
+        ST->ConOut->SetAttribute(ST->ConOut, attr);
+        ST->ConOut->ClearScreen(ST->ConOut);
 }
 
 void sort_pointer_array(
@@ -584,14 +584,14 @@ EFI_STATUS get_file_info_harder(
         if (!fi)
                 return EFI_OUT_OF_RESOURCES;
 
-        err = uefi_call_wrapper(handle->GetInfo, 4, handle, (EFI_GUID*) &EfiFileInfoGuid, &size, fi);
+        err = handle->GetInfo(handle, (EFI_GUID*) &EfiFileInfoGuid, &size, fi);
         if (err == EFI_BUFFER_TOO_SMALL) {
                 FreePool(fi);
                 fi = AllocatePool(size);  /* GetInfo tells us the required size, let's use that now */
                 if (!fi)
                         return EFI_OUT_OF_RESOURCES;
 
-                err = uefi_call_wrapper(handle->GetInfo, 4, handle, (EFI_GUID*) &EfiFileInfoGuid, &size, fi);
+                err = handle->GetInfo(handle, (EFI_GUID*) &EfiFileInfoGuid, &size, fi);
         }
 
         if (EFI_ERROR(err))
@@ -631,7 +631,7 @@ EFI_STATUS readdir_harder(
         } else
                 sz = *buffer_size;
 
-        err = uefi_call_wrapper(handle->Read, 3, handle, &sz, *buffer);
+        err = handle->Read(handle, &sz, *buffer);
         if (err == EFI_BUFFER_TOO_SMALL) {
                 FreePool(*buffer);
 
@@ -643,7 +643,7 @@ EFI_STATUS readdir_harder(
 
                 *buffer_size = sz;
 
-                err = uefi_call_wrapper(handle->Read, 3, handle, &sz, *buffer);
+                err = handle->Read(handle, &sz, *buffer);
         }
         if (EFI_ERROR(err))
                 return err;
@@ -728,13 +728,7 @@ EFI_STATUS open_directory(
 
         /* Opens a file, and then verifies it is actually a directory */
 
-        err = uefi_call_wrapper(
-                        root->Open, 5,
-                        root,
-                        &dir,
-                        (CHAR16*) path,
-                        EFI_FILE_MODE_READ,
-                        0ULL);
+        err = root->Open(root, &dir, (CHAR16*) path, EFI_FILE_MODE_READ, 0ULL);
         if (EFI_ERROR(err))
                 return err;
 
index fb0b2f87c99caf2354d17275172d0ab1bc1952c5..d1ef9efeed1aee39ef73ef10747e3092437046c5 100644 (file)
@@ -72,7 +72,7 @@ static inline void FileHandleClosep(EFI_FILE_HANDLE *handle) {
         if (!*handle)
                 return;
 
-        uefi_call_wrapper((*handle)->Close, 1, *handle);
+        (*handle)->Close(*handle);
 }
 
 /*
index 7c1fd0e6c6535607cbdf3dd9d0774f71f8821d82..471982c25152267d00f4f425dc8ae8beed93dd16 100644 (file)
@@ -95,8 +95,7 @@ static EFI_STATUS try_gpt(
         assert(ret_part_uuid);
 
         /* Read the GPT header */
-        err = uefi_call_wrapper(
-                        block_io->ReadBlocks, 5,
+        err = block_io->ReadBlocks(
                         block_io,
                         block_io->Media->MediaId,
                         lba,
@@ -117,8 +116,7 @@ static EFI_STATUS try_gpt(
         if (!entries)
                 return EFI_OUT_OF_RESOURCES;
 
-        err = uefi_call_wrapper(
-                        block_io->ReadBlocks, 5,
+        err = block_io->ReadBlocks(
                         block_io,
                         block_io->Media->MediaId,
                         gpt.gpt_header.PartitionEntryLBA,
@@ -199,11 +197,11 @@ static EFI_STATUS find_device(
                 if (!disk_path)
                         continue;
 
-                err = uefi_call_wrapper(BS->LocateDevicePath, 3, &BlockIoProtocol, &p, &disk_handle);
+                err = BS->LocateDevicePath(&BlockIoProtocol, &p, &disk_handle);
                 if (EFI_ERROR(err))
                         continue;
 
-                err = uefi_call_wrapper(BS->HandleProtocol, 3, disk_handle, &BlockIoProtocol, (void **)&block_io);
+                err = BS->HandleProtocol(disk_handle, &BlockIoProtocol, (void **)&block_io);
                 if (EFI_ERROR(err))
                         continue;
 
@@ -292,7 +290,7 @@ EFI_STATUS xbootldr_open(EFI_HANDLE *device, EFI_HANDLE *ret_device, EFI_FILE **
                 hd->SignatureType = SIGNATURE_TYPE_GUID;
         }
 
-        err = uefi_call_wrapper(BS->LocateDevicePath, 3, &BlockIoProtocol, &partition_path, &new_device);
+        err = BS->LocateDevicePath(&BlockIoProtocol, &partition_path, &new_device);
         if (EFI_ERROR(err))
                 return err;