Greetings, OSDev.org!
How do I get the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL for the boot partition? I tried getting it from EFI_LOADED_IMAGE->DeviceHandle, but it only supports EFI_DEVICE_PATH_PROTOCOL, EFI_FIRMWARE_VOLUME2_PROTOCOL and EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL.
Thanks in advance.
How do I find the boot volume with UEFI?
How do I find the boot volume with UEFI?
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
Re: How do I find the boot volume with UEFI?
Hmm, what firmware are you on? OVMF supports what you're trying to do, at least when using HandleProtocol: https://github.com/rpjohnst/kernel/blob ... .c#L27-L33
Re: How do I find the boot volume with UEFI?
Pretty odd, because the following prints "fail" for me:Rusky wrote:Hmm, what firmware are you on? OVMF supports what you're trying to do, at least when using HandleProtocol: https://github.com/rpjohnst/kernel/blob ... .c#L27-L33
Code: Select all
EFIAPI
EFI_STATUS Main(
EFI_HANDLE imageHandle,
EFI_SYSTEM_TABLE *systemTable
) {
void InitSystem(
EFI_HANDLE imageHandle,
EFI_SYSTEM_TABLE *systemTable
);
InitSystem(imageHandle, systemTable);
EFI_GUID loadedImageProtoId = EFI_LOADED_IMAGE_PROTOCOL_GUID;
EFI_LOADED_IMAGE *loadedImage;
systemTable->BootServices->LocateProtocol(
&loadedImageProtoId,
NULL,
(void **)&loadedImage
);
EFI_GUID fsProtoId = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs;
if (systemTable->BootServices->HandleProtocol(
loadedImage->ParentHandle,
&fsProtoId,
(void **)&fs
) != EFI_SUCCESS) {
puts(L"fail\n\r");
} else {
puts(L"ok\n\r");
};
puts(L"Finish.\n\r");
for (;;);
}
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay
Re: How do I find the boot volume with UEFI?
Thanks for the example! Changing LocateProtocol to HandleProtocol fixed the problem!
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
- Alan Kay