From: Jan Kiszka <[email protected]> Modern compilers (gcc already since version 5) support ABI selection via GNU_EFI_USE_MS_ABI, obsoleting the clumsy uefi_call_wrapper this way.
Signed-off-by: Jan Kiszka <[email protected]> --- Makefile.am | 2 +- drivers/watchdog/amdfch_wdt.c | 6 ++--- drivers/watchdog/atom-quark.c | 5 ++-- drivers/watchdog/hpwdt.c | 16 +++++------- drivers/watchdog/i6300esb.c | 25 +++++++----------- drivers/watchdog/itco.c | 10 +++---- env/fatvars.c | 14 +++++----- include/syspart.h | 16 ++++++------ main.c | 49 ++++++++++++++++------------------- utils.c | 35 ++++++++++++------------- 10 files changed, 79 insertions(+), 99 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0018fd3..9eb1263 100644 --- a/Makefile.am +++ b/Makefile.am @@ -187,13 +187,13 @@ efi_cflags = \ -fno-strict-aliasing \ -fno-stack-protector \ -Wsign-compare \ + -DGNU_EFI_USE_MS_ABI \ $(CFLAGS) if ARCH_X86_64 efi_cflags += \ -mno-sse \ -mno-mmx \ - -DEFI_FUNCTION_WRAPPER \ -mno-red-zone endif diff --git a/drivers/watchdog/amdfch_wdt.c b/drivers/watchdog/amdfch_wdt.c index 333e5c6..a68939d 100644 --- a/drivers/watchdog/amdfch_wdt.c +++ b/drivers/watchdog/amdfch_wdt.c @@ -149,9 +149,9 @@ init(EFI_PCI_IO *pci_io, UINT16 pci_vendor_id, UINT16 pci_device_id, return EFI_UNSUPPORTED; } - status = uefi_call_wrapper(pci_io->Pci.Read, 5, pci_io, - EfiPciIoWidthUint8, PCI_REVISION_ID_REG, - 1, &pci_revision_id); + status = pci_io->Pci.Read( + pci_io, EfiPciIoWidthUint8, PCI_REVISION_ID_REG, 1, + &pci_revision_id); if (EFI_ERROR(status)) { return EFI_UNSUPPORTED; } diff --git a/drivers/watchdog/atom-quark.c b/drivers/watchdog/atom-quark.c index 4a3c070..c0896f2 100644 --- a/drivers/watchdog/atom-quark.c +++ b/drivers/watchdog/atom-quark.c @@ -67,9 +67,8 @@ init(EFI_PCI_IO *pci_io, UINT16 pci_vendor_id, UINT16 pci_device_id, return EFI_UNSUPPORTED; } - status = uefi_call_wrapper(pci_io->Pci.Read, 5, pci_io, - EfiPciIoWidthUint32, WDTBA_REG, - 1, &wdt_base); + status = pci_io->Pci.Read( + pci_io, EfiPciIoWidthUint32, WDTBA_REG, 1, &wdt_base); if (EFI_ERROR(status)) { return status; } diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index 30c8579..8c72f6c 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c @@ -51,9 +51,9 @@ init(EFI_PCI_IO *pci_io, UINT16 pci_vendor_id, UINT16 pci_device_id, UINT16 vendor, product; UINT32 value; - status = uefi_call_wrapper(pci_io->Pci.Read, 5, pci_io, - EfiPciIoWidthUint32, - PCI_SUBSYSTEM_VENDOR_ID, 1, &value); + status = pci_io->Pci.Read( + pci_io, EfiPciIoWidthUint32, PCI_SUBSYSTEM_VENDOR_ID, 1, + &value); if (EFI_ERROR(status)) { return status; } @@ -71,17 +71,15 @@ init(EFI_PCI_IO *pci_io, UINT16 pci_vendor_id, UINT16 pci_device_id, INFO(L"Detected HPE ProLiant watchdog\n"); reload = SECS_TO_TICKS(timeout); - status = uefi_call_wrapper(pci_io->Mem.Write, 6, pci_io, - EfiPciIoWidthUint16, 1, HPWDT_TIMER_REG, - 1, &reload); + status = pci_io->Mem.Write( + pci_io, EfiPciIoWidthUint16, 1, HPWDT_TIMER_REG, 1, &reload); if (EFI_ERROR(status)) { return status; } control = 0x81; - status = uefi_call_wrapper(pci_io->Mem.Write, 6, pci_io, - EfiPciIoWidthUint8, 1, HPWDT_TIMER_CON, - 1, &control); + status = pci_io->Mem.Write( + pci_io, EfiPciIoWidthUint8, 1, HPWDT_TIMER_CON, 1, &control); if (EFI_ERROR(status)) { return status; } diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c index 527c5de..4f50e69 100644 --- a/drivers/watchdog/i6300esb.c +++ b/drivers/watchdog/i6300esb.c @@ -33,17 +33,15 @@ static EFI_STATUS unlock_timer_regs(EFI_PCI_IO *pci_io) UINT32 value; value = 0x80; - status = uefi_call_wrapper(pci_io->Mem.Write, 6, pci_io, - EfiPciIoWidthUint32, 0, ESB_RELOAD_REG, - 1, &value); + status = pci_io->Mem.Write( + pci_io, EfiPciIoWidthUint32, 0, ESB_RELOAD_REG, 1, &value); if (EFI_ERROR(status)) { return status; } value = 0x86; - return uefi_call_wrapper(pci_io->Mem.Write, 6, pci_io, - EfiPciIoWidthUint32, 0, ESB_RELOAD_REG, - 1, &value); + return pci_io->Mem.Write( + pci_io, EfiPciIoWidthUint32, 0, ESB_RELOAD_REG, 1, &value); } static EFI_STATUS __attribute__((constructor)) @@ -66,9 +64,8 @@ init(EFI_PCI_IO *pci_io, UINT16 pci_vendor_id, UINT16 pci_device_id, } value = ((timeout * 1000000000ULL) >> 15) / 30; - status = uefi_call_wrapper(pci_io->Mem.Write, 6, pci_io, - EfiPciIoWidthUint32, 0, ESB_TIMER1_REG, - 1, &value); + status = pci_io->Mem.Write( + pci_io, EfiPciIoWidthUint32, 0, ESB_TIMER1_REG, 1, &value); if (EFI_ERROR(status)) { return status; } @@ -79,17 +76,15 @@ init(EFI_PCI_IO *pci_io, UINT16 pci_vendor_id, UINT16 pci_device_id, } value = 0; - status = uefi_call_wrapper(pci_io->Mem.Write, 6, pci_io, - EfiPciIoWidthUint32, 0, ESB_TIMER2_REG, - 1, &value); + status = pci_io->Mem.Write( + pci_io, EfiPciIoWidthUint32, 0, ESB_TIMER2_REG, 1, &value); if (EFI_ERROR(status)) { return status; } value = ESB_LOCK_WDT_ENABLE | ESB_LOCK_WDT_LOCK; - status = uefi_call_wrapper(pci_io->Pci.Write, 5, pci_io, - EfiPciIoWidthUint8, ESB_LOCK_REG, - 1, &value); + status = pci_io->Pci.Write( + pci_io, EfiPciIoWidthUint8, ESB_LOCK_REG, 1, &value); return status; } diff --git a/drivers/watchdog/itco.c b/drivers/watchdog/itco.c index 0713f28..183300a 100644 --- a/drivers/watchdog/itco.c +++ b/drivers/watchdog/itco.c @@ -186,9 +186,8 @@ static UINT32 get_pm_base(EFI_PCI_IO *pci_io, const iTCO_info *itco) return 0; } - status = uefi_call_wrapper(pci_io->Pci.Read, 5, pci_io, - EfiPciIoWidthUint32, - regs->pm_base_reg, 1, &pm_base); + status = pci_io->Pci.Read( + pci_io, EfiPciIoWidthUint32, regs->pm_base_reg, 1, &pm_base); if (EFI_ERROR(status)) { ERROR(L"reading PM_BASE: %r\n", status); return 0; @@ -226,9 +225,8 @@ static EFI_STATUS update_no_reboot_flag_mem(EFI_PCI_IO *pci_io, UINT32 pmc_base; UINTN pmc_reg; - status = - uefi_call_wrapper(pci_io->Pci.Read, 5, pci_io, EfiPciIoWidthUint32, - regs->pmc_base_reg, 1, &pmc_base); + status = pci_io->Pci.Read( + pci_io, EfiPciIoWidthUint32, regs->pmc_base_reg, 1, &pmc_base); if (EFI_ERROR(status)) { return status; } diff --git a/env/fatvars.c b/env/fatvars.c index 7572e83..61f94f0 100644 --- a/env/fatvars.c +++ b/env/fatvars.c @@ -64,12 +64,11 @@ static BG_STATUS save_current_config(VOID) UINTN writelen = sizeof(BG_ENVDATA); uint32_t crc32; - (VOID)uefi_call_wrapper(BS->CalculateCrc32, 3, &env[current_partition], - sizeof(BG_ENVDATA) - sizeof(env[current_partition].crc32), - &crc32); + (VOID) BS->CalculateCrc32( + &env[current_partition], + sizeof(BG_ENVDATA) - sizeof(env[current_partition].crc32), &crc32); env[current_partition].crc32 = crc32; - efistatus = uefi_call_wrapper(fh->Write, 3, fh, &writelen, - (VOID *)&env[current_partition]); + efistatus = fh->Write(fh, &writelen, (VOID *)&env[current_partition]); if (EFI_ERROR(efistatus)) { ERROR(L"Cannot write environment to file: %r\n", efistatus); (VOID) close_cfg_file(v->root, fh); @@ -147,9 +146,8 @@ BG_STATUS load_config(BG_LOADER_PARAMS *bglp) } uint32_t crc32; - (VOID)uefi_call_wrapper(BS->CalculateCrc32, 3, &env[i], - sizeof(BG_ENVDATA) - sizeof(env[i].crc32), - &crc32); + (VOID) BS->CalculateCrc32( + &env[i], sizeof(BG_ENVDATA) - sizeof(env[i].crc32), &crc32); if (crc32 != env[i].crc32) { ERROR(L"CRC32 error in environment data on config partition %d.\n", diff --git a/include/syspart.h b/include/syspart.h index 947a8b3..d725e23 100644 --- a/include/syspart.h +++ b/include/syspart.h @@ -20,16 +20,16 @@ #include <efipciio.h> #include "bootguard.h" -#define open_cfg_file(root, file, mode) \ - uefi_call_wrapper((root)->Open, 5, (root), (file), \ - ENV_FILE_NAME, (mode), \ - EFI_FILE_ARCHIVE | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM) +#define open_cfg_file(root, file, mode) \ + (root)->Open( \ + (root), (file), ENV_FILE_NAME, (mode), \ + EFI_FILE_ARCHIVE | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM) -#define close_cfg_file(root, file) \ - uefi_call_wrapper((root)->Close, 1, (file)) +#define close_cfg_file(root, file) \ + (root)->Close(file) -#define read_cfg_file(file, len, buffer) \ - uefi_call_wrapper((file)->Read, 3, (file), (len), (buffer)) +#define read_cfg_file(file, len, buffer) \ + (file)->Read((file), (len), (buffer)) EFI_STATUS enumerate_cfg_parts(UINTN *config_volumes, UINTN *maxHandles); UINTN filter_cfg_parts(UINTN *config_volumes, UINTN maxHandles); diff --git a/main.c b/main.c index 68e4eff..a50bd05 100644 --- a/main.c +++ b/main.c @@ -39,9 +39,9 @@ static EFI_STATUS probe_watchdogs(EFI_LOADED_IMAGE *loaded_image, UINTN timeout) UINTN handle_count = 0; EFI_HANDLE *handle_buffer = NULL; - EFI_STATUS status = uefi_call_wrapper(BS->LocateHandleBuffer, 5, - ByProtocol, &PciIoProtocol, NULL, - &handle_count, &handle_buffer); + EFI_STATUS status = BS->LocateHandleBuffer(ByProtocol, &PciIoProtocol, + NULL, &handle_count, + &handle_buffer); if (EFI_ERROR(status) || (handle_count == 0)) { WARNING(L"No PCI I/O Protocol handles found.\n"); if (handle_buffer) { @@ -53,26 +53,24 @@ static EFI_STATUS probe_watchdogs(EFI_LOADED_IMAGE *loaded_image, UINTN timeout) EFI_PCI_IO_PROTOCOL *pci_io; UINT32 value; for (UINTN index = 0; index < handle_count; index++) { - status = uefi_call_wrapper(BS->OpenProtocol, 6, - handle_buffer[index], &PciIoProtocol, - (VOID **)&pci_io, this_image, NULL, - EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); + status = BS->OpenProtocol(handle_buffer[index], &PciIoProtocol, + (VOID **)&pci_io, this_image, NULL, + EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); if (EFI_ERROR(status)) { ERROR(L"Cannot not open PciIoProtocol: %r\n", status); FreePool(handle_buffer); return status; } - status = uefi_call_wrapper(pci_io->Pci.Read, 5, pci_io, - EfiPciIoWidthUint32, PCI_VENDOR_ID, - 1, &value); + status = pci_io->Pci.Read(pci_io, EfiPciIoWidthUint32, + PCI_VENDOR_ID, 1, &value); if (EFI_ERROR(status)) { WARNING( L"Cannot not read from PCI device, skipping: %r\n", status); - (VOID) uefi_call_wrapper( - BS->CloseProtocol, 4, handle_buffer[index], - &PciIoProtocol, this_image, NULL); + (VOID) BS->CloseProtocol(handle_buffer[index], + &PciIoProtocol, this_image, + NULL); continue; } @@ -87,8 +85,7 @@ static EFI_STATUS probe_watchdogs(EFI_LOADED_IMAGE *loaded_image, UINTN timeout) } } - (VOID) uefi_call_wrapper(BS->CloseProtocol, 4, - handle_buffer[index], &PciIoProtocol, + (VOID) BS->CloseProtocol(handle_buffer[index], &PciIoProtocol, this_image, NULL); if (status == EFI_SUCCESS) { @@ -115,13 +112,12 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) this_image = image_handle; InitializeLib(this_image, system_table); - (VOID)uefi_call_wrapper(ST->ConOut->ClearScreen, 2, ST->ConOut); + (VOID) ST->ConOut->ClearScreen(ST->ConOut); PrintC(EFI_CYAN, L"\nEFI Boot Guard %s\n", L"" EFIBOOTGUARD_VERSION); - status = - uefi_call_wrapper(BS->OpenProtocol, 6, this_image, - &LoadedImageProtocol, (VOID **)&loaded_image, - this_image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + status = BS->OpenProtocol(this_image, &LoadedImageProtocol, + (VOID **)&loaded_image, this_image, NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (EFI_ERROR(status)) { error_exit(L"Cannot open LoadedImageProtocol to get image information", status); @@ -178,8 +174,8 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) } /* Load and start image */ - status = uefi_call_wrapper(BS->LoadImage, 6, TRUE, this_image, - payload_dev_path, NULL, 0, &payload_handle); + status = BS->LoadImage(TRUE, this_image, payload_dev_path, NULL, 0, + &payload_handle); if (EFI_ERROR(status)) { error_exit(L"Cannot load specified kernel image", status); } @@ -187,10 +183,9 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) FreePool(payload_dev_path); FreePool(boot_medium_path); - status = - uefi_call_wrapper(BS->OpenProtocol, 6, payload_handle, - &LoadedImageProtocol, (VOID **)&loaded_image, - this_image, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + status = BS->OpenProtocol(payload_handle, &LoadedImageProtocol, + (VOID **)&loaded_image, this_image, + NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (EFI_ERROR(status)) { error_exit(L"Cannot open LoadedImageProtocol to set kernel load options", status); @@ -203,5 +198,5 @@ EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) INFO(L"Starting %s with watchdog set to %d seconds ...\n", bg_loader_params.payload_path, bg_loader_params.timeout); - return uefi_call_wrapper(BS->StartImage, 3, payload_handle, NULL, NULL); + return BS->StartImage(payload_handle, NULL, NULL); } diff --git a/utils.c b/utils.c index 8088372..324d77d 100644 --- a/utils.c +++ b/utils.c @@ -21,14 +21,14 @@ VOID PrintC(const UINT8 color, const CHAR16 *fmt, ...) { INT32 attr = ST->ConOut->Mode->Attribute; - (VOID)uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, color); + (VOID) ST->ConOut->SetAttribute(ST->ConOut, color); va_list args; va_start(args, fmt); (VOID)VPrint(fmt, args); va_end(args); - (VOID)uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, attr); + (VOID) ST->ConOut->SetAttribute(ST->ConOut, attr); } BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp) @@ -52,8 +52,8 @@ BOOLEAN IsOnBootMedium(EFI_DEVICE_PATH *dp) VOID __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status) { ERROR(L"%s (%r).\n", message, status); - (VOID)uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000); - (VOID)uefi_call_wrapper(BS->Exit, 4, this_image, status, 0, NULL); + (VOID) BS->Stall(3 * 1000 * 1000); + (VOID) BS->Exit(this_image, status, 0, NULL); __builtin_unreachable(); } @@ -69,8 +69,7 @@ CHAR16 *get_volume_label(EFI_FILE_HANDLE fh) return NULL; } fsis = MAX_INFO_SIZE; - status = - uefi_call_wrapper(fh->GetInfo, 4, fh, &fsiGuid, &fsis, (VOID *)fsi); + status = fh->GetInfo(fh, &fsiGuid, &fsis, (VOID *)fsi); if (EFI_ERROR(status) || fsis == 0) { FreePool(fsi); return NULL; @@ -85,21 +84,21 @@ CHAR16 *get_volume_custom_label(EFI_FILE_HANDLE fh) CHAR16 *buffer = AllocatePool(64); UINTN buffsize = 63; - status = uefi_call_wrapper( - fh->Open, 5, fh, &tmp, L"EFILABEL", EFI_FILE_MODE_READ, + status = fh->Open( + fh, &tmp, L"EFILABEL", EFI_FILE_MODE_READ, EFI_FILE_ARCHIVE | EFI_FILE_HIDDEN | EFI_FILE_SYSTEM); if (status != EFI_SUCCESS) { FreePool(buffer); return NULL; } - status = uefi_call_wrapper(tmp->Read, 3, tmp, &buffsize, buffer); + status = tmp->Read(tmp, &buffsize, buffer); if (status != EFI_SUCCESS) { - (VOID)uefi_call_wrapper(fh->Close, 1, tmp); + (VOID) fh->Close(tmp); FreePool(buffer); return NULL; } buffer[buffsize/sizeof(CHAR16)] = L'\0'; - (VOID)uefi_call_wrapper(fh->Close, 1, tmp); + (VOID) fh->Close(tmp); return buffer; } @@ -118,8 +117,8 @@ EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN *count) return EFI_INVALID_PARAMETER; } - status = uefi_call_wrapper(BS->LocateHandleBuffer, 5, ByProtocol, - &sfspGuid, NULL, &handleCount, &handles); + status = BS->LocateHandleBuffer( + ByProtocol, &sfspGuid, NULL, &handleCount, &handles); if (EFI_ERROR(status)) { ERROR(L"Could not locate handle buffer.\n"); return EFI_OUT_OF_RESOURCES; @@ -136,16 +135,15 @@ EFI_STATUS get_volumes(VOLUME_DESC **volumes, UINTN *count) EFI_FILE_IO_INTERFACE *fs = NULL; CHAR16 *devpathstr; - status = - uefi_call_wrapper(BS->HandleProtocol, 3, handles[index], - &sfspGuid, (VOID **)&fs); + status = BS->HandleProtocol( + handles[index], &sfspGuid, (VOID **)&fs); if (EFI_ERROR(status)) { /* skip failed handle and continue enumerating */ ERROR(L"File IO handle %d does not support SIMPLE_FILE_SYSTEM_PROTOCOL, skipping.\n", index); continue; } - status = uefi_call_wrapper(fs->OpenVolume, 2, fs, &tmp); + status = fs->OpenVolume(fs, &tmp); if (EFI_ERROR(status)) { /* skip failed handle and continue enumerating */ ERROR(L"Could not open file system for IO handle %d, skipping.\n", @@ -198,8 +196,7 @@ EFI_STATUS close_volumes(VOLUME_DESC *volumes, UINTN count) result = EFI_INVALID_PARAMETER; continue; } - status = uefi_call_wrapper(volumes[i].root->Close, 1, - volumes[i].root); + status = volumes[i].root->Close(volumes[i].root); if (EFI_ERROR(status)) { ERROR(L"Could not close volume %d.\n", i); result = EFI_DEVICE_ERROR; -- 2.34.1 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/c4050570-1c13-9128-fd10-77ee9a600f8a%40siemens.com.
