Reading EDID fails on OVMF
Posted: Fri Aug 13, 2021 10:41 am
Hello,
I am currently working on a display manager for my UEFI bootloader. The only problem is, HandleProtocol() for EDID keeps returning EFI_UNSUPPORTED! Here is the code for
Also, EDK2 is being used to build this
Thanks,
nexos
- Edit - I thought I knew C... The problem was that a continue statement should have been a break . I also cleaned up that loop, it had some very unnecessary stuff in it
I am currently working on a display manager for my UEFI bootloader. The only problem is, HandleProtocol() for EDID keeps returning EFI_UNSUPPORTED! Here is the code for
Code: Select all
// Initializes the boot graphics system
void screen_init()
{
EFI_GUID gopguid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
UINTN bufsize = 0;
EFI_HANDLE* handles = NULL;
// Obtain the size of the GOP handle list
EFI_STATUS status = gBS->LocateHandle(ByProtocol, &gopguid, NULL, &bufsize, handles);
// Status must equal EFI_BUFFER_TOO_SMALL
if(status != EFI_BUFFER_TOO_SMALL)
efi_panicearly(L"unable to locate GOP handle list\r\n");
// Allocate the buffer
handles = (EFI_HANDLE*)efi_alloc(bufsize);
if(!handles)
efi_panicearly(L"unable to allocate GOP handle list\r\n");
// Read in the handle list
status = gBS->LocateHandle(ByProtocol, &gopguid, NULL, &bufsize, handles);
if(EFI_ERROR(status))
efi_panicearly(L"unable to locate GOP handles list\r\n");
// Loop through every handle, attempting to open up GOP and EDID until we succeed
UINTN numhandles = bufsize / sizeof(EFI_HANDLE);
EFI_EDID_ACTIVE_PROTOCOL* edid = NULL;
for(int i = 0; i < numhandles; ++i)
{
// Obtain the current handle
EFI_HANDLE handle = handles[i];
// Attempt to open up the GOP on it. At the moment, we only use the first display
status = gBS->HandleProtocol(handle, &gopguid, (VOID**)&gop);
// Check if it worked
if(EFI_ERROR(status))
{
// No display is supported
if(i + 1 == numhandles)
break;
else
continue;
}
// Open up EDID now
EFI_GUID edidguid = EFI_EDID_ACTIVE_PROTOCOL_GUID;
status = gBS->HandleProtocol(handle, &edidguid, (VOID**)&edid);
if(EFI_ERROR(status))
{
if(i + 1 == numhandles)
efi_panicearly(L"could not find EDID\r\n");
}
}
}
Thanks,
nexos
- Edit - I thought I knew C... The problem was that a continue statement should have been a break . I also cleaned up that loop, it had some very unnecessary stuff in it