aboutsummaryrefslogtreecommitdiffstats
path: root/UefiMonitorTest
diff options
context:
space:
mode:
Diffstat (limited to 'UefiMonitorTest')
-rw-r--r--UefiMonitorTest/UefiMonitorTest.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/UefiMonitorTest/UefiMonitorTest.c b/UefiMonitorTest/UefiMonitorTest.c
index f7c9f04..7cdff88 100644
--- a/UefiMonitorTest/UefiMonitorTest.c
+++ b/UefiMonitorTest/UefiMonitorTest.c
@@ -10,6 +10,45 @@
#include <Protocol/GraphicsOutput.h>
+STATIC
+EFI_GRAPHICS_OUTPUT_PROTOCOL *
+GetGraphicsOutputProtocol (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeInfo;
+ UINTN SizeOfInfo;
+
+ Status = gBS->LocateProtocol (
+ &gEfiGraphicsOutputProtocolGuid,
+ NULL,
+ (VOID **)&Gop
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Unable to locate GOP\n"));
+ return NULL;
+ }
+
+ Status = Gop->QueryMode (
+ Gop,
+ (Gop->Mode == NULL) ? 0 : Gop->Mode->Mode,
+ &SizeOfInfo,
+ &ModeInfo
+ );
+ if (Status == EFI_NOT_STARTED) {
+ Status = Gop->SetMode (Gop, 0);
+ }
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Unable to get native mode\n"));
+ return NULL;
+ }
+
+ // TODO: free ModeInfo
+ return Gop;
+}
+
EFI_STATUS
EFIAPI
UefiMain (
@@ -17,5 +56,13 @@ UefiMain (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
+
+ Gop = GetGraphicsOutputProtocol ();
+ if (Gop == NULL) {
+ Print (L"Error: Getting a Graphical Output Protocol is failed\n");
+ return EFI_NOT_FOUND;
+ }
+
return EFI_SUCCESS;
}