4 extern EFI_GUID GraphicsOutputProtocol;
6 static int memcmp(const void *s1, const void *s2, UINTN n)
8 const unsigned char *c1 = s1, *c2 = s2;
19 d = (int)*c1++ - (int)*c2++;
27 print_modes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
32 imax = gop->Mode->MaxMode;
34 Print(L"GOP reports MaxMode %d\n", imax);
35 for (i = 0; i < imax; i++) {
36 EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
38 rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo,
40 if (EFI_ERROR(rc) && rc == EFI_NOT_STARTED) {
41 rc = uefi_call_wrapper(gop->SetMode, 2, gop,
43 rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i,
49 StatusToString(Buffer, rc);
50 Print(L"%d: Bad response from QueryMode: %s (%d)\n",
54 Print(L"%c%d: %dx%d ", memcmp(info,gop->Mode->Info,sizeof(*info)) == 0 ? '*' : ' ', i,
55 info->HorizontalResolution,
56 info->VerticalResolution);
57 switch(info->PixelFormat) {
58 case PixelRedGreenBlueReserved8BitPerColor:
61 case PixelBlueGreenRedReserved8BitPerColor:
65 Print(L"R:%08x G:%08x B:%08x X:%08x",
66 info->PixelInformation.RedMask,
67 info->PixelInformation.GreenMask,
68 info->PixelInformation.BlueMask,
69 info->PixelInformation.ReservedMask);
75 Print(L"(Invalid pixel format)");
78 Print(L" pitch %d\n", info->PixelsPerScanLine);
83 SetWatchdog(UINTN seconds)
86 rc = uefi_call_wrapper(BS->SetWatchdogTimer, 4, seconds, 0x1ffff,
90 StatusToString(Buffer, rc);
91 Print(L"Bad response from QueryMode: %s (%d)\n", Buffer, rc);
97 efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
100 EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;
102 InitializeLib(image_handle, systab);
106 rc = LibLocateProtocol(&GraphicsOutputProtocol, (void **)&gop);