0

我正在使用 GNUEFI 开发操作系统,

我正在尝试按照Fmurphy 的 ShowEdid从 UEFI 协议中获取 EDID 。

但是在编写完所有代码后,我得到了 output Cannot Locate an Edid,因为我尝试了很多次,但这不是固定的。

我怎样才能解决这个问题?

这是我获取 EDID 的主要代码:

EFI_GUID gEfiEdidDiscoveredProtocolGuid = EFI_EDID_DISCOVERED_PROTOCOL_GUID;
    EFI_EDID_DISCOVERED_PROTOCOL *Edp;
    EFI_HANDLE *HandleBuffer;
    EFI_STATUS Status = EFI_SUCCESS;
    BOOLEAN Found = FALSE;
    BOOLEAN HexDump = FALSE;
    UINTN HandleCount = 0;

    // Try to Locate GOP by Handle
    Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiGraphicsOutputProtocolGuid, NULL, &HandleCount, &HandleBuffer);

    if(EFI_ERROR(Status))
    {
        Print(L"ERROR : No GOP Handle Found. Could Not Locate ann EDID.\n");
        return Status;
    }

    // I am Getting HandleCount = 2;

    for (UINT8 i = 0; i < HandleCount; i++)
    {
        Status = gBS->OpenProtocol(HandleBuffer[i], &gEfiEdidDiscoveredProtocolGuid, (VOID **)&Edp, gImageHandle, NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
        if(Status == EFI_SUCCESS)
        {
            Print(L"Status Success\n");
            if(!CheckForValidEdid((EDID_DATA_BLOCK *)(Edp->Edid)))
            {
                Found = TRUE;
                if(HexDump)
                {
                    DumpEdid((UINT8 *)(Edp->Edid), (int)sizeof(EDID_DATA_BLOCK));
                }
                else
                {
                    PrintEdid((EDID_DATA_BLOCK *)(Edp->Edid));
                }
            }
            else
            {
                Print(L"Error : Invalid EDID Checksum.\n");
            }
        }
        else
        {
            Print(L"Status Failed : %s\n", HandleBuffer[i]);
        }
    }

    if(!Found) {
        Print(L"Cannot Locate an EDID : %d\n", HandleCount);
    }
4

0 回答 0