From nobody Mon Dec 23 14:52:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518044317978854.1563064142182; Wed, 7 Feb 2018 14:58:37 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3544121F0DA4A; Wed, 7 Feb 2018 14:52:47 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2AF04222DE132 for ; Wed, 7 Feb 2018 14:52:44 -0800 (PST) Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2018 14:58:28 -0800 Received: from mdkinney-mobl2.amr.corp.intel.com ([10.241.98.55]) by fmsmga007.fm.intel.com with ESMTP; 07 Feb 2018 14:58:28 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,473,1511856000"; d="scan'208";a="16135179" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:16 -0800 Message-Id: <20180207225822.28876-5-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20180207225822.28876-1-michael.d.kinney@intel.com> References: <20180207225822.28876-1-michael.d.kinney@intel.com> Subject: [edk2] [Patch 04/10] IntelFrameworkModulePkg/GenericBdsLib: Use BmpSupportLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael D Kinney , Jiewen Yao , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Michael D Kinney https://bugzilla.tianocore.org/show_bug.cgi?id=3D800 Based on content from the following branch/commits: https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2= e60302b2d https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135= 098f53d61 https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111= f016dbd9b Update GenericBdsLib to use BmpSupportLib to convert a BMP graphics image to a GOP BLT Buffer to display the boot logo. Cc: Sean Brogan Cc: Jiewen Yao Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- .../IntelFrameworkModulePkg.dsc | 4 +- .../Library/GenericBdsLib/BdsConsole.c | 250 +----------------= ---- .../Library/GenericBdsLib/GenericBdsLib.inf | 3 +- .../Library/GenericBdsLib/InternalBdsLib.h | 3 +- 4 files changed, 10 insertions(+), 250 deletions(-) diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc b/IntelFra= meworkModulePkg/IntelFrameworkModulePkg.dsc index a9a01aa647..6c6c3d802a 100644 --- a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc +++ b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc @@ -3,7 +3,7 @@ # # This file is used to build all modules in IntelFrameworkModulePkg. # -#Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+#Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
#This program and the accompanying materials are licensed and made availab= le under=20 #the terms and conditions of the BSD License that accompanies this distrib= ution. =20 #The full text of the license may be found at @@ -54,6 +54,8 @@ SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull= .inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLi= b.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServic= esLib.inf HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf PlatformBdsLib|IntelFrameworkModulePkg/Library/PlatformBdsLibNull/Platfo= rmBdsLibNull.inf diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c b/I= ntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c index 8f273ff1b1..9c21cfcd59 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c @@ -1,7 +1,7 @@ /** @file BDS Lib functions which contain all the code to connect console device =20 -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER= EXPRESS OR IMPLIED. **/ =20 #include "InternalBdsLib.h" -#include =20 =20 /** @@ -642,249 +641,6 @@ BdsLibConnectAllDefaultConsolesWithOutConIn ( =20 } =20 -/** - Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer - is passed in a GopBlt buffer will be allocated by this routine. If a Gop= Blt - buffer is passed in it will be used if it is big enough. - - @param BmpImage Pointer to BMP file - @param BmpImageSize Number of bytes in BmpImage - @param GopBlt Buffer containing GOP version of BmpImage. - @param GopBltSize Size of GopBlt in bytes. - @param PixelHeight Height of GopBlt/BmpImage in pixels - @param PixelWidth Width of GopBlt/BmpImage in pixels - - @retval EFI_SUCCESS GopBlt and GopBltSize are returned. - @retval EFI_UNSUPPORTED BmpImage is not a valid *.BMP image - @retval EFI_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big eno= ugh. - GopBltSize will contain the required size. - @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate. - -**/ -EFI_STATUS -ConvertBmpToGopBlt ( - IN VOID *BmpImage, - IN UINTN BmpImageSize, - IN OUT VOID **GopBlt, - IN OUT UINTN *GopBltSize, - OUT UINTN *PixelHeight, - OUT UINTN *PixelWidth - ) -{ - UINT8 *Image; - UINT8 *ImageHeader; - BMP_IMAGE_HEADER *BmpHeader; - BMP_COLOR_MAP *BmpColorMap; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; - UINT64 BltBufferSize; - UINTN Index; - UINTN Height; - UINTN Width; - UINTN ImageIndex; - UINT32 DataSizePerLine; - BOOLEAN IsAllocated; - UINT32 ColorMapNum; - - if (sizeof (BMP_IMAGE_HEADER) > BmpImageSize) { - return EFI_INVALID_PARAMETER; - } - - BmpHeader =3D (BMP_IMAGE_HEADER *) BmpImage; - - if (BmpHeader->CharB !=3D 'B' || BmpHeader->CharM !=3D 'M') { - return EFI_UNSUPPORTED; - } - - // - // Doesn't support compress. - // - if (BmpHeader->CompressionType !=3D 0) { - return EFI_UNSUPPORTED; - } - - // - // Only support BITMAPINFOHEADER format. - // BITMAPFILEHEADER + BITMAPINFOHEADER =3D BMP_IMAGE_HEADER - // - if (BmpHeader->HeaderSize !=3D sizeof (BMP_IMAGE_HEADER) - OFFSET_OF(BMP= _IMAGE_HEADER, HeaderSize)) { - return EFI_UNSUPPORTED; - } - - // - // The data size in each line must be 4 byte alignment. - // - DataSizePerLine =3D ((BmpHeader->PixelWidth * BmpHeader->BitPerPixel + 3= 1) >> 3) & (~0x3); - BltBufferSize =3D MultU64x32 (DataSizePerLine, BmpHeader->PixelHeight); - if (BltBufferSize > (UINT32) ~0) { - return EFI_INVALID_PARAMETER; - } - - if ((BmpHeader->Size !=3D BmpImageSize) ||=20 - (BmpHeader->Size < BmpHeader->ImageOffset) || - (BmpHeader->Size - BmpHeader->ImageOffset !=3D BmpHeader->PixelHeig= ht * DataSizePerLine)) { - return EFI_INVALID_PARAMETER; - } - - // - // Calculate Color Map offset in the image. - // - Image =3D BmpImage; - BmpColorMap =3D (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER)); - if (BmpHeader->ImageOffset < sizeof (BMP_IMAGE_HEADER)) { - return EFI_INVALID_PARAMETER; - } - - if (BmpHeader->ImageOffset > sizeof (BMP_IMAGE_HEADER)) { - switch (BmpHeader->BitPerPixel) { - case 1: - ColorMapNum =3D 2; - break; - case 4: - ColorMapNum =3D 16; - break; - case 8: - ColorMapNum =3D 256; - break; - default: - ColorMapNum =3D 0; - break; - } - // - // BMP file may has padding data between the bmp header section and th= e bmp data section. - // - if (BmpHeader->ImageOffset - sizeof (BMP_IMAGE_HEADER) < sizeof (BMP_C= OLOR_MAP) * ColorMapNum) { - return EFI_INVALID_PARAMETER; - } - } - - // - // Calculate graphics image data address in the image - // - Image =3D ((UINT8 *) BmpImage) + BmpHeader->ImageOffset; - ImageHeader =3D Image; - - // - // Calculate the BltBuffer needed size. - // - BltBufferSize =3D MultU64x32 ((UINT64) BmpHeader->PixelWidth, BmpHeader-= >PixelHeight); - // - // Ensure the BltBufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doe= sn't overflow - // - if (BltBufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_B= LT_PIXEL))) { - return EFI_UNSUPPORTED; - } - BltBufferSize =3D MultU64x32 (BltBufferSize, sizeof (EFI_GRAPHICS_OUTPUT= _BLT_PIXEL)); - - IsAllocated =3D FALSE; - if (*GopBlt =3D=3D NULL) { - // - // GopBlt is not allocated by caller. - // - *GopBltSize =3D (UINTN) BltBufferSize; - *GopBlt =3D AllocatePool (*GopBltSize); - IsAllocated =3D TRUE; - if (*GopBlt =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - } else { - // - // GopBlt has been allocated by caller. - // - if (*GopBltSize < (UINTN) BltBufferSize) { - *GopBltSize =3D (UINTN) BltBufferSize; - return EFI_BUFFER_TOO_SMALL; - } - } - - *PixelWidth =3D BmpHeader->PixelWidth; - *PixelHeight =3D BmpHeader->PixelHeight; - - // - // Convert image from BMP to Blt buffer format - // - BltBuffer =3D *GopBlt; - for (Height =3D 0; Height < BmpHeader->PixelHeight; Height++) { - Blt =3D &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->= PixelWidth]; - for (Width =3D 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt= ++) { - switch (BmpHeader->BitPerPixel) { - case 1: - // - // Convert 1-bit (2 colors) BMP to 24-bit color - // - for (Index =3D 0; Index < 8 && Width < BmpHeader->PixelWidth; Inde= x++) { - Blt->Red =3D BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red; - Blt->Green =3D BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Gre= en; - Blt->Blue =3D BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blu= e; - Blt++; - Width++; - } - - Blt--; - Width--; - break; - - case 4: - // - // Convert 4-bit (16 colors) BMP Palette to 24-bit color - // - Index =3D (*Image) >> 4; - Blt->Red =3D BmpColorMap[Index].Red; - Blt->Green =3D BmpColorMap[Index].Green; - Blt->Blue =3D BmpColorMap[Index].Blue; - if (Width < (BmpHeader->PixelWidth - 1)) { - Blt++; - Width++; - Index =3D (*Image) & 0x0f; - Blt->Red =3D BmpColorMap[Index].Red; - Blt->Green =3D BmpColorMap[Index].Green; - Blt->Blue =3D BmpColorMap[Index].Blue; - } - break; - - case 8: - // - // Convert 8-bit (256 colors) BMP Palette to 24-bit color - // - Blt->Red =3D BmpColorMap[*Image].Red; - Blt->Green =3D BmpColorMap[*Image].Green; - Blt->Blue =3D BmpColorMap[*Image].Blue; - break; - - case 24: - // - // It is 24-bit BMP. - // - Blt->Blue =3D *Image++; - Blt->Green =3D *Image++; - Blt->Red =3D *Image; - break; - - default: - // - // Other bit format BMP is not supported. - // - if (IsAllocated) { - FreePool (*GopBlt); - *GopBlt =3D NULL; - } - return EFI_UNSUPPORTED; - }; - - } - - ImageIndex =3D (UINTN)Image - (UINTN)ImageHeader; - if ((ImageIndex % 4) !=3D 0) { - // - // Bmp Image starts each row on a 32-bit boundary! - // - Image =3D Image + (4 - (ImageIndex % 4)); - } - } - - return EFI_SUCCESS; -} - /** Use SystemTable Conout to stop video based Simple Text Out consoles from= going to the video device. Put up LogoFile on every video device that is a con= sole. @@ -1042,10 +798,10 @@ EnableQuietBoot ( FreePool (Blt); } Blt =3D NULL; - Status =3D ConvertBmpToGopBlt ( + Status =3D TranslateBmpToGopBlt ( ImageData, ImageSize, - (VOID **) &Blt, + &Blt, &BltSize, &Height, &Width diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.in= f b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf index 9d879c20e1..eba0cff200 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf @@ -6,7 +6,7 @@ # 2) BDS boot device connect interface; # 3) BDS Misc interfaces for mainting boot variable, ouput string, etc. # =20 -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at @@ -70,6 +70,7 @@ DxeServicesLib HiiLib ReportStatusCodeLib + BmpSupportLib =20 [Guids] ## SOMETIMES_CONSUMES ## HOB # The hob holding memory type infor= mation diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h= b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h index 7201d8a335..9492117fb9 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h @@ -1,7 +1,7 @@ /** @file BDS library definition, include the file and data structure =20 -Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -71,6 +71,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER= EXPRESS OR IMPLIED. #include #include #include +#include =20 #if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME) #if defined (MDE_CPU_EBC) --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel