]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/PlatformBootManagerLib: rebase boot logo display to BootLogoLib
authorLaszlo Ersek <lersek@redhat.com>
Wed, 25 May 2016 11:08:15 +0000 (13:08 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Mon, 6 Jun 2016 15:06:49 +0000 (17:06 +0200)
In the course of porting ArmVirtPkg to the MdeModulePkg BDS, commit
1f73aef50c5e

  ArmVirtPkg/PlatformBootManagerLib: add EnableQuietBoot & DisableQuietBoot

open-coded the EnableQuietBoot() function (and its dependencies / friends)
from IntelFrameworkModulePkg BDS.

This code duplication can be avoided; the functionality is available from
the following three libraries in MdeModulePkg:

- BootLogoLib: provides the BootLogoEnableLogo() function. It does not
  provide the internal ConvertBmpToGopBlt() function -- that one is
  delegated to ImageDecoderLib (function DecodeImage()).

- ImageDecoderLib: a general library that registers decoder plugins for
  specific image formats, and provides the generic DecodeImage() on top.

- BmpImageDecoderLib: one of said decoder plugins, for handling BMP images
  (which is the format of our logo).

In this patch, we revert 1f73aef50c5e, and atomically incorporate the
above libraries. This is inspired by Nt32Pkg commit 859e75c4fc42:

  Nt32Pkg: Use BootLogoLib for logo and progress bar drawing.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
ArmVirtPkg/ArmVirtQemu.dsc
ArmVirtPkg/ArmVirtQemuKernel.dsc
ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.h
ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
ArmVirtPkg/Library/PlatformBootManagerLib/QuietBoot.c [deleted file]

index cd4a50d5eaa3e0bd0e0594736a265bdf430bd2f9..32a5aa9774014bf81f37b963c2a9642343fc0ede 100644 (file)
@@ -60,6 +60,8 @@
 \r
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
   UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
 \r
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
   UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
+  BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf\r
+  ImageDecoderLib|MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf\r
   PlatformBootManagerLib|ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf\r
   CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
   QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf\r
   PlatformBootManagerLib|ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf\r
   CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
   QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
-  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|MdeModulePkg/Library/BmpImageDecoderLib/BmpImageDecoderLib.inf\r
+  }\r
   MdeModulePkg/Application/UiApp/UiApp.inf {\r
     <LibraryClasses>\r
       NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf\r
   MdeModulePkg/Application/UiApp/UiApp.inf {\r
     <LibraryClasses>\r
       NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf\r
index 9982dee9365d752ea3494158ffb3eebd03286eef..264bd445ea4e98e1996aae4eb0f25831b0119cb6 100644 (file)
@@ -59,6 +59,8 @@
 \r
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
   UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
 \r
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
   UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf\r
+  BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf\r
+  ImageDecoderLib|MdeModulePkg/Library/ImageDecoderLib/ImageDecoderLib.inf\r
   PlatformBootManagerLib|ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf\r
   CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
   QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf\r
   PlatformBootManagerLib|ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf\r
   CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
   QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf\r
-  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {\r
+    <LibraryClasses>\r
+      NULL|MdeModulePkg/Library/BmpImageDecoderLib/BmpImageDecoderLib.inf\r
+  }\r
   MdeModulePkg/Application/UiApp/UiApp.inf {\r
     <LibraryClasses>\r
       NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf\r
   MdeModulePkg/Application/UiApp/UiApp.inf {\r
     <LibraryClasses>\r
       NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf\r
index cc6d21e30007887a9747baae8f2468cd6a959504..b7e02f3d00f4070ac339c88e6480ee0448f5e2d3 100644 (file)
@@ -16,6 +16,7 @@
 **/\r
 \r
 #include <IndustryStandard/Pci22.h>\r
 **/\r
 \r
 #include <IndustryStandard/Pci22.h>\r
+#include <Library/BootLogoLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/QemuBootOrderLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/QemuBootOrderLib.h>\r
@@ -531,7 +532,13 @@ PlatformBootManagerAfterConsole (
   //\r
   // Show the splash screen.\r
   //\r
   //\r
   // Show the splash screen.\r
   //\r
-  EnableQuietBoot (PcdGetPtr (PcdLogoFile));\r
+  BootLogoEnableLogo (\r
+    ImageFormatBmp,                          // ImageFormat\r
+    PcdGetPtr (PcdLogoFile),                 // Logo\r
+    EdkiiPlatformLogoDisplayAttributeCenter, // Attribute\r
+    0,                                       // OffsetX\r
+    0                                        // OffsetY\r
+    );\r
 \r
   //\r
   // Connect the rest of the devices.\r
 \r
   //\r
   // Connect the rest of the devices.\r
index 22df65f73026b8942d6e26e42505a60215260053..df1519c24175e7f84c234b1eec444b561c377eee 100644 (file)
@@ -48,33 +48,4 @@ TryRunningQemuKernel (
   VOID\r
   );\r
 \r
   VOID\r
   );\r
 \r
-/**\r
-  Use SystemTable Conout to stop video based Simple Text Out consoles from\r
-  going to the video device. Put up LogoFile on every video device that is a\r
-  console.\r
-\r
-  @param[in]  LogoFile   File name of logo to display on the center of the\r
-                         screen.\r
-\r
-  @retval EFI_SUCCESS     ConsoleControl has been flipped to graphics and logo\r
-                          displayed.\r
-  @retval EFI_UNSUPPORTED Logo not found\r
-**/\r
-EFI_STATUS\r
-EnableQuietBoot (\r
-  IN  EFI_GUID  *LogoFile\r
-  );\r
-\r
-/**\r
-  Use SystemTable Conout to turn on video based Simple Text Out consoles. The\r
-  Simple Text Out screens will now be synced up with all non video output\r
-  devices\r
-\r
-  @retval EFI_SUCCESS     UGA devices are back in text mode and synced up.\r
-**/\r
-EFI_STATUS\r
-DisableQuietBoot (\r
-  VOID\r
-  );\r
-\r
 #endif // _PLATFORM_BM_H_\r
 #endif // _PLATFORM_BM_H_\r
index 2500ad9d68058da25666904a8d32c03228eb3b6d..9c95b69cc9740e05020d4cd5c1579c2eb0ac4e4b 100644 (file)
@@ -33,7 +33,6 @@
 [Sources]\r
   PlatformBm.c\r
   QemuKernel.c\r
 [Sources]\r
   PlatformBm.c\r
   QemuKernel.c\r
-  QuietBoot.c\r
 \r
 [Packages]\r
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
 \r
 [Packages]\r
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
@@ -45,9 +44,9 @@
 [LibraryClasses]\r
   BaseLib\r
   BaseMemoryLib\r
 [LibraryClasses]\r
   BaseLib\r
   BaseMemoryLib\r
+  BootLogoLib\r
   DebugLib\r
   DevicePathLib\r
   DebugLib\r
   DevicePathLib\r
-  DxeServicesLib\r
   MemoryAllocationLib\r
   PcdLib\r
   PrintLib\r
   MemoryAllocationLib\r
   PcdLib\r
   PrintLib\r
   UefiLib\r
   UefiRuntimeServicesTableLib\r
 \r
   UefiLib\r
   UefiRuntimeServicesTableLib\r
 \r
-[FeaturePcd]\r
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdBootlogoOnlyEnable\r
-  gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport\r
-\r
 [FixedPcd]\r
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile\r
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile\r
 [FixedPcd]\r
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile\r
   gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile\r
@@ -85,6 +80,5 @@
   gEfiDevicePathProtocolGuid\r
   gEfiGraphicsOutputProtocolGuid\r
   gEfiLoadedImageProtocolGuid\r
   gEfiDevicePathProtocolGuid\r
   gEfiGraphicsOutputProtocolGuid\r
   gEfiLoadedImageProtocolGuid\r
-  gEfiOEMBadgingProtocolGuid\r
   gEfiPciRootBridgeIoProtocolGuid\r
   gEfiSimpleFileSystemProtocolGuid\r
   gEfiPciRootBridgeIoProtocolGuid\r
   gEfiSimpleFileSystemProtocolGuid\r
diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/QuietBoot.c b/ArmVirtPkg/Library/PlatformBootManagerLib/QuietBoot.c
deleted file mode 100644 (file)
index 687bda0..0000000
+++ /dev/null
@@ -1,680 +0,0 @@
-/** @file\r
-  Platform BDS function for quiet boot support.\r
-\r
-Copyright (C) 2016, Red Hat, Inc.\r
-Copyright (c) 2004 - 2016, 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <IndustryStandard/Bmp.h>\r
-#include <Library/DxeServicesLib.h>\r
-#include <Protocol/BootLogo.h>\r
-#include <Protocol/OEMBadging.h>\r
-#include <Protocol/UgaDraw.h>\r
-\r
-#include "PlatformBm.h"\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
-  buffer is passed in it will be used if it is big enough.\r
-\r
-  @param  BmpImage      Pointer to BMP file\r
-  @param  BmpImageSize  Number of bytes in BmpImage\r
-  @param  GopBlt        Buffer containing GOP version of BmpImage.\r
-  @param  GopBltSize    Size of GopBlt in bytes.\r
-  @param  PixelHeight   Height of GopBlt/BmpImage in pixels\r
-  @param  PixelWidth    Width of GopBlt/BmpImage in pixels\r
-\r
-  @retval EFI_SUCCESS           GopBlt and GopBltSize are returned.\r
-  @retval EFI_UNSUPPORTED       BmpImage is not a valid *.BMP image\r
-  @retval EFI_BUFFER_TOO_SMALL  The passed in GopBlt buffer is not big enough.\r
-                                GopBltSize will contain the required size.\r
-  @retval EFI_OUT_OF_RESOURCES  No enough buffer to allocate.\r
-\r
-**/\r
-STATIC\r
-EFI_STATUS\r
-ConvertBmpToGopBlt (\r
-  IN     VOID      *BmpImage,\r
-  IN     UINTN     BmpImageSize,\r
-  IN OUT VOID      **GopBlt,\r
-  IN OUT UINTN     *GopBltSize,\r
-     OUT UINTN     *PixelHeight,\r
-     OUT UINTN     *PixelWidth\r
-  )\r
-{\r
-  UINT8                         *Image;\r
-  UINT8                         *ImageHeader;\r
-  BMP_IMAGE_HEADER              *BmpHeader;\r
-  BMP_COLOR_MAP                 *BmpColorMap;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
-  UINT64                        BltBufferSize;\r
-  UINTN                         Index;\r
-  UINTN                         Height;\r
-  UINTN                         Width;\r
-  UINTN                         ImageIndex;\r
-  UINT32                        DataSizePerLine;\r
-  BOOLEAN                       IsAllocated;\r
-  UINT32                        ColorMapNum;\r
-\r
-  if (sizeof (BMP_IMAGE_HEADER) > BmpImageSize) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;\r
-\r
-  if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Doesn't support compress.\r
-  //\r
-  if (BmpHeader->CompressionType != 0) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Only support BITMAPINFOHEADER format.\r
-  // BITMAPFILEHEADER + BITMAPINFOHEADER = BMP_IMAGE_HEADER\r
-  //\r
-  if (BmpHeader->HeaderSize != sizeof (BMP_IMAGE_HEADER) - OFFSET_OF(BMP_IMAGE_HEADER, HeaderSize)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // The data size in each line must be 4 byte alignment.\r
-  //\r
-  DataSizePerLine = ((BmpHeader->PixelWidth * BmpHeader->BitPerPixel + 31) >> 3) & (~0x3);\r
-  BltBufferSize = MultU64x32 (DataSizePerLine, BmpHeader->PixelHeight);\r
-  if (BltBufferSize > (UINT32) ~0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((BmpHeader->Size != BmpImageSize) ||\r
-      (BmpHeader->Size < BmpHeader->ImageOffset) ||\r
-      (BmpHeader->Size - BmpHeader->ImageOffset !=  BmpHeader->PixelHeight * DataSizePerLine)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Calculate Color Map offset in the image.\r
-  //\r
-  Image       = BmpImage;\r
-  BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));\r
-  if (BmpHeader->ImageOffset < sizeof (BMP_IMAGE_HEADER)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (BmpHeader->ImageOffset > sizeof (BMP_IMAGE_HEADER)) {\r
-    switch (BmpHeader->BitPerPixel) {\r
-      case 1:\r
-        ColorMapNum = 2;\r
-        break;\r
-      case 4:\r
-        ColorMapNum = 16;\r
-        break;\r
-      case 8:\r
-        ColorMapNum = 256;\r
-        break;\r
-      default:\r
-        ColorMapNum = 0;\r
-        break;\r
-      }\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
-\r
-  //\r
-  // Calculate graphics image data address in the image\r
-  //\r
-  Image         = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;\r
-  ImageHeader   = Image;\r
-\r
-  //\r
-  // Calculate the BltBuffer needed size.\r
-  //\r
-  BltBufferSize = MultU64x32 ((UINT64) BmpHeader->PixelWidth, BmpHeader->PixelHeight);\r
-  //\r
-  // Ensure the BltBufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow\r
-  //\r
-  if (BltBufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  BltBufferSize = MultU64x32 (BltBufferSize, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-\r
-  IsAllocated   = FALSE;\r
-  if (*GopBlt == NULL) {\r
-    //\r
-    // GopBlt is not allocated by caller.\r
-    //\r
-    *GopBltSize = (UINTN) BltBufferSize;\r
-    *GopBlt     = AllocatePool (*GopBltSize);\r
-    IsAllocated = TRUE;\r
-    if (*GopBlt == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-  } else {\r
-    //\r
-    // GopBlt has been allocated by caller.\r
-    //\r
-    if (*GopBltSize < (UINTN) BltBufferSize) {\r
-      *GopBltSize = (UINTN) BltBufferSize;\r
-      return EFI_BUFFER_TOO_SMALL;\r
-    }\r
-  }\r
-\r
-  *PixelWidth   = BmpHeader->PixelWidth;\r
-  *PixelHeight  = BmpHeader->PixelHeight;\r
-\r
-  //\r
-  // Convert image from BMP to Blt buffer format\r
-  //\r
-  BltBuffer = *GopBlt;\r
-  for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {\r
-    Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];\r
-    for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {\r
-      switch (BmpHeader->BitPerPixel) {\r
-      case 1:\r
-        //\r
-        // Convert 1-bit (2 colors) BMP to 24-bit color\r
-        //\r
-        for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {\r
-          Blt->Red    = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;\r
-          Blt->Green  = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;\r
-          Blt->Blue   = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;\r
-          Blt++;\r
-          Width++;\r
-        }\r
-\r
-        Blt--;\r
-        Width--;\r
-        break;\r
-\r
-      case 4:\r
-        //\r
-        // Convert 4-bit (16 colors) BMP Palette to 24-bit color\r
-        //\r
-        Index       = (*Image) >> 4;\r
-        Blt->Red    = BmpColorMap[Index].Red;\r
-        Blt->Green  = BmpColorMap[Index].Green;\r
-        Blt->Blue   = BmpColorMap[Index].Blue;\r
-        if (Width < (BmpHeader->PixelWidth - 1)) {\r
-          Blt++;\r
-          Width++;\r
-          Index       = (*Image) & 0x0f;\r
-          Blt->Red    = BmpColorMap[Index].Red;\r
-          Blt->Green  = BmpColorMap[Index].Green;\r
-          Blt->Blue   = BmpColorMap[Index].Blue;\r
-        }\r
-        break;\r
-\r
-      case 8:\r
-        //\r
-        // Convert 8-bit (256 colors) BMP Palette to 24-bit color\r
-        //\r
-        Blt->Red    = BmpColorMap[*Image].Red;\r
-        Blt->Green  = BmpColorMap[*Image].Green;\r
-        Blt->Blue   = BmpColorMap[*Image].Blue;\r
-        break;\r
-\r
-      case 24:\r
-        //\r
-        // It is 24-bit BMP.\r
-        //\r
-        Blt->Blue   = *Image++;\r
-        Blt->Green  = *Image++;\r
-        Blt->Red    = *Image;\r
-        break;\r
-\r
-      default:\r
-        //\r
-        // Other bit format BMP is not supported.\r
-        //\r
-        if (IsAllocated) {\r
-          FreePool (*GopBlt);\r
-          *GopBlt = NULL;\r
-        }\r
-        return EFI_UNSUPPORTED;\r
-      };\r
-\r
-    }\r
-\r
-    ImageIndex = (UINTN) (Image - ImageHeader);\r
-    if ((ImageIndex % 4) != 0) {\r
-      //\r
-      // Bmp Image starts each row on a 32-bit boundary!\r
-      //\r
-      Image = Image + (4 - (ImageIndex % 4));\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Use SystemTable Conout to stop video based Simple Text Out consoles from going\r
-  to the video device. Put up LogoFile on every video device that is a console.\r
-\r
-  @param[in]  LogoFile   File name of logo to display on the center of the screen.\r
-\r
-  @retval EFI_SUCCESS     ConsoleControl has been flipped to graphics and logo displayed.\r
-  @retval EFI_UNSUPPORTED Logo not found\r
-\r
-**/\r
-EFI_STATUS\r
-EnableQuietBoot (\r
-  IN  EFI_GUID  *LogoFile\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_OEM_BADGING_PROTOCOL      *Badging;\r
-  UINT32                        SizeOfX;\r
-  UINT32                        SizeOfY;\r
-  INTN                          DestX;\r
-  INTN                          DestY;\r
-  UINT8                         *ImageData;\r
-  UINTN                         ImageSize;\r
-  UINTN                         BltSize;\r
-  UINT32                        Instance;\r
-  EFI_BADGING_FORMAT            Format;\r
-  EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;\r
-  UINTN                         CoordinateX;\r
-  UINTN                         CoordinateY;\r
-  UINTN                         Height;\r
-  UINTN                         Width;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
-  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;\r
-  UINT32                        ColorDepth;\r
-  UINT32                        RefreshRate;\r
-  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;\r
-  EFI_BOOT_LOGO_PROTOCOL        *BootLogo;\r
-  UINTN                         NumberOfLogos;\r
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt;\r
-  UINTN                         LogoDestX;\r
-  UINTN                         LogoDestY;\r
-  UINTN                         LogoHeight;\r
-  UINTN                         LogoWidth;\r
-  UINTN                         NewDestX;\r
-  UINTN                         NewDestY;\r
-  UINTN                         NewHeight;\r
-  UINTN                         NewWidth;\r
-  UINT64                        BufferSize;\r
-\r
-  UgaDraw = NULL;\r
-  //\r
-  // Try to open GOP first\r
-  //\r
-  Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);\r
-  if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-    GraphicsOutput = NULL;\r
-    //\r
-    // Open GOP failed, try to open UGA\r
-    //\r
-    Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);\r
-  }\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  //\r
-  // Try to open Boot Logo Protocol.\r
-  //\r
-  BootLogo = NULL;\r
-  gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);\r
-\r
-  //\r
-  // Erase Cursor from screen\r
-  //\r
-  gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r
-\r
-  Badging = NULL;\r
-  Status  = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID **) &Badging);\r
-\r
-  if (GraphicsOutput != NULL) {\r
-    SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
-    SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
-\r
-  } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-    Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-  } else {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
-  Blt = NULL;\r
-  NumberOfLogos = 0;\r
-  LogoDestX = 0;\r
-  LogoDestY = 0;\r
-  LogoHeight = 0;\r
-  LogoWidth = 0;\r
-  NewDestX = 0;\r
-  NewDestY = 0;\r
-  NewHeight = 0;\r
-  NewWidth = 0;\r
-  Instance = 0;\r
-  Height = 0;\r
-  Width = 0;\r
-  while (1) {\r
-    ImageData = NULL;\r
-    ImageSize = 0;\r
-\r
-    if (Badging != NULL) {\r
-      //\r
-      // Get image from OEMBadging protocol.\r
-      //\r
-      Status = Badging->GetImage (\r
-                          Badging,\r
-                          &Instance,\r
-                          &Format,\r
-                          &ImageData,\r
-                          &ImageSize,\r
-                          &Attribute,\r
-                          &CoordinateX,\r
-                          &CoordinateY\r
-                          );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-\r
-      //\r
-      // Currently only support BMP format.\r
-      //\r
-      if (Format != EfiBadgingFormatBMP) {\r
-        if (ImageData != NULL) {\r
-          FreePool (ImageData);\r
-        }\r
-        continue;\r
-      }\r
-    } else {\r
-      //\r
-      // Get the specified image from FV.\r
-      //\r
-      Status = GetSectionFromAnyFv (LogoFile, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize);\r
-      if (EFI_ERROR (Status)) {\r
-        return EFI_UNSUPPORTED;\r
-      }\r
-\r
-      CoordinateX = 0;\r
-      CoordinateY = 0;\r
-      if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {\r
-        Attribute   = EfiBadgingDisplayAttributeCenter;\r
-      } else {\r
-        Attribute   = EfiBadgingDisplayAttributeCustomized;\r
-      }\r
-    }\r
-\r
-    if (Blt != NULL) {\r
-      FreePool (Blt);\r
-    }\r
-    Blt = NULL;\r
-    Status = ConvertBmpToGopBlt (\r
-              ImageData,\r
-              ImageSize,\r
-              (VOID **) &Blt,\r
-              &BltSize,\r
-              &Height,\r
-              &Width\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      FreePool (ImageData);\r
-\r
-      if (Badging == NULL) {\r
-        return Status;\r
-      } else {\r
-        continue;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Calculate the display position according to Attribute.\r
-    //\r
-    switch (Attribute) {\r
-    case EfiBadgingDisplayAttributeLeftTop:\r
-      DestX = CoordinateX;\r
-      DestY = CoordinateY;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenterTop:\r
-      DestX = (SizeOfX - Width) / 2;\r
-      DestY = CoordinateY;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeRightTop:\r
-      DestX = (SizeOfX - Width - CoordinateX);\r
-      DestY = CoordinateY;;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenterRight:\r
-      DestX = (SizeOfX - Width - CoordinateX);\r
-      DestY = (SizeOfY - Height) / 2;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeRightBottom:\r
-      DestX = (SizeOfX - Width - CoordinateX);\r
-      DestY = (SizeOfY - Height - CoordinateY);\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenterBottom:\r
-      DestX = (SizeOfX - Width) / 2;\r
-      DestY = (SizeOfY - Height - CoordinateY);\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeLeftBottom:\r
-      DestX = CoordinateX;\r
-      DestY = (SizeOfY - Height - CoordinateY);\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenterLeft:\r
-      DestX = CoordinateX;\r
-      DestY = (SizeOfY - Height) / 2;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCenter:\r
-      DestX = (SizeOfX - Width) / 2;\r
-      DestY = (SizeOfY - Height) / 2;\r
-      break;\r
-\r
-    case EfiBadgingDisplayAttributeCustomized:\r
-      DestX = (SizeOfX - Width) / 2;\r
-      DestY = ((SizeOfY * 382) / 1000) - Height / 2;\r
-      break;\r
-\r
-    default:\r
-      DestX = CoordinateX;\r
-      DestY = CoordinateY;\r
-      break;\r
-    }\r
-\r
-    if ((DestX >= 0) && (DestY >= 0)) {\r
-      if (GraphicsOutput != NULL) {\r
-        Status = GraphicsOutput->Blt (\r
-                            GraphicsOutput,\r
-                            Blt,\r
-                            EfiBltBufferToVideo,\r
-                            0,\r
-                            0,\r
-                            (UINTN) DestX,\r
-                            (UINTN) DestY,\r
-                            Width,\r
-                            Height,\r
-                            Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-                            );\r
-      } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-        Status = UgaDraw->Blt (\r
-                            UgaDraw,\r
-                            (EFI_UGA_PIXEL *) Blt,\r
-                            EfiUgaBltBufferToVideo,\r
-                            0,\r
-                            0,\r
-                            (UINTN) DestX,\r
-                            (UINTN) DestY,\r
-                            Width,\r
-                            Height,\r
-                            Width * sizeof (EFI_UGA_PIXEL)\r
-                            );\r
-      } else {\r
-        Status = EFI_UNSUPPORTED;\r
-      }\r
-\r
-      //\r
-      // Report displayed Logo information.\r
-      //\r
-      if (!EFI_ERROR (Status)) {\r
-        NumberOfLogos++;\r
-\r
-        if (LogoWidth == 0) {\r
-          //\r
-          // The first Logo.\r
-          //\r
-          LogoDestX = (UINTN) DestX;\r
-          LogoDestY = (UINTN) DestY;\r
-          LogoWidth = Width;\r
-          LogoHeight = Height;\r
-        } else {\r
-          //\r
-          // Merge new logo with old one.\r
-          //\r
-          NewDestX = MIN ((UINTN) DestX, LogoDestX);\r
-          NewDestY = MIN ((UINTN) DestY, LogoDestY);\r
-          NewWidth = MAX ((UINTN) DestX + Width, LogoDestX + LogoWidth) - NewDestX;\r
-          NewHeight = MAX ((UINTN) DestY + Height, LogoDestY + LogoHeight) - NewDestY;\r
-\r
-          LogoDestX = NewDestX;\r
-          LogoDestY = NewDestY;\r
-          LogoWidth = NewWidth;\r
-          LogoHeight = NewHeight;\r
-        }\r
-      }\r
-    }\r
-\r
-    FreePool (ImageData);\r
-\r
-    if (Badging == NULL) {\r
-      break;\r
-    }\r
-  }\r
-\r
-Done:\r
-  if (BootLogo == NULL || NumberOfLogos == 0) {\r
-    //\r
-    // No logo displayed.\r
-    //\r
-    if (Blt != NULL) {\r
-      FreePool (Blt);\r
-    }\r
-\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  // Advertise displayed Logo information.\r
-  //\r
-  if (NumberOfLogos == 1) {\r
-    //\r
-    // Only one logo displayed, use its Blt buffer directly for BootLogo protocol.\r
-    //\r
-    LogoBlt = Blt;\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    //\r
-    // More than one Logo displayed, get merged BltBuffer using VideoToBuffer operation.\r
-    //\r
-    if (Blt != NULL) {\r
-      FreePool (Blt);\r
-    }\r
-\r
-    //\r
-    // Ensure the LogoHeight * LogoWidth doesn't overflow\r
-    //\r
-    if (LogoHeight > DivU64x64Remainder ((UINTN) ~0, LogoWidth, NULL)) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-    BufferSize = MultU64x64 (LogoWidth, LogoHeight);\r
-\r
-    //\r
-    // Ensure the BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow\r
-    //\r
-    if (BufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {\r
-      return EFI_UNSUPPORTED;\r
-    }\r
-\r
-    LogoBlt = AllocateZeroPool ((UINTN)BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
-    if (LogoBlt == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    if (GraphicsOutput != NULL) {\r
-      Status = GraphicsOutput->Blt (\r
-                          GraphicsOutput,\r
-                          LogoBlt,\r
-                          EfiBltVideoToBltBuffer,\r
-                          LogoDestX,\r
-                          LogoDestY,\r
-                          0,\r
-                          0,\r
-                          LogoWidth,\r
-                          LogoHeight,\r
-                          LogoWidth * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)\r
-                          );\r
-    } else if (UgaDraw != NULL && FeaturePcdGet (PcdUgaConsumeSupport)) {\r
-      Status = UgaDraw->Blt (\r
-                          UgaDraw,\r
-                          (EFI_UGA_PIXEL *) LogoBlt,\r
-                          EfiUgaVideoToBltBuffer,\r
-                          LogoDestX,\r
-                          LogoDestY,\r
-                          0,\r
-                          0,\r
-                          LogoWidth,\r
-                          LogoHeight,\r
-                          LogoWidth * sizeof (EFI_UGA_PIXEL)\r
-                          );\r
-    } else {\r
-      Status = EFI_UNSUPPORTED;\r
-    }\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    BootLogo->SetBootLogo (BootLogo, LogoBlt, LogoDestX, LogoDestY, LogoWidth, LogoHeight);\r
-  }\r
-  FreePool (LogoBlt);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Use SystemTable Conout to turn on video based Simple Text Out consoles. The\r
-  Simple Text Out screens will now be synced up with all non video output devices\r
-\r
-  @retval EFI_SUCCESS     UGA devices are back in text mode and synced up.\r
-\r
-**/\r
-EFI_STATUS\r
-DisableQuietBoot (\r
-  VOID\r
-  )\r
-{\r
-\r
-  //\r
-  // Enable Cursor on Screen\r
-  //\r
-  gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
-  return EFI_SUCCESS;\r
-}\r
-\r