Last Updated: February 25, 2016
·
681
· daiakushi

Enumerate GOP Supported Modes

Select one of listed modes for your application.

#include <Uefi.h>
#include <Protocol/GraphicsOutput.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <stdio.h>

VOID DisplayModeInfo() {
    printf("[GOP] GOP ver.%X Mode Info :\n", Gop->Mode->Info->Version);
    printf("\tFrame Buffer Base: %08X\n", Gop->Mode->FrameBufferBase);
    printf("\tFrame Buffer Size: %08X\n", Gop->Mode->FrameBufferSize);
    printf("\tMax Mode: %08X\n", Gop->Mode->MaxMode);
    for (UINT32 i = 0; i < Gop->Mode->MaxMode; i++) {
        EFI_GRAPHICS_OUTPUT_MODE_INFORMATION    *info;
        UINTN                                   infoSize;
        Gop->QueryMode(Gop, i, &infoSize, &info);
        printf("\t\tMode: %X\n", i);
        printf("\t\tResolution: %dx%d\n", info->HorizontalResolution, info->VerticalResolution);
        printf("\t\tPixel Format: %X\n", info->PixelFormat);
        printf("\t\tPixel Information: %08X\n", info->PixelInformation);
        printf("\t\tPixels Per Scanline: %d\n", info->PixelsPerScanLine);
        FreePool(info);
    }
}

The stdio.h is from EADK.