]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c
MdeModulePkg: Removing ipf which is no longer supported from edk2.
[mirror_edk2.git] / MdeModulePkg / Universal / Console / GraphicsConsoleDxe / GraphicsConsole.c
index 212564a5c8cf553cb4072bec4a133aca08850bec..444773d089bfc30052cfb33df2f66ed88650a7e1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This is the main routine for initializing the Graphics Console support routines.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -57,7 +57,7 @@ GRAPHICS_CONSOLE_MODE_DATA mGraphicsConsoleModeData[] = {
 EFI_HII_DATABASE_PROTOCOL   *mHiiDatabase;\r
 EFI_HII_FONT_PROTOCOL       *mHiiFont;\r
 EFI_HII_HANDLE              mHiiHandle;\r
-EFI_EVENT                   mHiiRegistration;\r
+VOID                        *mHiiRegistration;\r
 \r
 EFI_GUID             mFontPackageListGuid = {0xf5f219d3, 0x7006, 0x4648, {0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad}};\r
 \r
@@ -245,8 +245,8 @@ InitializeGraphicsConsoleTextMode (
   UINTN                       ValidCount;\r
   UINTN                       ValidIndex;\r
   UINTN                       MaxColumns;\r
-  UINTN                       MaxRows;  \r
-  \r
+  UINTN                       MaxRows;\r
+\r
   if ((TextModeCount == NULL) || (TextModeData == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -287,7 +287,7 @@ InitializeGraphicsConsoleTextMode (
   //\r
   // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.\r
   //\r
-  ValidCount = 0;  \r
+  ValidCount = 0;\r
 \r
   NewModeBuffer[ValidCount].Columns       = 80;\r
   NewModeBuffer[ValidCount].Rows          = 25;\r
@@ -295,20 +295,20 @@ InitializeGraphicsConsoleTextMode (
   NewModeBuffer[ValidCount].GopHeight     = VerticalResolution;\r
   NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;\r
   NewModeBuffer[ValidCount].DeltaX        = (HorizontalResolution - (NewModeBuffer[ValidCount].Columns * EFI_GLYPH_WIDTH)) >> 1;\r
-  NewModeBuffer[ValidCount].DeltaY        = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1;      \r
+  NewModeBuffer[ValidCount].DeltaY        = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1;\r
   ValidCount++;\r
 \r
   if ((MaxColumns >= 80) && (MaxRows >= 50)) {\r
     NewModeBuffer[ValidCount].Columns = 80;\r
     NewModeBuffer[ValidCount].Rows    = 50;\r
     NewModeBuffer[ValidCount].DeltaX  = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1;\r
-    NewModeBuffer[ValidCount].DeltaY  = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1;    \r
+    NewModeBuffer[ValidCount].DeltaY  = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1;\r
   }\r
   NewModeBuffer[ValidCount].GopWidth      = HorizontalResolution;\r
   NewModeBuffer[ValidCount].GopHeight     = VerticalResolution;\r
   NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;\r
   ValidCount++;\r
-  \r
+\r
   //\r
   // Start from mode 2 to put the valid mode other than 80x25 and 80x50 in the output mode buffer.\r
   //\r
@@ -340,14 +340,14 @@ InitializeGraphicsConsoleTextMode (
       ValidCount++;\r
     }\r
   }\r
\r
+\r
   DEBUG_CODE (\r
     for (Index = 0; Index < ValidCount; Index++) {\r
-      DEBUG ((EFI_D_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n", \r
-                           Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));  \r
+      DEBUG ((EFI_D_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n",\r
+                           Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));\r
     }\r
   );\r
-  \r
+\r
   //\r
   // Return valid mode count and mode information buffer.\r
   //\r
@@ -388,9 +388,9 @@ GraphicsConsoleControllerDriverStart (
   UINTN                                MaxMode;\r
   UINT32                               ModeNumber;\r
   EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE    *Mode;\r
-  UINTN                                SizeOfInfo;  \r
+  UINTN                                SizeOfInfo;\r
   EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;\r
-  \r
+\r
   ModeNumber = 0;\r
 \r
   //\r
@@ -442,9 +442,9 @@ GraphicsConsoleControllerDriverStart (
     if ((HorizontalResolution == 0x0) || (VerticalResolution == 0x0)) {\r
       //\r
       // Find the highest resolution which GOP supports.\r
-      //    \r
+      //\r
       MaxMode = Private->GraphicsOutput->Mode->MaxMode;\r
-      \r
+\r
       for (ModeIndex = 0; ModeIndex < MaxMode; ModeIndex++) {\r
         Status = Private->GraphicsOutput->QueryMode (\r
                            Private->GraphicsOutput,\r
@@ -453,8 +453,8 @@ GraphicsConsoleControllerDriverStart (
                            &Info\r
                            );\r
         if (!EFI_ERROR (Status)) {\r
-          if ((Info->HorizontalResolution >= HorizontalResolution) &&\r
-              (Info->VerticalResolution >= VerticalResolution)) {\r
+          if ((Info->HorizontalResolution > HorizontalResolution) ||\r
+              ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution > VerticalResolution))) {\r
             HorizontalResolution = Info->HorizontalResolution;\r
             VerticalResolution   = Info->VerticalResolution;\r
             ModeNumber           = ModeIndex;\r
@@ -480,10 +480,12 @@ GraphicsConsoleControllerDriverStart (
         //\r
         // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec\r
         //\r
+        HorizontalResolution = 800;\r
+        VerticalResolution   = 600;\r
         Status = CheckModeSupported (\r
                      Private->GraphicsOutput,\r
-                     800,\r
-                     600,\r
+                     HorizontalResolution,\r
+                     VerticalResolution,\r
                      &ModeNumber\r
                      );\r
         Mode = Private->GraphicsOutput->Mode;\r
@@ -549,6 +551,8 @@ GraphicsConsoleControllerDriverStart (
     }\r
   }\r
 \r
+  DEBUG ((EFI_D_INFO, "GraphicsConsole video resolution %d x %d\n", HorizontalResolution, VerticalResolution));\r
+\r
   //\r
   // Initialize the mode which GraphicsConsole supports.\r
   //\r
@@ -577,7 +581,7 @@ GraphicsConsoleControllerDriverStart (
     Status = GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");\r
     if (EFI_ERROR (Status)) {\r
       goto Error;\r
-    }  \r
+    }\r
   DEBUG_CODE_END ();\r
 \r
   //\r
@@ -804,42 +808,14 @@ EfiLocateHiiProtocol (
   VOID\r
   )\r
 {\r
-  EFI_HANDLE  Handle;\r
-  UINTN       Size;\r
   EFI_STATUS  Status;\r
 \r
-  //\r
-  // There should only be one - so buffer size is this\r
-  //\r
-  Size = sizeof (EFI_HANDLE);\r
-\r
-  Status = gBS->LocateHandle (\r
-                  ByProtocol,\r
-                  &gEfiHiiDatabaseProtocolGuid,\r
-                  NULL,\r
-                  &Size,\r
-                  (VOID **) &Handle\r
-                  );\r
-\r
+  Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &mHiiDatabase);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiHiiDatabaseProtocolGuid,\r
-                  (VOID **) &mHiiDatabase\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiHiiFontProtocolGuid,\r
-                  (VOID **) &mHiiFont\r
-                  );\r
+  Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &mHiiFont);\r
   return Status;\r
 }\r
 \r
@@ -939,7 +915,7 @@ GraphicsConsoleConOutOutputString (
   }\r
 \r
   Status = EFI_SUCCESS;\r
-  \r
+\r
   OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
   //\r
   // Current mode\r
@@ -1329,7 +1305,7 @@ GraphicsConsoleConOutSetMode (
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
-  \r
+\r
   ModeData  = &(Private->ModeData[ModeNumber]);\r
 \r
   if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {\r
@@ -1467,7 +1443,7 @@ GraphicsConsoleConOutSetMode (
   This->Mode->CursorColumn  = 0;\r
   This->Mode->CursorRow     = 0;\r
 \r
-  FlushCursor (This);  \r
+  FlushCursor (This);\r
 \r
   Status = EFI_SUCCESS;\r
 \r
@@ -1502,14 +1478,7 @@ GraphicsConsoleConOutSetAttribute (
 {\r
   EFI_TPL               OldTpl;\r
 \r
-  if ((Attribute | 0xFF) != 0xFF) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  if (This->Mode->Mode == -1) {\r
-    //\r
-    // If current mode is not valid, return error.\r
-    //\r
+  if ((Attribute | 0x7F) != 0x7F) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -1558,7 +1527,7 @@ GraphicsConsoleConOutClearScreen (
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
   EFI_TPL                       OldTpl;\r
-  \r
+\r
   if (This->Mode->Mode == -1) {\r
     //\r
     // If current mode is not valid, return error.\r
@@ -1907,11 +1876,11 @@ DrawUnicodeWeightAtCursorN (
 \r
 /**\r
   Flush the cursor on the screen.\r
-  \r
+\r
   If CursorVisible is FALSE, nothing to do and return directly.\r
-  If CursorVisible is TRUE, \r
+  If CursorVisible is TRUE,\r
      i) If the cursor shows on screen, it will be erased.\r
-    ii) If the cursor does not show on screen, it will be shown. \r
+    ii) If the cursor does not show on screen, it will be shown.\r
 \r
   @param  This                  Protocol instance pointer.\r
 \r
@@ -2055,7 +2024,9 @@ RegisterFontPackage (
                   NULL,\r
                   (VOID **) &HiiDatabase\r
                   );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    return;\r
+  }\r
 \r
   //\r
   // Add 4 bytes to the header for entire length for HiiAddPackages use only.\r