diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2016-02-12 16:21:49 -0800 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2016-02-12 17:15:22 -0800 |
commit | b98d381bf3f8bd7f3f8d677be40aee427ea8e8cc (patch) | |
tree | 8dad349eeb65ca7d0bbbefb2fce04512338215f4 | |
parent | 18bbce759ab9b8f64d05cf6b1987539c746d4bc7 (diff) | |
download | efitools-b98d381bf3f8bd7f3f8d677be40aee427ea8e8cc.tar.gz |
arm build fixes
This is a monster bunch. Firstly, eliminate the efi call wrapper
thunking. On the security policy override, this was done via an
x86_64 asm routine which won't work on non-x86.
The build arm objects using the -O binary objcopy method and take the
linker scripts from gnu-efi rather than hand rolling.
Confine the EFI building machinery to its own include file (not having
this correct was causing an OBS build failure on arm)
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | HashTool.c | 4 | ||||
-rw-r--r-- | KeyTool.c | 35 | ||||
-rw-r--r-- | Loader.c | 16 | ||||
-rw-r--r-- | LockDown.c | 42 | ||||
-rw-r--r-- | Make.rules | 34 | ||||
-rw-r--r-- | PreLoader.c | 4 | ||||
-rw-r--r-- | UpdateVars.c | 10 | ||||
-rw-r--r-- | elf_ia32_efi.lds | 75 | ||||
-rw-r--r-- | elf_x86_64_efi.lds | 59 | ||||
-rw-r--r-- | include/buildefi.h | 15 | ||||
-rw-r--r-- | lib/console.c | 56 | ||||
-rw-r--r-- | lib/execute.c | 10 | ||||
-rw-r--r-- | lib/guid.c | 1 | ||||
-rw-r--r-- | lib/pecoff.c | 20 | ||||
-rw-r--r-- | lib/security_policy.c | 33 | ||||
-rw-r--r-- | lib/sha256.c | 10 | ||||
-rw-r--r-- | lib/shell.c | 2 | ||||
-rw-r--r-- | lib/simple_file.c | 46 | ||||
-rw-r--r-- | lib/variables.c | 54 |
19 files changed, 191 insertions, 335 deletions
@@ -252,9 +252,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) NULL }); if (selection == 1) - uefi_call_wrapper(RT->ResetSystem, 4, - EfiResetWarm, - EFI_SUCCESS, 0, NULL); + RT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL); } else if (option == exit_moktool) { break; } @@ -169,12 +169,11 @@ select_and_apply(CHAR16 **title, CHAR16 *ext, int key, UINTN options) status = SetSecureVariable(keyinfo[key].name, esl, size, *keyinfo[key].guid, options, 0); } else { - status = uefi_call_wrapper(RT->SetVariable, 5, - keyinfo[key].name, keyinfo[key].guid, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_BOOTSERVICE_ACCESS - | options, - size, esl); + status = RT->SetVariable(keyinfo[key].name, keyinfo[key].guid, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_BOOTSERVICE_ACCESS + | options, + size, esl); } if (status != EFI_SUCCESS) { console_error(L"Failed to update variable", status); @@ -193,7 +192,7 @@ StringSplit(CHAR16 *str, int maxlen, CHAR16 c, CHAR16 **out) return 1; } while (len > 0) { - int i, found; + int i, found = 0; for (i = 0; i < maxlen; i++) { if (str[i] == c) @@ -237,11 +236,10 @@ delete_key(int key, void *Data, int DataSize, EFI_SIGNATURE_LIST *CertList, DataSize, *keyinfo[key].guid, 0, 0); else - status = uefi_call_wrapper(RT->SetVariable, 5, - keyinfo[key].name, keyinfo[key].guid, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_BOOTSERVICE_ACCESS, - DataSize, Data); + status = RT->SetVariable(keyinfo[key].name, keyinfo[key].guid, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_BOOTSERVICE_ACCESS, + DataSize, Data); if (status != EFI_SUCCESS) console_error(L"Failed to delete key", status); @@ -556,7 +554,7 @@ manipulate_key(int key) UINT8 *Data; UINTN DataSize = 0, Size; - efi_status = uefi_call_wrapper(RT->GetVariable, 5, keyinfo[key].name, keyinfo[key].guid, NULL, &DataSize, NULL); + efi_status = RT->GetVariable(keyinfo[key].name, keyinfo[key].guid, NULL, &DataSize, NULL); if (efi_status != EFI_BUFFER_TOO_SMALL && efi_status != EFI_NOT_FOUND) { console_error(L"Failed to get DataSize", efi_status); return; @@ -570,7 +568,7 @@ manipulate_key(int key) return; } - efi_status = uefi_call_wrapper(RT->GetVariable, 5, keyinfo[key].name, keyinfo[key].guid, NULL, &DataSize, Data); + efi_status = RT->GetVariable(keyinfo[key].name, keyinfo[key].guid, NULL, &DataSize, Data); if (efi_status == EFI_NOT_FOUND) { int t = 2; title[t++] = L"Variable is Empty"; @@ -726,15 +724,14 @@ execute_binary() devpath = FileDevicePath(h, bin_name); - status = uefi_call_wrapper(BS->LoadImage, 6, FALSE, im, - devpath, NULL, 0, &ih); + status = BS->LoadImage(FALSE, im, devpath, NULL, 0, &ih); if (status != EFI_SUCCESS) { console_error(L"Image failed to load", status); return; } - status = uefi_call_wrapper(BS->StartImage, 3, ih, NULL, NULL); - uefi_call_wrapper(BS->UnloadImage, 1, ih); + status = BS->StartImage(ih, NULL, NULL); + BS->UnloadImage(ih); if (status != EFI_SUCCESS) console_error(L"Execution returned error", status); @@ -754,7 +751,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) if (GetOSIndications() & EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION) display_dbt = 1; - efi_status = uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); + efi_status = RT->GetVariable(L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); if (efi_status != EFI_SUCCESS) { Print(L"No SetupMode variable ... is platform secure boot enabled?\n"); return EFI_SUCCESS; @@ -16,6 +16,7 @@ #include <console.h> #include <efiauthenticated.h> #include <guid.h> +#include <execute.h> CHAR16 *loader = L"\\linux-loader.efi"; @@ -65,7 +66,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) InitializeLib(image, systab); - efi_status = uefi_call_wrapper(RT->GetVariable, 5, L"SecureBoot", &GV_GUID, NULL, &DataSize, &SecureBoot); + efi_status = RT->GetVariable(L"SecureBoot", &GV_GUID, NULL, &DataSize, &SecureBoot); if (efi_status != EFI_SUCCESS) { Print(L"Not a Secure Boot Platform %d\n", efi_status); @@ -74,10 +75,9 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) DataSize = sizeof(SetupMode); } - uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); + RT->GetVariable(L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); - efi_status = uefi_call_wrapper(BS->HandleProtocol, 3, image, - &IMAGE_PROTOCOL, &li); + efi_status = BS->HandleProtocol(image, &IMAGE_PROTOCOL, (VOID **)&li); if (efi_status != EFI_SUCCESS) { Print(L"Failed to init loaded image protocol: %d\n", efi_status); return efi_status; @@ -91,13 +91,13 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) } if (!SetupMode) { - efi_status = uefi_call_wrapper(BS->LoadImage, 6, FALSE, image, - loadpath, NULL, 0, &loader_handle); + efi_status = BS->LoadImage(FALSE, image, loadpath, NULL, + 0, &loader_handle); if (efi_status == EFI_SUCCESS) { /* Image validates - start it */ Print(L"Starting file via StartImage\n"); - uefi_call_wrapper(BS->StartImage, 3, loader_handle, NULL, NULL); - uefi_call_wrapper(BS->UnloadImage, 1, loader_handle); + BS->StartImage(loader_handle, NULL, NULL); + BS->UnloadImage(loader_handle); return EFI_SUCCESS; } else { Print(L"Failed to load the image: %d\n", efi_status); @@ -22,7 +22,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) InitializeLib(image, systab); - efi_status = uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); + efi_status = RT->GetVariable(L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); if (efi_status != EFI_SUCCESS) { Print(L"No SetupMode variable ... is platform secure boot enabled?\n"); @@ -36,23 +36,23 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) Print(L"Platform is in Setup Mode\n"); - efi_status = uefi_call_wrapper(RT->SetVariable, 5, L"KEK", &GV_GUID, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_RUNTIME_ACCESS - | EFI_VARIABLE_BOOTSERVICE_ACCESS - | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS, - KEK_auth_len, KEK_auth); + efi_status = RT->SetVariable(L"KEK", &GV_GUID, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_RUNTIME_ACCESS + | EFI_VARIABLE_BOOTSERVICE_ACCESS + | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS, + KEK_auth_len, KEK_auth); if (efi_status != EFI_SUCCESS) { Print(L"Failed to enroll KEK: %d\n", efi_status); return efi_status; } Print(L"Created KEK Cert\n"); - efi_status = uefi_call_wrapper(RT->SetVariable, 5, L"db", &SIG_DB, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_RUNTIME_ACCESS - | EFI_VARIABLE_BOOTSERVICE_ACCESS - | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS, - DB_auth_len, DB_auth); + efi_status = RT->SetVariable(L"db", &SIG_DB, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_RUNTIME_ACCESS + | EFI_VARIABLE_BOOTSERVICE_ACCESS + | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS, + DB_auth_len, DB_auth); if (efi_status != EFI_SUCCESS) { Print(L"Failed to enroll db: %d\n", efi_status); return efi_status; @@ -68,12 +68,12 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) } #endif /* PK must be updated with a signed copy of itself */ - efi_status = uefi_call_wrapper(RT->SetVariable, 5, L"PK", &GV_GUID, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_RUNTIME_ACCESS - | EFI_VARIABLE_BOOTSERVICE_ACCESS - | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS, - PK_auth_len, PK_auth); + efi_status = RT->SetVariable(L"PK", &GV_GUID, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_RUNTIME_ACCESS + | EFI_VARIABLE_BOOTSERVICE_ACCESS + | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS, + PK_auth_len, PK_auth); if (efi_status != EFI_SUCCESS) { @@ -82,7 +82,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) } Print(L"Created PK Cert\n"); /* enrolling the PK should put us in SetupMode; check this */ - efi_status = uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); + efi_status = RT->GetVariable(L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); if (efi_status != EFI_SUCCESS) { Print(L"Failed to get SetupMode variable: %d\n", efi_status); return efi_status; @@ -91,7 +91,7 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) /* finally, check that SecureBoot is enabled */ - efi_status = uefi_call_wrapper(RT->GetVariable, 5, L"SecureBoot", &GV_GUID, NULL, &DataSize, &SecureBoot); + efi_status = RT->GetVariable(L"SecureBoot", &GV_GUID, NULL, &DataSize, &SecureBoot); if (efi_status != EFI_SUCCESS) { Print(L"Failed to get SecureBoot variable: %d\n", efi_status); @@ -1,7 +1,7 @@ EFISIGNED = $(patsubst %.efi,%-signed.efi,$(EFIFILES)) MANPAGES = $(patsubst doc/%.1.in,doc/%.1,$(wildcard doc/*.1.in)) HELP2MAN = help2man -ARCH = $(shell uname -m | sed s/i.86/ia32/) +ARCH = $(shell uname -m | sed 's/i.86/ia32/;s/arm.*/arm/') ifeq ($(ARCH),ia32) ARCH3264 = -m32 else ifeq ($(ARCH),x86_64) @@ -9,13 +9,13 @@ ARCH3264 = else ifeq ($(ARCH),aarch64) ARCH3264 = else ifeq ($(ARCH),arm) -ARCH3264 = -m32 +ARCH3264 = else $(error unknown architecture $(ARCH)) endif INCDIR = -I$(TOPDIR)include/ -I/usr/include/efi -I/usr/include/efi/$(ARCH) -I/usr/include/efi/protocol CPPFLAGS = -DCONFIG_$(ARCH) -CFLAGS = -O2 $(ARCH3264) -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -mno-red-zone -fno-stack-protector -g +CFLAGS = -O2 $(ARCH3264) -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -fno-stack-protector -ffreestanding -fno-stack-check LDFLAGS = -nostdlib CRTOBJ = crt0-efi-$(ARCH).o CRTPATHS = /lib /lib64 /lib/efi /lib64/efi /usr/lib /usr/lib64 /usr/lib/efi /usr/lib64/efi @@ -23,10 +23,10 @@ CRTPATH = $(shell for f in $(CRTPATHS); do if [ -e $$f/$(CRTOBJ) ]; then echo $ CRTOBJS = $(CRTPATH)/$(CRTOBJ) # there's a bug in the gnu tools ... the .reloc section has to be # aligned otherwise the file alignment gets screwed up -LDSCRIPT = $(TOPDIR)/elf_$(ARCH)_efi.lds -LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic $(CRTOBJS) -L $(CRTPATH) +LDSCRIPT = elf_$(ARCH)_efi.lds +LDFLAGS += -shared -Bsymbolic $(CRTOBJS) -L $(CRTPATH) -T $(LDSCRIPT) LOADLIBES = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name) -FORMAT = efi-app-$(ARCH) +FORMAT = --target=efi-app-$(ARCH) OBJCOPY = objcopy MYGUID = 11111111-2222-3333-4444-123456789abc INSTALL = install @@ -39,13 +39,27 @@ DOCDIR = $(DESTDIR)/usr/share/efitools CFLAGS += -DGNU_EFI_USE_MS_ABI ifeq ($(ARCH),x86_64) - CFLAGS += -DEFI_FUNCTION_WRAPPER + CFLAGS += -DEFI_FUNCTION_WRAPPER -mno-red-zone endif -%.efi: %.so - $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \ - -j .rela -j .reloc --target=$(FORMAT) $*.so $@ +ifeq ($(ARCH),ia32) + CFLAGS += -mno-red-zone +endif +ifeq ($(ARCH),arm) + LDFLAGS += --defsym=EFI_SUBSYSTEM=0x0a + FORMAT = -O binary +endif + +ifeq ($(ARCH),aarch64) + LDFLAGS += --defsym=EFI_SUBSYSTEM=0x0a + FORMAT = -O binary +endif + +%.efi: %.so + $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ + -j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ + -j .reloc $(FORMAT) $*.so $@ %.so: %.o $(LD) $(LDFLAGS) $^ -o $@ $(LOADLIBES) # check we have no undefined symbols diff --git a/PreLoader.c b/PreLoader.c index b9cea32..42896f4 100644 --- a/PreLoader.c +++ b/PreLoader.c @@ -30,8 +30,8 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) console_reset(); - status = uefi_call_wrapper(RT->GetVariable, 5, L"SecureBoot", - &GV_GUID, NULL, &DataSize, &SecureBoot); + status = RT->GetVariable(L"SecureBoot", + &GV_GUID, NULL, &DataSize, &SecureBoot); if (status != EFI_SUCCESS) { Print(L"Not a Secure Boot Platform %d\n", status); goto override; diff --git a/UpdateVars.c b/UpdateVars.c index 6c6f76b..2d21563 100644 --- a/UpdateVars.c +++ b/UpdateVars.c @@ -134,11 +134,11 @@ efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) } else if (esl_mode) { status = SetSecureVariable(var, buf, size, *owner, options, 0); } else { - status = uefi_call_wrapper(RT->SetVariable, 5, var, owner, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_BOOTSERVICE_ACCESS - | options, - size, buf); + status = RT->SetVariable(var, owner, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_BOOTSERVICE_ACCESS + | options, + size, buf); } if (status != EFI_SUCCESS) { diff --git a/elf_ia32_efi.lds b/elf_ia32_efi.lds deleted file mode 100644 index 975e36c..0000000 --- a/elf_ia32_efi.lds +++ /dev/null @@ -1,75 +0,0 @@ -OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") -OUTPUT_ARCH(i386) -ENTRY(_start) -SECTIONS -{ - . = 0; - ImageBase = .; - .hash : { *(.hash) } /* this MUST come first! */ - . = ALIGN(4096); - .text : - { - *(.text) - *(.text.*) - *(.gnu.linkonce.t.*) - } - . = ALIGN(4096); - .sdata : - { - *(.got.plt) - *(.got) - *(.srodata) - *(.sdata) - *(.sbss) - *(.scommon) - } - . = ALIGN(4096); - .data : - { - *(.rodata*) - *(.data) - *(.data1) - *(.data.*) - *(.sdata) - *(.got.plt) - *(.got) - /* the EFI loader doesn't seem to like a .bss section, so we stick - it all into .data: */ - *(.sbss) - *(.scommon) - *(.dynbss) - *(.bss) - *(COMMON) - } - . = ALIGN(4096); - .dynamic : { *(.dynamic) } - . = ALIGN(4096); - .rel : - { - *(.rel.data) - *(.rel.data.*) - *(.rel.got) - *(.rel.stab) - *(.data.rel.ro.local) - *(.data.rel.local) - *(.data.rel.ro) - *(.data.rel*) - } - . = ALIGN(4096); - .reloc : /* This is the PECOFF .reloc section! */ - { - *(.reloc) - } - . = ALIGN(4096); - .dynsym : { *(.dynsym) } - . = ALIGN(4096); - .dynstr : { *(.dynstr) } - . = ALIGN(4096); - /DISCARD/ : - { - *(.rel.reloc) - *(.eh_frame) - *(.note.GNU-stack) - } - .comment 0 : { *(.comment) } -} diff --git a/elf_x86_64_efi.lds b/elf_x86_64_efi.lds deleted file mode 100644 index bcbff09..0000000 --- a/elf_x86_64_efi.lds +++ /dev/null @@ -1,59 +0,0 @@ -OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") -OUTPUT_ARCH(i386:x86-64) -ENTRY(_start) -SECTIONS -{ - . = 0; - ImageBase = .; - .hash : { *(.hash) } /* this MUST come first! */ - . = ALIGN(4096); - .eh_frame : - { - *(.eh_frame) - } - . = ALIGN(4096); - .text : - { - *(.text) - } - . = ALIGN(4096); - .reloc : - { - *(.reloc) - } - . = ALIGN(4096); - .data : - { - *(.rodata*) - *(.got.plt) - *(.got) - *(.data*) - *(.sdata) - /* the EFI loader doesn't seem to like a .bss section, so we stick - it all into .data: */ - *(.sbss) - *(.scommon) - *(.dynbss) - *(.bss) - *(COMMON) - *(.rel.local) - } - . = ALIGN(4096); - .dynamic : { *(.dynamic) } - . = ALIGN(4096); - .rela : - { - *(.rela.data*) - *(.rela.got) - *(.rela.stab) - } - . = ALIGN(4096); - .dynsym : { *(.dynsym) } - . = ALIGN(4096); - .dynstr : { *(.dynstr) } - . = ALIGN(4096); - .ignored.reloc : - { - *(.rela.reloc) - } -} diff --git a/include/buildefi.h b/include/buildefi.h new file mode 100644 index 0000000..223aa6a --- /dev/null +++ b/include/buildefi.h @@ -0,0 +1,15 @@ +#ifndef _BUILDEFI_H +#define _BUILDEFI_H + +#ifndef BUILD_EFI +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#define Print(...) printf("%ls", __VA_ARGS__) +#define AllocatePool(x) malloc(x) +#define CopyMem(d, s, l) memcpy(d, s, l) +#define ZeroMem(s, l) memset(s, 0, l) +#define FreePool(s) free(s) +#endif + +#endif /* _BUILDEFI_H */ diff --git a/lib/console.c b/lib/console.c index a7f4237..9c10560 100644 --- a/lib/console.c +++ b/lib/console.c @@ -42,8 +42,8 @@ console_get_keystroke(void) EFI_INPUT_KEY key; UINTN EventIndex; - uefi_call_wrapper(BS->WaitForEvent, 3, 1, &ST->ConIn->WaitForKey, &EventIndex); - uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &key); + BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &EventIndex); + ST->ConIn->ReadKeyStroke(ST->ConIn, &key); return key; } @@ -61,7 +61,7 @@ console_check_for_keystroke(CHAR16 key) * it */ for(;;) { - status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &k); + status = ST->ConIn->ReadKeyStroke(ST->ConIn, &k); if (status != EFI_SUCCESS) break; @@ -83,7 +83,7 @@ console_print_box_at(CHAR16 *str_arr[], int highlight, int start_col, int start_ if (lines == 0) return; - uefi_call_wrapper(co->QueryMode, 4, co, co->Mode->Mode, &cols, &rows); + co->QueryMode(co, co->Mode->Mode, &cols, &rows); /* last row on screen is unusable without scrolling, so ignore it */ rows--; @@ -126,8 +126,8 @@ console_print_box_at(CHAR16 *str_arr[], int highlight, int start_col, int start_ Line[0] = BOXDRAW_DOWN_RIGHT; Line[size_cols - 1] = BOXDRAW_DOWN_LEFT; Line[size_cols] = L'\0'; - uefi_call_wrapper(co->SetCursorPosition, 3, co, start_col, start_row); - uefi_call_wrapper(co->OutputString, 2, co, Line); + co->SetCursorPosition(co, start_col, start_row); + co->OutputString(co, Line); int start; if (offset == 0) @@ -158,19 +158,19 @@ console_print_box_at(CHAR16 *str_arr[], int highlight, int start_col, int start_ CopyMem(Line + col + 1, s, min(len, size_cols - 2)*2); } if (line >= 0 && line == highlight) - uefi_call_wrapper(co->SetAttribute, 2, co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLACK); - uefi_call_wrapper(co->SetCursorPosition, 3, co, start_col, i); - uefi_call_wrapper(co->OutputString, 2, co, Line); + co->SetAttribute(co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLACK); + co->SetCursorPosition(co, start_col, i); + co->OutputString(co, Line); if (line >= 0 && line == highlight) - uefi_call_wrapper(co->SetAttribute, 2, co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); + co->SetAttribute(co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); } SetMem16 (Line, size_cols * 2, BOXDRAW_HORIZONTAL); Line[0] = BOXDRAW_UP_RIGHT; Line[size_cols - 1] = BOXDRAW_UP_LEFT; Line[size_cols] = L'\0'; - uefi_call_wrapper(co->SetCursorPosition, 3, co, start_col, i); - uefi_call_wrapper(co->OutputString, 2, co, Line); + co->SetCursorPosition(co, start_col, i); + co->OutputString(co, Line); FreePool (Line); @@ -182,19 +182,19 @@ console_print_box(CHAR16 *str_arr[], int highlight) SIMPLE_TEXT_OUTPUT_MODE SavedConsoleMode; SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut; CopyMem(&SavedConsoleMode, co->Mode, sizeof(SavedConsoleMode)); - uefi_call_wrapper(co->EnableCursor, 2, co, FALSE); - uefi_call_wrapper(co->SetAttribute, 2, co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); + co->EnableCursor(co, FALSE); + co->SetAttribute(co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); console_print_box_at(str_arr, highlight, 0, 0, -1, -1, 0, count_lines(str_arr)); console_get_keystroke(); - uefi_call_wrapper(co->EnableCursor, 2, co, SavedConsoleMode.CursorVisible); + co->EnableCursor(co, SavedConsoleMode.CursorVisible); - uefi_call_wrapper(co->EnableCursor, 2, co, SavedConsoleMode.CursorVisible); - uefi_call_wrapper(co->SetCursorPosition, 3, co, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow); - uefi_call_wrapper(co->SetAttribute, 2, co, SavedConsoleMode.Attribute); + co->EnableCursor(co, SavedConsoleMode.CursorVisible); + co->SetCursorPosition(co, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow); + co->SetAttribute(co, SavedConsoleMode.Attribute); } int @@ -211,7 +211,7 @@ console_select(CHAR16 *title[], CHAR16* selectors[], int start) int title_lines = count_lines(title); UINTN cols, rows; - uefi_call_wrapper(co->QueryMode, 4, co, co->Mode->Mode, &cols, &rows); + co->QueryMode(co, co->Mode->Mode, &cols, &rows); for (i = 0; i < selector_lines; i++) { int len = StrLen(selectors[i]); @@ -247,8 +247,8 @@ console_select(CHAR16 *title[], CHAR16* selectors[], int start) } CopyMem(&SavedConsoleMode, co->Mode, sizeof(SavedConsoleMode)); - uefi_call_wrapper(co->EnableCursor, 2, co, FALSE); - uefi_call_wrapper(co->SetAttribute, 2, co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); + co->EnableCursor(co, FALSE); + co->SetAttribute(co, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE); console_print_box_at(title, -1, 0, 0, -1, -1, 1, count_lines(title)); @@ -281,11 +281,11 @@ console_select(CHAR16 *title[], CHAR16* selectors[], int start) } while (!(k.ScanCode == SCAN_NULL && k.UnicodeChar == CHAR_CARRIAGE_RETURN)); - uefi_call_wrapper(co->EnableCursor, 2, co, SavedConsoleMode.CursorVisible); + co->EnableCursor(co, SavedConsoleMode.CursorVisible); - uefi_call_wrapper(co->EnableCursor, 2, co, SavedConsoleMode.CursorVisible); - uefi_call_wrapper(co->SetCursorPosition, 3, co, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow); - uefi_call_wrapper(co->SetAttribute, 2, co, SavedConsoleMode.Attribute); + co->EnableCursor(co, SavedConsoleMode.CursorVisible); + co->SetCursorPosition(co, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow); + co->SetAttribute(co, SavedConsoleMode.Attribute); if (selector < 0) /* ESC pressed */ @@ -405,8 +405,8 @@ console_reset(void) { SIMPLE_TEXT_OUTPUT_INTERFACE *co = ST->ConOut; - uefi_call_wrapper(co->Reset, 2, co, TRUE); + co->Reset(co, TRUE); /* set mode 0 - required to be 80x25 */ - uefi_call_wrapper(co->SetMode, 2, co, 0); - uefi_call_wrapper(co->ClearScreen, 1, co); + co->SetMode(co, 0); + co->ClearScreen(co); } diff --git a/lib/execute.c b/lib/execute.c index 8d726eb..4ed4045 100644 --- a/lib/execute.c +++ b/lib/execute.c @@ -102,8 +102,7 @@ execute(EFI_HANDLE image, CHAR16 *name) EFI_DEVICE_PATH *devpath; CHAR16 *PathName; - status = uefi_call_wrapper(BS->HandleProtocol, 3, image, - &IMAGE_PROTOCOL, &li); + status = BS->HandleProtocol(image, &IMAGE_PROTOCOL, (VOID **)&li); if (status != EFI_SUCCESS) return status; @@ -112,13 +111,12 @@ execute(EFI_HANDLE image, CHAR16 *name) if (status != EFI_SUCCESS) return status; - status = uefi_call_wrapper(BS->LoadImage, 6, FALSE, image, - devpath, NULL, 0, &h); + status = BS->LoadImage(FALSE, image, devpath, NULL, 0, &h); if (status != EFI_SUCCESS) goto out; - status = uefi_call_wrapper(BS->StartImage, 3, h, NULL, NULL); - uefi_call_wrapper(BS->UnloadImage, 1, h); + status = BS->StartImage(h, NULL, NULL); + BS->UnloadImage(h); out: FreePool(PathName); @@ -6,6 +6,7 @@ #include <guid.h> #include <stdio.h> +#include <buildefi.h> #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) diff --git a/lib/pecoff.c b/lib/pecoff.c index 11445cd..87b9de1 100644 --- a/lib/pecoff.c +++ b/lib/pecoff.c @@ -57,14 +57,8 @@ #include <variables.h> #include <sha256.h> #include <errors.h> - -#ifndef BUILD_EFI -#include <stdio.h> -#define Print(...) printf("%ls", __VA_ARGS__) -#define AllocatePool(x) malloc(x) -#define CopyMem(d, s, l) memcpy(d, s, l) -#define ZeroMem(s, l) memset(s, 0, l) -#endif +#include <execute.h> +#include <buildefi.h> EFI_STATUS pecoff_read_header(PE_COFF_LOADER_IMAGE_CONTEXT *context, void *data) @@ -335,21 +329,19 @@ pecoff_execute_checked(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab, CHAR16 *name) EFI_HANDLE h; EFI_FILE *file; - status = uefi_call_wrapper(BS->HandleProtocol, 3, image, - &IMAGE_PROTOCOL, &li); + status = BS->HandleProtocol(image, &IMAGE_PROTOCOL, (VOID **)&li); if (status != EFI_SUCCESS) return status; status = generate_path(name, li, &loadpath, &PathName); if (status != EFI_SUCCESS) return status; - status = uefi_call_wrapper(BS->LoadImage, 6, FALSE, image, - loadpath, NULL, 0, &h); + status = BS->LoadImage(FALSE, image, loadpath, NULL, 0, &h); if (status == EFI_SECURITY_VIOLATION || status == EFI_ACCESS_DENIED) status = pecoff_check_mok(image, name); if (status != EFI_SUCCESS) /* this will fail if signature validation fails */ return status; - uefi_call_wrapper(BS->UnloadImage, 1, h); + BS->UnloadImage(h); status = simple_file_open(image, name, &file, EFI_FILE_MODE_READ); if (status != EFI_SUCCESS) @@ -397,7 +389,7 @@ pecoff_execute_image(EFI_FILE *file, CHAR16 *name, EFI_HANDLE image, goto out; } - efi_status = uefi_call_wrapper(entry_point, 2, image, systab); + efi_status = entry_point(image, systab); out: FreePool(buffer); diff --git a/lib/security_policy.c b/lib/security_policy.c index 39654d4..37a58e4 100644 --- a/lib/security_policy.c +++ b/lib/security_policy.c @@ -104,8 +104,8 @@ security_policy_check_mok(void *data, UINTN len) return EFI_SECURITY_VIOLATION; } -static EFI_SECURITY_FILE_AUTHENTICATION_STATE esfas = NULL; -static EFI_SECURITY2_FILE_AUTHENTICATION es2fa = NULL; +static EFIAPI EFI_SECURITY_FILE_AUTHENTICATION_STATE esfas = NULL; +static EFIAPI EFI_SECURITY2_FILE_AUTHENTICATION es2fa = NULL; EFI_STATUS EFIAPI @@ -121,8 +121,7 @@ security2_policy_authentication ( /* Chain original security policy */ - status = uefi_call_wrapper(es2fa, 5, This, DevicePath, FileBuffer, - FileSize, BootPolicy); + status = es2fa(This, DevicePath, FileBuffer, FileSize, BootPolicy); /* if OK, don't bother with MOK check */ if (status == EFI_SUCCESS) @@ -158,8 +157,7 @@ security_policy_authentication ( CHAR16* DevPathStr; /* Chain original security policy */ - status = uefi_call_wrapper(esfas, 3, This, AuthenticationStatus, - DevicePathConst); + status = esfas(This, AuthenticationStatus, DevicePathConst); /* if OK avoid checking MOK: It's a bit expensive to * read the whole file in again (esfas already did this) */ @@ -170,8 +168,7 @@ security_policy_authentication ( * EFI_SECURITY_VIOLATION */ fail_status = status; - status = uefi_call_wrapper(BS->LocateDevicePath, 3, - &SIMPLE_FS_PROTOCOL, &DevPath, &h); + status = BS->LocateDevicePath(&SIMPLE_FS_PROTOCOL, &DevPath, &h); if (status != EFI_SUCCESS) goto out; @@ -213,13 +210,11 @@ security_policy_install(void) /* Don't bother with status here. The call is allowed * to fail, since SECURITY2 was introduced in PI 1.2.1 * If it fails, use security2_protocol == NULL as indicator */ - uefi_call_wrapper(BS->LocateProtocol, 3, - &SECURITY2_PROTOCOL_GUID, NULL, - &security2_protocol); + BS->LocateProtocol(&SECURITY2_PROTOCOL_GUID, NULL, + (VOID **)&security2_protocol); - status = uefi_call_wrapper(BS->LocateProtocol, 3, - &SECURITY_PROTOCOL_GUID, NULL, - &security_protocol); + status = BS->LocateProtocol(&SECURITY_PROTOCOL_GUID, NULL, + (VOID **)&security_protocol); if (status != EFI_SUCCESS) /* This one is mandatory, so there's a serious problem */ return status; @@ -253,9 +248,8 @@ security_policy_uninstall(void) if (esfas) { EFI_SECURITY_PROTOCOL *security_protocol; - status = uefi_call_wrapper(BS->LocateProtocol, 3, - &SECURITY_PROTOCOL_GUID, NULL, - &security_protocol); + status = BS->LocateProtocol(&SECURITY_PROTOCOL_GUID, NULL, + (VOID **)&security_protocol); if (status != EFI_SUCCESS) return status; @@ -270,9 +264,8 @@ security_policy_uninstall(void) if (es2fa) { EFI_SECURITY2_PROTOCOL *security2_protocol; - status = uefi_call_wrapper(BS->LocateProtocol, 3, - &SECURITY2_PROTOCOL_GUID, NULL, - &security2_protocol); + status = BS->LocateProtocol(&SECURITY2_PROTOCOL_GUID, NULL, + (VOID **)&security2_protocol); if (status != EFI_SUCCESS) return status; diff --git a/lib/sha256.c b/lib/sha256.c index 8966ff5..96963a1 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -24,15 +24,7 @@ #include <sha256.h> #include <pecoff.h> #include <simple_file.h> - -#ifndef BUILD_EFI -#include <stdio.h> -#define Print(...) printf("%ls", __VA_ARGS__) -#define AllocatePool(x) malloc(x) -#define CopyMem(d, s, l) memcpy(d, s, l) -#define ZeroMem(s, l) memset(s, 0, l) -#define FreePool(s) free(s) -#endif +#include <buildefi.h> #define GET_UINT32(n,b,i) \ { \ diff --git a/lib/shell.c b/lib/shell.c index 51de4e0..e38829c 100644 --- a/lib/shell.c +++ b/lib/shell.c @@ -20,7 +20,7 @@ argsplit(EFI_HANDLE image, int *argc, CHAR16*** ARGV) *argc = 0; - status = uefi_call_wrapper(BS->HandleProtocol, 3, image, &LoadedImageProtocol, (VOID **) &info); + status = BS->HandleProtocol(image, &LoadedImageProtocol, (VOID **) &info); if (EFI_ERROR(status)) { Print(L"Failed to get arguments\n"); return status; diff --git a/lib/simple_file.c b/lib/simple_file.c index 7b37418..22d807a 100644 --- a/lib/simple_file.c +++ b/lib/simple_file.c @@ -25,23 +25,21 @@ simple_file_open_by_handle(EFI_HANDLE device, CHAR16 *name, EFI_FILE **file, UIN EFI_FILE_IO_INTERFACE *drive; EFI_FILE *root; - efi_status = uefi_call_wrapper(BS->HandleProtocol, 3, device, - &SIMPLE_FS_PROTOCOL, &drive); + efi_status = BS->HandleProtocol(device, &SIMPLE_FS_PROTOCOL, (VOID **)&drive); if (efi_status != EFI_SUCCESS) { Print(L"Unable to find simple file protocol (%d)\n", efi_status); goto error; } - efi_status = uefi_call_wrapper(drive->OpenVolume, 2, drive, &root); + efi_status = drive->OpenVolume(drive, &root); if (efi_status != EFI_SUCCESS) { Print(L"Failed to open drive volume (%d)\n", efi_status); goto error; } - efi_status = uefi_call_wrapper(root->Open, 5, root, file, name, - mode, 0); + efi_status = root->Open(root, file, name, mode, 0); error: return efi_status; @@ -56,8 +54,7 @@ simple_file_open(EFI_HANDLE image, CHAR16 *name, EFI_FILE **file, UINT64 mode) EFI_DEVICE_PATH *loadpath = NULL; CHAR16 *PathName = NULL; - efi_status = uefi_call_wrapper(BS->HandleProtocol, 3, image, - &IMAGE_PROTOCOL, &li); + efi_status = BS->HandleProtocol(image, &IMAGE_PROTOCOL, (VOID **)&li); if (efi_status != EFI_SUCCESS) return simple_file_open_by_handle(image, name, file, mode); @@ -88,8 +85,7 @@ simple_dir_read_all_by_handle(EFI_HANDLE image, EFI_FILE *file, CHAR16* name, EF UINTN size = sizeof(buf); EFI_FILE_INFO *fi = (void *)buf; - status = uefi_call_wrapper(file->GetInfo, 4, file, &FILE_INFO, - &size, fi); + status = file->GetInfo(file, &FILE_INFO, &size, fi); if (status != EFI_SUCCESS) { Print(L"Failed to get file info\n"); goto out; @@ -103,13 +99,13 @@ simple_dir_read_all_by_handle(EFI_HANDLE image, EFI_FILE *file, CHAR16* name, EF *count = 0; for (;;) { UINTN len = sizeof(buf); - status = uefi_call_wrapper(file->Read, 3, file, &len, buf); + status = file->Read(file, &len, buf); if (status != EFI_SUCCESS || len == 0) break; (*count)++; size += len; } - uefi_call_wrapper(file->SetPosition, 2, file, 0); + file->SetPosition(file, 0); char *ptr = AllocatePool(size); *entries = (EFI_FILE_INFO *)ptr; @@ -117,8 +113,8 @@ simple_dir_read_all_by_handle(EFI_HANDLE image, EFI_FILE *file, CHAR16* name, EF return EFI_OUT_OF_RESOURCES; int i; for (i = 0; i < *count; i++) { - int len = size; - uefi_call_wrapper(file->Read, 3, file, &len, ptr); + UINTN len = size; + file->Read(file, &len, ptr); ptr += len; size -= len; } @@ -159,8 +155,7 @@ simple_file_read_all(EFI_FILE *file, UINTN *size, void **buffer) fi = (void *)buf; - efi_status = uefi_call_wrapper(file->GetInfo, 4, file, &FILE_INFO, - size, fi); + efi_status = file->GetInfo(file, &FILE_INFO, size, fi); if (efi_status != EFI_SUCCESS) { Print(L"Failed to get file info\n"); return efi_status; @@ -174,7 +169,7 @@ simple_file_read_all(EFI_FILE *file, UINTN *size, void **buffer) Print(L"Failed to allocate buffer of size %d\n", *size); return EFI_OUT_OF_RESOURCES; } - efi_status = uefi_call_wrapper(file->Read, 3, file, size, *buffer); + efi_status = file->Read(file, size, *buffer); return efi_status; } @@ -185,7 +180,7 @@ simple_file_write_all(EFI_FILE *file, UINTN size, void *buffer) { EFI_STATUS efi_status; - efi_status = uefi_call_wrapper(file->Write, 3, file, &size, buffer); + efi_status = file->Write(file, &size, buffer); return efi_status; } @@ -193,7 +188,7 @@ simple_file_write_all(EFI_FILE *file, UINTN size, void *buffer) void simple_file_close(EFI_FILE *file) { - uefi_call_wrapper(file->Close, 1, file); + file->Close(file); } EFI_STATUS @@ -205,8 +200,8 @@ simple_volume_selector(CHAR16 **title, CHAR16 **selected, EFI_HANDLE *h) CHAR16 **entries; int val; - uefi_call_wrapper(BS->LocateHandleBuffer, 5, ByProtocol, - &SIMPLE_FS_PROTOCOL, NULL, &count, &vol_handles); + BS->LocateHandleBuffer(ByProtocol, &SIMPLE_FS_PROTOCOL, NULL, + &count, &vol_handles); if (!count || !vol_handles) return EFI_NOT_FOUND; @@ -223,18 +218,17 @@ simple_volume_selector(CHAR16 **title, CHAR16 **selected, EFI_HANDLE *h) CHAR16 *name; EFI_FILE_IO_INTERFACE *drive; - status = uefi_call_wrapper(BS->HandleProtocol, 3, - vol_handles[i], - &SIMPLE_FS_PROTOCOL, &drive); + status = BS->HandleProtocol(vol_handles[i], + &SIMPLE_FS_PROTOCOL, + (VOID **)&drive); if (status != EFI_SUCCESS || !drive) continue; - status = uefi_call_wrapper(drive->OpenVolume, 2, drive, &root); + status = drive->OpenVolume(drive, &root); if (status != EFI_SUCCESS) continue; - status = uefi_call_wrapper(root->GetInfo, 4, root, &FS_INFO, - &size, fi); + status = root->GetInfo(root, &FS_INFO, &size, fi); if (status != EFI_SUCCESS) continue; diff --git a/lib/variables.c b/lib/variables.c index 37bb1c1..6d78679 100644 --- a/lib/variables.c +++ b/lib/variables.c @@ -99,7 +99,7 @@ CreateTimeBasedPayload ( DescriptorData = (EFI_VARIABLE_AUTHENTICATION_2 *) (NewData); ZeroMem (&Time, sizeof (EFI_TIME)); - Status = uefi_call_wrapper(RT->GetTime,2, &Time, NULL); + Status = RT->GetTime(&Time, NULL); if (EFI_ERROR (Status)) { FreePool(NewData); return Status; @@ -164,13 +164,13 @@ SetSecureVariable(CHAR16 *var, UINT8 *Data, UINTN len, EFI_GUID owner, return efi_status; } - efi_status = uefi_call_wrapper(RT->SetVariable, 5, var, &owner, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_RUNTIME_ACCESS - | EFI_VARIABLE_BOOTSERVICE_ACCESS - | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS - | options, - DataSize, Cert); + efi_status = RT->SetVariable(var, &owner, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_RUNTIME_ACCESS + | EFI_VARIABLE_BOOTSERVICE_ACCESS + | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS + | options, + DataSize, Cert); return efi_status; } @@ -182,7 +182,7 @@ GetOSIndications(void) UINTN DataSize = sizeof(indications); EFI_STATUS efi_status; - efi_status = uefi_call_wrapper(RT->GetVariable, 5, L"OsIndicationsSupported", &GV_GUID, NULL, &DataSize, &indications); + efi_status = RT->GetVariable(L"OsIndicationsSupported", &GV_GUID, NULL, &DataSize, &indications); if (efi_status != EFI_SUCCESS) return 0; @@ -195,17 +195,17 @@ SETOSIndicationsAndReboot(UINT64 indications) UINTN DataSize = sizeof(indications); EFI_STATUS efi_status; - efi_status = uefi_call_wrapper(RT->SetVariable, 5, L"OsIndications", - &GV_GUID, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_RUNTIME_ACCESS - | EFI_VARIABLE_BOOTSERVICE_ACCESS, - DataSize, &indications); + efi_status = RT->SetVariable(L"OsIndications", + &GV_GUID, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_RUNTIME_ACCESS + | EFI_VARIABLE_BOOTSERVICE_ACCESS, + DataSize, &indications); if (efi_status != EFI_SUCCESS) return efi_status; - uefi_call_wrapper(RT->ResetSystem, 4, EfiResetWarm, EFI_SUCCESS, 0, NULL); + RT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL); /* does not return */ return EFI_SUCCESS; @@ -219,8 +219,7 @@ get_variable_attr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner, *len = 0; - efi_status = uefi_call_wrapper(RT->GetVariable, 5, var, &owner, - NULL, len, NULL); + efi_status = RT->GetVariable(var, &owner, NULL, len, NULL); if (efi_status != EFI_BUFFER_TOO_SMALL) return efi_status; @@ -228,8 +227,7 @@ get_variable_attr(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner, if (!data) return EFI_OUT_OF_RESOURCES; - efi_status = uefi_call_wrapper(RT->GetVariable, 5, var, &owner, - attributes, len, *data); + efi_status = RT->GetVariable(var, &owner, attributes, len, *data); if (efi_status != EFI_SUCCESS) { FreePool(*data); @@ -286,8 +284,7 @@ variable_is_setupmode(void) UINT8 SetupMode = 1; UINTN DataSize = sizeof(SetupMode); - uefi_call_wrapper(RT->GetVariable, 5, L"SetupMode", &GV_GUID, NULL, - &DataSize, &SetupMode); + RT->GetVariable(L"SetupMode", &GV_GUID, NULL, &DataSize, &SetupMode); return SetupMode; } @@ -300,8 +297,7 @@ variable_is_secureboot(void) UINTN DataSize; DataSize = sizeof(SecureBoot); - uefi_call_wrapper(RT->GetVariable, 5, L"SecureBoot", &GV_GUID, NULL, - &DataSize, &SecureBoot); + RT->GetVariable(L"SecureBoot", &GV_GUID, NULL, &DataSize, &SecureBoot); return SecureBoot; } @@ -331,10 +327,10 @@ variable_enroll_hash(CHAR16 *var, EFI_GUID owner, status = SetSecureVariable(var, sig, sizeof(sig), owner, EFI_VARIABLE_APPEND_WRITE, 0); else - status = uefi_call_wrapper(RT->SetVariable, 5, var, &owner, - EFI_VARIABLE_NON_VOLATILE - | EFI_VARIABLE_BOOTSERVICE_ACCESS - | EFI_VARIABLE_APPEND_WRITE, - sizeof(sig), sig); + status = RT->SetVariable(var, &owner, + EFI_VARIABLE_NON_VOLATILE + | EFI_VARIABLE_BOOTSERVICE_ACCESS + | EFI_VARIABLE_APPEND_WRITE, + sizeof(sig), sig); return status; } |