efi: Directly use EFI functions instead of using GNU-EFI's call wrapper

This commit is contained in:
mintsuki 2021-08-25 22:03:00 +02:00
parent 23a93a85dc
commit 31f52c2b30
12 changed files with 69 additions and 102 deletions

View File

@ -61,7 +61,6 @@ INTERNAL_CFLAGS := \
-fno-stack-protector \
-fno-omit-frame-pointer \
-fno-lto \
-fno-pic \
-Wno-address-of-packed-member \
-Wshadow \
-mno-80387 \
@ -85,6 +84,7 @@ ifeq ($(TARGET), bios)
-m32 \
-march=i386 \
-mabi=sysv \
-fno-pic \
-fno-pie
endif
@ -96,6 +96,7 @@ ifeq ($(TARGET), uefi)
-m32 \
-march=i386 \
-mabi=sysv \
-DGNU_EFI_USE_MS_ABI \
-fpie
INTERNAL_CFLAGS += \
@ -104,6 +105,7 @@ ifeq ($(TARGET), uefi)
-m64 \
-march=x86-64 \
-mabi=sysv \
-DGNU_EFI_USE_MS_ABI \
-I../gnu-efi/inc \
-I../gnu-efi/inc/x86_64 \
-fpie \
@ -117,6 +119,7 @@ ifeq ($(TARGET), uefi32)
-m32 \
-march=i386 \
-mabi=sysv \
-DGNU_EFI_USE_MS_ABI \
-I../gnu-efi/inc \
-I../gnu-efi/inc/ia32 \
-fpie
@ -254,15 +257,12 @@ $(BUILDDIR)/BOOTX64.EFI: $(BUILDDIR)/limine_efi.elf
$(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a: $(BUILDDIR)/gnu-efi
$(MAKE) -C $(BUILDDIR)/gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m64 -march=x86-64" AR="$(TOOLCHAIN_AR)" ARCH=x86_64
$(BUILDDIR)/gnu-efi/lib/x86_64/efi_stub.o: $(BUILDDIR)/gnu-efi
$(MAKE) -C $(BUILDDIR)/gnu-efi/lib CC="$(TOOLCHAIN_CC) -m64 -march=x86-64" ARCH=x86_64 x86_64/efi_stub.o
$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(BUILDDIR)/gnu-efi/lib/x86_64/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
$(TOOLCHAIN_LD) \
-Tlinker_uefi_nomap.ld \
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(BUILDDIR)/gnu-efi/lib/x86_64/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o
$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o
$(TOOLCHAIN_LD) \
-Tlinker_uefi.ld \
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
@ -282,15 +282,12 @@ $(BUILDDIR)/BOOTIA32.EFI: $(BUILDDIR)/limine_efi.elf
$(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a: $(BUILDDIR)/gnu-efi
$(MAKE) -C $(BUILDDIR)/gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m32 -march=i386" AR="$(TOOLCHAIN_AR)" ARCH=ia32
$(BUILDDIR)/gnu-efi/lib/ia32/efi_stub.o: $(BUILDDIR)/gnu-efi
$(MAKE) -C $(BUILDDIR)/gnu-efi/lib CC="$(TOOLCHAIN_CC) -m32 -march=i386" ARCH=ia32 ia32/efi_stub.o
$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(BUILDDIR)/gnu-efi/lib/ia32/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o
$(TOOLCHAIN_LD) \
-Tlinker_uefi32_nomap.ld \
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(BUILDDIR)/gnu-efi/lib/ia32/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o
$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o
$(TOOLCHAIN_LD) \
-Tlinker_uefi32.ld \
$^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@

View File

@ -214,23 +214,19 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE *efi_handle) {
EFI_DISK_IO *disk_io = NULL;
EFI_BLOCK_IO *block_io = NULL;
status = uefi_call_wrapper(gBS->HandleProtocol, 3, efi_handle, &disk_io_guid,
(void **)&disk_io);
status = gBS->HandleProtocol(efi_handle, &disk_io_guid, (void **)&disk_io);
if (status)
return NULL;
status = uefi_call_wrapper(gBS->HandleProtocol, 3, efi_handle, &block_io_guid,
(void **)&block_io);
status = gBS->HandleProtocol(efi_handle, &block_io_guid, (void **)&block_io);
if (status)
return NULL;
uint64_t signature = BUILD_ID;
uint64_t orig;
uefi_call_wrapper(disk_io->ReadDisk, 5, disk_io, block_io->Media->MediaId, 0,
sizeof(uint64_t), &orig);
disk_io->ReadDisk(disk_io, block_io->Media->MediaId, 0, sizeof(uint64_t), &orig);
status = uefi_call_wrapper(disk_io->WriteDisk, 5,
disk_io, block_io->Media->MediaId, 0, sizeof(uint64_t), &signature);
status = disk_io->WriteDisk(disk_io, block_io->Media->MediaId, 0, sizeof(uint64_t), &signature);
if (status) {
// Really hacky support for CDs because they are read-only
@ -248,12 +244,12 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE *efi_handle) {
EFI_DISK_IO *cur_disk_io = NULL;
EFI_BLOCK_IO *cur_block_io = NULL;
uefi_call_wrapper(gBS->HandleProtocol, 3, volume_index[i]->efi_handle,
gBS->HandleProtocol(volume_index[i]->efi_handle,
&disk_io_guid, (void **)&cur_disk_io);
uefi_call_wrapper(gBS->HandleProtocol, 3, volume_index[i]->efi_handle,
gBS->HandleProtocol(volume_index[i]->efi_handle,
&block_io_guid, (void **)&cur_block_io);
uefi_call_wrapper(cur_disk_io->ReadDisk, 5, cur_disk_io,
cur_disk_io->ReadDisk(cur_disk_io,
cur_block_io->Media->MediaId,
0 +
volume_index[i]->first_sect * volume_index[i]->sector_size,
@ -265,8 +261,7 @@ struct volume *disk_volume_from_efi_handle(EFI_HANDLE *efi_handle) {
}
}
uefi_call_wrapper(disk_io->WriteDisk, 5, disk_io, block_io->Media->MediaId, 0,
sizeof(uint64_t), &orig);
disk_io->WriteDisk(disk_io, block_io->Media->MediaId, 0, sizeof(uint64_t), &orig);
return ret;
}
@ -277,10 +272,10 @@ bool disk_read_sectors(struct volume *volume, void *buf, uint64_t block, size_t
EFI_GUID block_io_guid = BLOCK_IO_PROTOCOL;
EFI_BLOCK_IO *block_io = NULL;
status = uefi_call_wrapper(gBS->HandleProtocol, 3, volume->efi_handle,
status = gBS->HandleProtocol(volume->efi_handle,
&block_io_guid, (void **)&block_io);
status = uefi_call_wrapper(block_io->ReadBlocks, 5, block_io,
status = block_io->ReadBlocks(block_io,
block_io->Media->MediaId,
block, count * volume->sector_size, buf);
@ -298,13 +293,11 @@ void disk_create_index(void) {
EFI_HANDLE *handles = NULL;
UINTN handles_size = 0;
uefi_call_wrapper(gBS->LocateHandle, 5, ByProtocol, &block_io_guid,
NULL, &handles_size, handles);
gBS->LocateHandle(ByProtocol, &block_io_guid, NULL, &handles_size, handles);
handles = ext_mem_alloc(handles_size);
uefi_call_wrapper(gBS->LocateHandle, 5, ByProtocol, &block_io_guid,
NULL, &handles_size, handles);
gBS->LocateHandle(ByProtocol, &block_io_guid, NULL, &handles_size, handles);
volume_index = ext_mem_alloc(sizeof(struct volume) * MAX_VOLUMES);
@ -319,13 +312,11 @@ void disk_create_index(void) {
EFI_GUID disk_io_guid = DISK_IO_PROTOCOL;
EFI_DISK_IO *disk_io = NULL;
uefi_call_wrapper(gBS->HandleProtocol, 3, handles[i], &disk_io_guid,
(void **)&disk_io);
gBS->HandleProtocol(handles[i], &disk_io_guid, (void **)&disk_io);
EFI_BLOCK_IO *drive = NULL;
status = uefi_call_wrapper(gBS->HandleProtocol, 3, handles[i],
&block_io_guid, (void **)&drive);
status = gBS->HandleProtocol(handles[i], &block_io_guid, (void **)&drive);
if (status != 0 || drive == NULL || drive->Media->LastBlock == 0)
continue;
@ -334,10 +325,8 @@ void disk_create_index(void) {
continue;
uint64_t orig;
uefi_call_wrapper(disk_io->ReadDisk, 5,
disk_io, drive->Media->MediaId, 0, sizeof(uint64_t), &orig);
status = uefi_call_wrapper(disk_io->WriteDisk, 5,
disk_io, drive->Media->MediaId, 0, sizeof(uint64_t), &orig);
disk_io->ReadDisk(disk_io, drive->Media->MediaId, 0, sizeof(uint64_t), &orig);
status = disk_io->WriteDisk(disk_io, drive->Media->MediaId, 0, sizeof(uint64_t), &orig);
struct volume *block = ext_mem_alloc(sizeof(struct volume));

View File

@ -58,16 +58,14 @@ struct edid_info_struct *get_edid_info(void) {
UINTN handles_size = 0;
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
status = uefi_call_wrapper(gBS->LocateHandle, 5,
ByProtocol, &gop_guid, NULL, &handles_size, handles);
status = gBS->LocateHandle(ByProtocol, &gop_guid, NULL, &handles_size, handles);
if (status && status != EFI_BUFFER_TOO_SMALL)
goto fail;
handles = ext_mem_alloc(handles_size);
status = uefi_call_wrapper(gBS->LocateHandle, 5,
ByProtocol, &gop_guid, NULL, &handles_size, handles);
status = gBS->LocateHandle(ByProtocol, &gop_guid, NULL, &handles_size, handles);
if (status)
goto fail;
@ -75,8 +73,7 @@ struct edid_info_struct *get_edid_info(void) {
EFI_EDID_ACTIVE_PROTOCOL *edid = NULL;
EFI_GUID edid_guid = EFI_EDID_ACTIVE_PROTOCOL_GUID;
status = uefi_call_wrapper(gBS->HandleProtocol, 3,
handles[0], &edid_guid, (void **)&edid);
status = gBS->HandleProtocol(handles[0], &edid_guid, (void **)&edid);
if (status)
goto fail;

View File

@ -40,13 +40,12 @@ static bool try_mode(struct fb_info *ret, size_t mode, int width, int height, in
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;
uefi_call_wrapper(gBS->LocateProtocol, 3, &gop_guid, NULL, (void **)&gop);
gBS->LocateProtocol(&gop_guid, NULL, (void **)&gop);
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info;
UINTN mode_info_size;
status = uefi_call_wrapper(gop->QueryMode, 4,
gop, mode, &mode_info_size, &mode_info);
status = gop->QueryMode(gop, mode, &mode_info_size, &mode_info);
if (status)
return false;
@ -102,7 +101,7 @@ static bool try_mode(struct fb_info *ret, size_t mode, int width, int height, in
if ((int)mode == current_video_mode) {
printv("gop: Mode was already set, perfect!\n");
} else {
status = uefi_call_wrapper(gop->SetMode, 2, gop, mode);
status = gop->SetMode(gop, mode);
if (status) {
current_video_mode = -2;
@ -137,17 +136,16 @@ bool init_gop(struct fb_info *ret,
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;
uefi_call_wrapper(gBS->LocateProtocol, 3, &gop_guid, NULL, (void **)&gop);
gBS->LocateProtocol(&gop_guid, NULL, (void **)&gop);
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info;
UINTN mode_info_size;
status = uefi_call_wrapper(gop->QueryMode, 4, gop,
gop->Mode == NULL ? 0 : gop->Mode->Mode,
&mode_info_size, &mode_info);
status = gop->QueryMode(gop, gop->Mode == NULL ? 0 : gop->Mode->Mode,
&mode_info_size, &mode_info);
if (status == EFI_NOT_STARTED) {
status = uefi_call_wrapper(gop->SetMode, 2, gop, 0);
status = gop->SetMode(gop, 0);
}
if (status) {

View File

@ -67,9 +67,8 @@ void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
EFI_GUID loaded_img_prot_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
EFI_LOADED_IMAGE_PROTOCOL *loaded_image = NULL;
status = uefi_call_wrapper(gBS->HandleProtocol, 3,
current_handle, &loaded_img_prot_guid,
(void **)&loaded_image);
status = gBS->HandleProtocol(current_handle, &loaded_img_prot_guid,
(void **)&loaded_image);
if (status) {
panic("HandleProtocol failure (%x)", status);

View File

@ -15,7 +15,8 @@ EFI_BOOT_SERVICES *gBS;
EFI_RUNTIME_SERVICES *gRT;
EFI_HANDLE efi_image_handle;
EFI_MEMORY_DESCRIPTOR *efi_mmap = NULL;
UINTN efi_mmap_size = 0, efi_desc_size = 0, efi_desc_ver = 0;
UINTN efi_mmap_size = 0, efi_desc_size = 0;
UINT32 efi_desc_ver = 0;
#endif
bool verbose = false;
@ -93,27 +94,24 @@ bool efi_exit_boot_services(void) {
efi_mmap_size = sizeof(tmp_mmap);
UINTN mmap_key = 0;
uefi_call_wrapper(gBS->GetMemoryMap, 5,
&efi_mmap_size, tmp_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
gBS->GetMemoryMap(&efi_mmap_size, tmp_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
efi_mmap_size += 4096;
status = uefi_call_wrapper(gBS->FreePool, 1, efi_mmap);
status = gBS->FreePool(efi_mmap);
if (status)
goto fail;
status = uefi_call_wrapper(gBS->AllocatePool, 3,
EfiLoaderData, efi_mmap_size, (void **)&efi_mmap);
status = gBS->AllocatePool(EfiLoaderData, efi_mmap_size, (void **)&efi_mmap);
if (status)
goto fail;
status = uefi_call_wrapper(gBS->GetMemoryMap, 5,
&efi_mmap_size, efi_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
status = gBS->GetMemoryMap(&efi_mmap_size, efi_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
if (status)
goto fail;
// Be gone, UEFI!
status = uefi_call_wrapper(gBS->ExitBootServices, 2, efi_image_handle, mmap_key);
status = gBS->ExitBootServices(efi_image_handle, mmap_key);
asm volatile ("cli" ::: "memory");

View File

@ -17,7 +17,8 @@ extern EFI_BOOT_SERVICES *gBS;
extern EFI_RUNTIME_SERVICES *gRT;
extern EFI_HANDLE efi_image_handle;
extern EFI_MEMORY_DESCRIPTOR *efi_mmap;
extern UINTN efi_mmap_size, efi_desc_size, efi_desc_ver;
extern UINTN efi_mmap_size, efi_desc_size;
extern UINT32 efi_desc_ver;
extern bool efi_boot_services_exited;
bool efi_exit_boot_services(void);

View File

@ -33,7 +33,7 @@ __attribute__((noreturn)) void panic(const char *fmt, ...) {
// release all uefi memory and return to firmware
pmm_release_uefi_mem();
uefi_call_wrapper(gBS->Exit, 4, efi_image_handle, EFI_ABORTED, 0, NULL);
gBS->Exit(efi_image_handle, EFI_ABORTED, 0, NULL);
__builtin_unreachable();
} else {
print("System halted.");

View File

@ -98,10 +98,9 @@ again:;
UINTN which;
uefi_call_wrapper(
gBS->WaitForEvent, 3, 1, (EFI_EVENT[]){ gST->ConIn->WaitForKey }, &which);
gBS->WaitForEvent(1, (EFI_EVENT[]){ gST->ConIn->WaitForKey }, &which);
uefi_call_wrapper(gST->ConIn->ReadKeyStroke, 2, gST->ConIn, &key);
gST->ConIn->ReadKeyStroke(gST->ConIn, &key);
int ret = getchar_internal(key.ScanCode, key.UnicodeChar);
@ -120,20 +119,18 @@ int pit_sleep_and_quit_on_keypress(int seconds) {
events[0] = gST->ConIn->WaitForKey;
uefi_call_wrapper(
gBS->CreateEvent, 5, EVT_TIMER, TPL_CALLBACK, NULL, NULL, &events[1]);
gBS->CreateEvent(EVT_TIMER, TPL_CALLBACK, NULL, NULL, &events[1]);
uefi_call_wrapper(
gBS->SetTimer, 3, events[1], TimerRelative, 10000000 * seconds);
gBS->SetTimer(events[1], TimerRelative, 10000000 * seconds);
again:
uefi_call_wrapper(gBS->WaitForEvent, 3, 2, events, &which);
gBS->WaitForEvent(2, events, &which);
if (which == 1) {
return 0;
}
uefi_call_wrapper(gST->ConIn->ReadKeyStroke, 2, gST->ConIn, &key);
gST->ConIn->ReadKeyStroke(gST->ConIn, &key);
int ret = getchar_internal(key.ScanCode, key.UnicodeChar);

View File

@ -52,7 +52,7 @@ uint64_t time(void) {
#if uefi == 1
uint64_t time(void) {
EFI_TIME time;
uefi_call_wrapper(gRT->GetTime, 2, &time, NULL);
gRT->GetTime(&time, NULL);
return get_unix_epoch(time.Second, time.Minute, time.Hour,
time.Day, time.Month, time.Year);

View File

@ -261,16 +261,13 @@ void init_memmap(void) {
efi_mmap_size = sizeof(tmp_mmap);
UINTN mmap_key = 0;
status = uefi_call_wrapper(gBS->GetMemoryMap, 5,
&efi_mmap_size, tmp_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
status = gBS->GetMemoryMap(&efi_mmap_size, tmp_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
efi_mmap_size += 4096;
status = uefi_call_wrapper(gBS->AllocatePool, 3,
EfiLoaderData, efi_mmap_size, (void **)&efi_mmap);
status = gBS->AllocatePool(EfiLoaderData, efi_mmap_size, (void **)&efi_mmap);
status = uefi_call_wrapper(gBS->GetMemoryMap, 5,
&efi_mmap_size, efi_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
status = gBS->GetMemoryMap(&efi_mmap_size, efi_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
size_t entry_count = efi_mmap_size / efi_desc_size;
@ -334,8 +331,8 @@ void init_memmap(void) {
EFI_PHYSICAL_ADDRESS base = memmap[i].base;
status = uefi_call_wrapper(gBS->AllocatePages, 4,
AllocateAddress, EfiLoaderData, memmap[i].length / 4096, &base);
status = gBS->AllocatePages(AllocateAddress, EfiLoaderData,
memmap[i].length / 4096, &base);
if (status)
panic("pmm: AllocatePages failure (%x)", status);
@ -447,8 +444,7 @@ void pmm_release_uefi_mem(void) {
continue;
}
status = uefi_call_wrapper(gBS->FreePages, 2,
memmap[i].base, memmap[i].length / 4096);
status = gBS->FreePages(memmap[i].base, memmap[i].length / 4096);
if (status)
panic("pmm: FreePages failure (%x)", status);

View File

@ -123,8 +123,7 @@ void chainload(char *config) {
void *_ptr = freadall(image, MEMMAP_RESERVED);
size_t image_size = image->size;
void *ptr;
status = uefi_call_wrapper(gBS->AllocatePool, 3,
EfiLoaderData, image_size, &ptr);
status = gBS->AllocatePool(EfiLoaderData, image_size, &ptr);
if (status)
panic("chainload: Allocation failure");
memcpy(ptr, _ptr, image_size);
@ -161,9 +160,9 @@ void chainload(char *config) {
EFI_HANDLE new_handle = 0;
status = uefi_call_wrapper(gBS->LoadImage, 6, 0, efi_image_handle,
(EFI_DEVICE_PATH *)memdev_path,
ptr, image_size, &new_handle);
status = gBS->LoadImage(0, efi_image_handle,
(EFI_DEVICE_PATH *)memdev_path,
ptr, image_size, &new_handle);
if (status) {
panic("chainload: LoadImage failure (%x)", status);
}
@ -173,17 +172,15 @@ void chainload(char *config) {
EFI_GUID loaded_img_prot_guid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
EFI_LOADED_IMAGE_PROTOCOL *loader_loaded_image = NULL;
status = uefi_call_wrapper(gBS->HandleProtocol, 3,
efi_image_handle, &loaded_img_prot_guid,
(void **)&loader_loaded_image);
status = gBS->HandleProtocol(efi_image_handle, &loaded_img_prot_guid,
(void **)&loader_loaded_image);
if (status) {
panic("chainload: HandleProtocol failure (%x)", status);
}
EFI_LOADED_IMAGE_PROTOCOL *new_handle_loaded_image = NULL;
status = uefi_call_wrapper(gBS->HandleProtocol, 3,
new_handle, &loaded_img_prot_guid,
(void **)&new_handle_loaded_image);
status = gBS->HandleProtocol(new_handle, &loaded_img_prot_guid,
(void **)&new_handle_loaded_image);
if (status) {
panic("chainload: HandleProtocol failure (%x)", status);
}
@ -192,11 +189,9 @@ void chainload(char *config) {
UINTN exit_data_size = 0;
CHAR16 *exit_data = NULL;
EFI_STATUS exit_status = uefi_call_wrapper(gBS->StartImage, 3,
new_handle, &exit_data_size, &exit_data);
EFI_STATUS exit_status = gBS->StartImage(new_handle, &exit_data_size, &exit_data);
status = uefi_call_wrapper(gBS->Exit, 4,
efi_image_handle, exit_status, exit_data_size, exit_data);
status = gBS->Exit(efi_image_handle, exit_status, exit_data_size, exit_data);
if (status) {
panic("chainload: Exit failure (%x)", status);
}