aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-03-25 17:02:48 +0300
committerJoursoir <chat@joursoir.net>2022-03-25 17:02:48 +0300
commite425501ea7af0e2cf0397b46bf65f9275f2a5659 (patch)
tree7f952b2685061297fe9e693e2f3e0de496b87eee
parent135db17fb36f502f0f20d5675f4f1d6f41cda226 (diff)
downloadumt-e425501ea7af0e2cf0397b46bf65f9275f2a5659.tar.gz
umt-e425501ea7af0e2cf0397b46bf65f9275f2a5659.tar.bz2
umt-e425501ea7af0e2cf0397b46bf65f9275f2a5659.zip
main: locate graphics output protocol
-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;
}