diff options
author | Jan Janssen <medhefgo@web.de> | 2021-09-30 12:11:56 +0200 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2021-10-17 11:55:57 +0200 |
commit | 12f32748aa291db1e8c1305e7fb4310e9728aad4 (patch) | |
tree | c19933452b62ff7de743eaea6765d75a34d6371e /src/boot | |
parent | sd-boot: Convert VOID -> void (diff) | |
download | systemd-12f32748aa291db1e8c1305e7fb4310e9728aad4.tar.xz systemd-12f32748aa291db1e8c1305e7fb4310e9728aad4.zip |
sd-boot: Get rid of uefi_call_wrapper
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.
Diffstat (limited to 'src/boot')
-rw-r--r-- | src/boot/efi/assert.c | 6 | ||||
-rw-r--r-- | src/boot/efi/boot.c | 61 | ||||
-rw-r--r-- | src/boot/efi/console.c | 32 | ||||
-rw-r--r-- | src/boot/efi/devicetree.c | 26 | ||||
-rw-r--r-- | src/boot/efi/drivers.c | 37 | ||||
-rw-r--r-- | src/boot/efi/graphics.c | 6 | ||||
-rw-r--r-- | src/boot/efi/initrd.c | 15 | ||||
-rw-r--r-- | src/boot/efi/linux.c | 20 | ||||
-rw-r--r-- | src/boot/efi/linux_x86.c | 6 | ||||
-rw-r--r-- | src/boot/efi/measure.c | 11 | ||||
-rw-r--r-- | src/boot/efi/meson.build | 5 | ||||
-rw-r--r-- | src/boot/efi/pe.c | 12 | ||||
-rw-r--r-- | src/boot/efi/random-seed.c | 12 | ||||
-rw-r--r-- | src/boot/efi/shim.c | 22 | ||||
-rw-r--r-- | src/boot/efi/splash.c | 26 | ||||
-rw-r--r-- | src/boot/efi/stub.c | 12 | ||||
-rw-r--r-- | src/boot/efi/util.c | 42 | ||||
-rw-r--r-- | src/boot/efi/util.h | 2 | ||||
-rw-r--r-- | src/boot/efi/xbootldr.c | 12 |
19 files changed, 162 insertions, 203 deletions
diff --git a/src/boot/efi/assert.c b/src/boot/efi/assert.c index 350b2b0167..7a25526de2 100644 --- a/src/boot/efi/assert.c +++ b/src/boot/efi/assert.c @@ -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 diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index f1fbd942eb..fcbf50fc0e 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -19,6 +19,13 @@ #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; } diff --git a/src/boot/efi/console.c b/src/boot/efi/console.c index 2287275c14..88309484c7 100644 --- a/src/boot/efi/console.c +++ b/src/boot/efi/console.c @@ -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) { diff --git a/src/boot/efi/devicetree.c b/src/boot/efi/devicetree.c index 71c08a21ce..30ba88c4f8 100644 --- a/src/boot/efi/devicetree.c +++ b/src/boot/efi/devicetree.c @@ -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; } diff --git a/src/boot/efi/drivers.c b/src/boot/efi/drivers.c index 5b2db2d502..f25b35ac96 100644 --- a/src/boot/efi/drivers.c +++ b/src/boot/efi/drivers.c @@ -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)) diff --git a/src/boot/efi/graphics.c b/src/boot/efi/graphics.c index 72b32b9bea..62a3512fa3 100644 --- a/src/boot/efi/graphics.c +++ b/src/boot/efi/graphics.c @@ -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, ¤t, &uga_exists, &stdin_locked); + err =ConsoleControl->GetMode(ConsoleControl, ¤t, &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; } diff --git a/src/boot/efi/initrd.c b/src/boot/efi/initrd.c index a939516d2e..b302743adf 100644 --- a/src/boot/efi/initrd.c +++ b/src/boot/efi/initrd.c @@ -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, diff --git a/src/boot/efi/linux.c b/src/boot/efi/linux.c index 882f3d0295..f86fcc1143 100644 --- a/src/boot/efi/linux.c +++ b/src/boot/efi/linux.c @@ -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); } diff --git a/src/boot/efi/linux_x86.c b/src/boot/efi/linux_x86.c index 63e6b86e86..98b2366ad2 100644 --- a/src/boot/efi/linux_x86.c +++ b/src/boot/efi/linux_x86.c @@ -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), diff --git a/src/boot/efi/measure.c b/src/boot/efi/measure.c index de7856bacf..220a8fbb35 100644 --- a/src/boot/efi/measure.c +++ b/src/boot/efi/measure.c @@ -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; diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build index e3e13fec04..201a9a70f3 100644 --- a/src/boot/efi/meson.build +++ b/src/boot/efi/meson.build @@ -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'] diff --git a/src/boot/efi/pe.c b/src/boot/efi/pe.c index 2be69071f0..518f5e66d0 100644 --- a/src/boot/efi/pe.c +++ b/src/boot/efi/pe.c @@ -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) diff --git a/src/boot/efi/random-seed.c b/src/boot/efi/random-seed.c index a3d079456f..e829cf98b1 100644 --- a/src/boot/efi/random-seed.c +++ b/src/boot/efi/random-seed.c @@ -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); diff --git a/src/boot/efi/shim.c b/src/boot/efi/shim.c index 7923259c81..0ccb90773a 100644 --- a/src/boot/efi/shim.c +++ b/src/boot/efi/shim.c @@ -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; diff --git a/src/boot/efi/splash.c b/src/boot/efi/splash.c index 8cb343b50f..c27203eb8c 100644 --- a/src/boot/efi/splash.c +++ b/src/boot/efi/splash.c @@ -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); } diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index 27b0e04e3c..256aa21827 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -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); diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index 704f1d960b..bbde2d8702 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -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; diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index fb0b2f87c9..d1ef9efeed 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -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); } /* diff --git a/src/boot/efi/xbootldr.c b/src/boot/efi/xbootldr.c index 7c1fd0e6c6..471982c251 100644 --- a/src/boot/efi/xbootldr.c +++ b/src/boot/efi/xbootldr.c @@ -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; |