]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
Remove BdsLibConnectConsoleVariableWithoutDispatch() and enhance BdsLibConnectDeviceP...
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / GenericBdsLib / BdsConsole.c
index 1ded13637d3c608e8f613549c8a9665341456d47..84e4a0e6be2d9cc07e348414b826428d8de42db7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   BDS Lib functions which contain all the code to connect console device\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2013, 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
@@ -88,6 +88,7 @@ UpdateSystemTableConsole (
   EFI_DEVICE_PATH_PROTOCOL  *Instance;\r
   VOID                      *Interface;\r
   EFI_HANDLE                NewHandle;\r
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;\r
 \r
   ASSERT (VarName != NULL);\r
   ASSERT (ConsoleHandle != NULL);\r
@@ -159,6 +160,15 @@ UpdateSystemTableConsole (
         //\r
         *ConsoleHandle     = NewHandle;\r
         *ProtocolInterface = Interface;\r
+        if (CompareGuid (ConsoleGuid, &gEfiSimpleTextOutProtocolGuid)) {\r
+          //\r
+          // If it is console out device, set console mode 80x25 if current mode is invalid.\r
+          //\r
+          TextOut = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *) Interface;\r
+          if (TextOut->Mode->Mode == -1) {\r
+            TextOut->SetMode (TextOut, 0);\r
+          }\r
+        }\r
         return TRUE;\r
       }\r
     }\r
@@ -307,9 +317,12 @@ BdsLibUpdateConsoleVariable (
 \r
 /**\r
   Connect the console device base on the variable ConVarName, if\r
-  device path of the ConVarName is multi-instance device path, if\r
+  device path of the ConVarName is multi-instance device path and\r
   anyone of the instances is connected success, then this function\r
   will return success.\r
+  If the handle associate with one device path node can not\r
+  be created successfully, then still give chance to do the dispatch,\r
+  which load the missing drivers if possible..\r
 \r
   @param  ConVarName               Console related variable name, ConIn, ConOut,\r
                                    ErrOut.\r
@@ -386,6 +399,7 @@ BdsLibConnectConsoleVariable (
       // Connect the instance device path\r
       //\r
       Status = BdsLibConnectDevicePath (Instance);\r
+\r
       if (EFI_ERROR (Status)) {\r
         //\r
         // Delete the instance from the console varialbe\r
@@ -407,7 +421,6 @@ BdsLibConnectConsoleVariable (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
 /**\r
   This function will search every simpletext device in current system,\r
   and make every simpletext device as pertantial console device.\r
@@ -561,6 +574,75 @@ BdsLibConnectAllDefaultConsoles (
 \r
 }\r
 \r
+/**\r
+  This function will connect console device except ConIn base on the console\r
+  device variable  ConOut and ErrOut.\r
+\r
+  @retval EFI_SUCCESS              At least one of the ConOut device have\r
+                                   been connected success.\r
+  @retval EFI_STATUS               Return the status of BdsLibConnectConsoleVariable ().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+BdsLibConnectAllDefaultConsolesWithOutConIn (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  BOOLEAN                   SystemTableUpdated;\r
+\r
+  //\r
+  // Connect all default console variables except ConIn\r
+  //\r
+\r
+  //\r
+  // It seems impossible not to have any ConOut device on platform,\r
+  // so we check the status here.\r
+  //\r
+  Status = BdsLibConnectConsoleVariable (L"ConOut");\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Insert the performance probe for Console Out\r
+  //\r
+  PERF_START (NULL, "ConOut", "BDS", 1);\r
+  PERF_END (NULL, "ConOut", "BDS", 0);\r
+\r
+  //\r
+  // The _ModuleEntryPoint err out var is legal.\r
+  //\r
+  BdsLibConnectConsoleVariable (L"ErrOut");\r
+\r
+  SystemTableUpdated = FALSE;\r
+  //\r
+  // Fill console handles in System Table if no console device assignd.\r
+  //\r
+  if (UpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut)) {\r
+    SystemTableUpdated = TRUE;\r
+  }\r
+  if (UpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr)) {\r
+    SystemTableUpdated = TRUE;\r
+  }\r
+\r
+  if (SystemTableUpdated) {\r
+    //\r
+    // Update the CRC32 in the EFI System Table header\r
+    //\r
+    gST->Hdr.CRC32 = 0;\r
+    gBS->CalculateCrc32 (\r
+          (UINT8 *) &gST->Hdr,\r
+          gST->Hdr.HeaderSize,\r
+          &gST->Hdr.CRC32\r
+          );\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+\r
+}\r
+\r
 /**\r
   Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer\r
   is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt\r
@@ -669,7 +751,10 @@ ConvertBmpToGopBlt (
         ColorMapNum = 0;\r
         break;\r
       }\r
-    if (BmpHeader->ImageOffset - sizeof (BMP_IMAGE_HEADER) != sizeof (BMP_COLOR_MAP) * ColorMapNum) {\r
+    //\r
+    // BMP file may has padding data between the bmp header section and the bmp data section.\r
+    //\r
+    if (BmpHeader->ImageOffset - sizeof (BMP_IMAGE_HEADER) < sizeof (BMP_COLOR_MAP) * ColorMapNum) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   }\r