]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Removed SetMode in GraphicsConsole Start() in release BIOS to improve performance...
authorli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 7 Aug 2012 09:32:46 +0000 (09:32 +0000)
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 7 Aug 2012 09:32:46 +0000 (09:32 +0000)
Signed-off-by: Li Elvin <elvin.li@intel.com>
Reviewed-by: Ni Ruiyu <ruiyu.ni@intel.com>, Tian Hot (hot.tian@intel.com)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13599 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c

index 117569fa624aa6e333ef02c2b208e3ea6142d6f7..7167033841054962c0f1b7146bb9c4629f333330 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 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, 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
@@ -35,7 +35,7 @@ GRAPHICS_CONSOLE_DEV    mGraphicsConsoleDevTemplate = {
   },\r
   {\r
     0,\r
-    0,\r
+    -1,\r
     EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK),\r
     0,\r
     0,\r
@@ -559,16 +559,15 @@ GraphicsConsoleControllerDriverStart (
   //\r
   Private->SimpleTextOutputMode.MaxMode = (INT32) MaxMode;\r
 \r
-  //\r
-  // Determine the number of text modes that this protocol can support\r
-  //\r
-  Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Error;\r
-  }\r
-\r
   DEBUG_CODE_BEGIN ();\r
-    GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");\r
+    Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0);\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error;\r
+    }\r
+    Status = GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r");\r
+    if (EFI_ERROR (Status)) {\r
+      goto Error;\r
+    }  \r
   DEBUG_CODE_END ();\r
 \r
   //\r
@@ -863,8 +862,13 @@ GraphicsConsoleConOutReset (
   IN  BOOLEAN                          ExtendedVerification\r
   )\r
 {\r
-  This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r
-  return This->SetMode (This, 0);\r
+  EFI_STATUS    Status;\r
+  Status = This->SetMode (This, 0);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  Status = This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));\r
+  return Status;\r
 }\r
 \r
 \r
@@ -917,8 +921,15 @@ GraphicsConsoleConOutOutputString (
   INT32                 OriginAttribute;\r
   EFI_TPL               OldTpl;\r
 \r
-  Status = EFI_SUCCESS;\r
+  if (This->Mode->Mode == -1) {\r
+    //\r
+    // If current mode is not valid, return error.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
 \r
+  Status = EFI_SUCCESS;\r
+  \r
   OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
   //\r
   // Current mode\r
@@ -1300,7 +1311,6 @@ GraphicsConsoleConOutSetMode (
   Private   = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);\r
   GraphicsOutput = Private->GraphicsOutput;\r
   UgaDraw   = Private->UgaDraw;\r
-  ModeData  = &(Private->ModeData[ModeNumber]);\r
 \r
   //\r
   // Make sure the requested mode number is supported\r
@@ -1309,38 +1319,26 @@ GraphicsConsoleConOutSetMode (
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
+  \r
+  ModeData  = &(Private->ModeData[ModeNumber]);\r
 \r
   if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
-  //\r
-  // Attempt to allocate a line buffer for the requested mode number\r
-  //\r
-  NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT);\r
 \r
-  if (NewLineBuffer == NULL) {\r
-    //\r
-    // The new line buffer could not be allocated, so return an error.\r
-    // No changes to the state of the current console have been made, so the current console is still valid\r
-    //\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Done;\r
-  }\r
   //\r
   // If the mode has been set at least one other time, then LineBuffer will not be NULL\r
   //\r
   if (Private->LineBuffer != NULL) {\r
-    //\r
-    // Clear the current text window on the current graphics console\r
-    //\r
-    This->ClearScreen (This);\r
-\r
     //\r
     // If the new mode is the same as the old mode, then just return EFI_SUCCESS\r
     //\r
     if ((INT32) ModeNumber == This->Mode->Mode) {\r
-      FreePool (NewLineBuffer);\r
+      //\r
+      // Clear the current text window on the current graphics console\r
+      //\r
+      This->ClearScreen (This);\r
       Status = EFI_SUCCESS;\r
       goto Done;\r
     }\r
@@ -1352,6 +1350,21 @@ GraphicsConsoleConOutSetMode (
 \r
     FreePool (Private->LineBuffer);\r
   }\r
+\r
+  //\r
+  // Attempt to allocate a line buffer for the requested mode number\r
+  //\r
+  NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT);\r
+\r
+  if (NewLineBuffer == NULL) {\r
+    //\r
+    // The new line buffer could not be allocated, so return an error.\r
+    // No changes to the state of the current console have been made, so the current console is still valid\r
+    //\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Done;\r
+  }\r
+\r
   //\r
   // Assign the current line buffer to the newly allocated line buffer\r
   //\r
@@ -1483,6 +1496,13 @@ GraphicsConsoleConOutSetAttribute (
     return EFI_UNSUPPORTED;\r
   }\r
 \r
+  if (This->Mode->Mode == -1) {\r
+    //\r
+    // If current mode is not valid, return error.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   if ((INT32) Attribute == This->Mode->Attribute) {\r
     return EFI_SUCCESS;\r
   }\r
@@ -1528,6 +1548,13 @@ GraphicsConsoleConOutClearScreen (
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;\r
   EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
   EFI_TPL                       OldTpl;\r
+  \r
+  if (This->Mode->Mode == -1) {\r
+    //\r
+    // If current mode is not valid, return error.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
 \r
   OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
 \r
@@ -1610,6 +1637,13 @@ GraphicsConsoleConOutSetCursorPosition (
   EFI_STATUS                  Status;\r
   EFI_TPL                     OldTpl;\r
 \r
+  if (This->Mode->Mode == -1) {\r
+    //\r
+    // If current mode is not valid, return error.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   Status = EFI_SUCCESS;\r
 \r
   OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
@@ -1651,6 +1685,8 @@ Done:
                                 the cursor is set to be invisible.\r
 \r
   @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_UNSUPPORTED       The output device's mode is not currently in a\r
+                                defined text mode.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1662,6 +1698,13 @@ GraphicsConsoleConOutEnableCursor (
 {\r
   EFI_TPL               OldTpl;\r
 \r
+  if (This->Mode->Mode == -1) {\r
+    //\r
+    // If current mode is not valid, return error.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   OldTpl = gBS->RaiseTPL (TPL_NOTIFY);\r
 \r
   FlushCursor (This);\r