我正在编写一个UEFI'chainloader'来了解它的工作原理。 我正在使用gnu-efi,并尝试加载和启动EFI图像。我希望我的main.efi加载并运行位于同一ESP中的hello.efi。我只是不明白该怎么称呼以及如何调用它。这是我的代码:
#include <efi.h> // EFI header
#include <efilib.h> // EFI library header
int DisableTimeout(EFI_SYSTEM_TABLE *SystemTable); // Allows us to call in efi_main
EFI_STATUS EFIAPI efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
InitializeLib(ImageHandle, SystemTable);
EFI_STATUS Status;
EFI_HANDLE ImageHandle2 = NULL;
const CHAR16 *FileName = L"HELLO.efi";
EFI_DEVICE_PATH_PROTOCOL *FilePath;
uefi_call_wrapper(SystemTable->ConOut->SetAttribute, 1, SystemTable->ConOut, 0x0F); // Set text to white
uefi_call_wrapper(SystemTable->ConOut->ClearScreen, 1, SystemTable->ConOut); // Clear screen
Print(L"Begin boot process.\nBooting from system with ");
Print(SystemTable->FirmwareVendor);
Print(L" firmware.\n");
Status = DisableTimeout(SystemTable); // Pass system table so it can shut off timer
Status = SystemTable->BootServices->LoadImage(TRUE, ImageHandle, FilePath, NULL, 0, &ImageHandle2);
Status = SystemTable->BootServices->StartImage(ImageHandle2, NULL, NULL);
Print(L"Boot complete.\n");
WaitForSingleEvent(SystemTable->ConIn->WaitForKey, 0); // Wait for keypress
return EFI_SUCCESS;
}
DisableTimeout()是我做的一个函数。
对不起,我对UEFI开发很新。