From nobody Wed May 1 22:38:33 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 1518044313269221.33316123989812; Wed, 7 Feb 2018 14:58:33 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 61C51222DE13F; Wed, 7 Feb 2018 14:52:46 -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 BC940222DE135 for ; Wed, 7 Feb 2018 14:52:43 -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:27 -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:26 -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="16135168" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:13 -0800 Message-Id: <20180207225822.28876-2-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 01/10] MdeModulePkg: Add BmpSupportLib class and instance 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: Ruiyu Ni , Eric Dong , Jiewen Yao , Michael D Kinney , Star Zeng 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" 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 Add BmpSupportLib class and instances that provides services to convert a BMP graphics image to a GOP BLT buffer and to convert a GOP BLT buffer to a BMP graphics image. Cc: Sean Brogan Cc: Jiewen Yao Cc: Star Zeng Cc: Eric Dong Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com Reviewed-by: Star Zeng to MdeModulePkg change with a = minor comment below. --- MdeModulePkg/Include/Library/BmpSupportLib.h | 105 ++++ .../BaseBmpSupportLib/BaseBmpSupportLib.inf | 49 ++ .../BaseBmpSupportLib/BaseBmpSupportLib.uni | 20 + .../Library/BaseBmpSupportLib/BmpSupportLib.c | 583 +++++++++++++++++= ++++ MdeModulePkg/MdeModulePkg.dec | 6 +- MdeModulePkg/MdeModulePkg.dsc | 1 + 6 files changed, 763 insertions(+), 1 deletion(-) create mode 100644 MdeModulePkg/Include/Library/BmpSupportLib.h create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLi= b.inf create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLi= b.uni create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c diff --git a/MdeModulePkg/Include/Library/BmpSupportLib.h b/MdeModulePkg/In= clude/Library/BmpSupportLib.h new file mode 100644 index 0000000000..3406aa3fca --- /dev/null +++ b/MdeModulePkg/Include/Library/BmpSupportLib.h @@ -0,0 +1,105 @@ +/** @file + +Provides services to convert a BMP graphics image to a GOP BLT buffer. + +Copyright (c) 2016, Microsoft Corporation +Copyright (c) 2018, Intel Corporation. All rights reserved.
+ +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notic= e, +this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS= " AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPL= IED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS= CLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY D= IRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUD= ING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF U= SE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEO= RY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLI= GENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**/ + +#ifndef __BMP_SUPPORT_LIB_H__ +#define __BMP_SUPPORT_LIB_H__ + +#include + +/** + Translate a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buff= er + is passed in a GopBlt buffer will be allocated by this routine using + EFI_BOOT_SERVICES.AllocatePool(). If a GopBlt buffer is passed in it wil= l be + used if it is big enough. + + @param [in] BmpImage Pointer to BMP file. + @param [in] BmpImageSize Number of bytes in BmpImage. + @param [in, out] GopBlt Buffer containing GOP version of BmpImage. + @param [in, out] GopBltSize Size of GopBlt in bytes. + @param [out] PixelHeight Height of GopBlt/BmpImage in pixels. + @param [out] PixelWidth Width of GopBlt/BmpImage in pixels. + + @retval RETURN_SUCCESS GopBlt and GopBltSize are returned. + @retval RETURN_INVALID_PARAMETER BmpImage is NULL. + @retval RETURN_INVALID_PARAMETER GopBlt is NULL. + @retval RETURN_INVALID_PARAMETER GopBltSize is NULL. + @retval RETURN_INVALID_PARAMETER PixelHeight is NULL. + @retval RETURN_INVALID_PARAMETER PixelWidth is NULL. + @retval RETURN_UNSUPPORTED BmpImage is not a valid *.BMP image. + @retval RETURN_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big + enough. The required size is returned= in + GopBltSize. + @retval RETURN_OUT_OF_RESOURCES The GopBlt buffer could not be allocat= ed. + +**/ +RETURN_STATUS +EFIAPI +TranslateBmpToGopBlt ( + IN VOID *BmpImage, + IN UINTN BmpImageSize, + IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **GopBlt, + IN OUT UINTN *GopBltSize, + OUT UINTN *PixelHeight, + OUT UINTN *PixelWidth + ); + +/** + Translate a GOP blt buffer to an uncompressed 24-bit per pixel BMP graph= ics + image. If a NULL BmpImage is passed in a BmpImage buffer will be allocat= ed by + this routine using EFI_BOOT_SERVICES.AllocatePool(). If a BmpImage buffe= r is + passed in it will be used if it is big enough. + + @param [in] GopBlt Pointer to GOP blt buffer. + @param [in] PixelHeight Height of GopBlt/BmpImage in pixels. + @param [in] PixelWidth Width of GopBlt/BmpImage in pixels. + @param [in, out] BmpImage Buffer containing BMP version of GopBlt. + @param [in, out] BmpImageSize Size of BmpImage in bytes. + + @retval RETURN_SUCCESS BmpImage and BmpImageSize are returned. + @retval RETURN_INVALID_PARAMETER GopBlt is NULL. + @retval RETURN_INVALID_PARAMETER BmpImage is NULL. + @retval RETURN_INVALID_PARAMETER BmpImageSize is NULL. + @retval RETURN_UNSUPPORTED GopBlt cannot be converted to a *.BMP = image. + @retval RETURN_BUFFER_TOO_SMALL The passed in BmpImage buffer is not b= ig + enough. The required size is returned= in + BmpImageSize. + @retval RETURN_OUT_OF_RESOURCES The BmpImage buffer could not be alloc= ated. + +**/ +RETURN_STATUS +EFIAPI +TranslateGopBltToBmp ( + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *GopBlt, + IN UINT32 PixelHeight, + IN UINT32 PixelWidth, + IN OUT VOID **BmpImage, + IN OUT UINT32 *BmpImageSize + ); + +#endif diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf b= /MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf new file mode 100644 index 0000000000..02c3fae0b4 --- /dev/null +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf @@ -0,0 +1,49 @@ +## @file +# +# Provides services to convert a BMP graphics image to a GOP BLT buffer and +# from a GOP BLT buffer to a BMP graphics image. +# +# Copyright (c) 2017, Microsoft Corporation +# +# All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are m= et: +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright not= ice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS = IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IM= PLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE D= ISCLAIMED. +# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY= DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCL= UDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF= USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY TH= EORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEG= LIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D BaseBmpSupportLib + MODULE_UNI_FILE =3D BaseBmpSupportLib.uni + FILE_GUID =3D CF5F650B-C208-409A-B889-0755172E2B0C + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D BASE + LIBRARY_CLASS =3D BmpSupportLib + +[LibraryClasses] + DebugLib + BaseMemoryLib + MemoryAllocationLib + SafeIntLib + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[Sources] + BmpSupportLib.c diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.uni b= /MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.uni new file mode 100644 index 0000000000..f24e2d246f --- /dev/null +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.uni @@ -0,0 +1,20 @@ +// /** @file +// +// Provides services to convert a BMP graphics image to a GOP BLT buffer a= nd +// from a GOP BLT buffer to a BMP graphics image. +// +// Copyright (c) 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 b= e found at +// http://opensource.org/licenses/bsd-license.php +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "BmpSupportLib ins= tance" + +#string STR_MODULE_DESCRIPTION #language en-US "BmpSupportLib ins= tance." + diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeMo= dulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c new file mode 100644 index 0000000000..2c95e91ecc --- /dev/null +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c @@ -0,0 +1,583 @@ +/** @file + + Provides services to convert a BMP graphics image to a GOP BLT buffer and + from a GOP BLT buffer to a BMP graphics image. + + Caution: This module requires additional review when modified. + This module processes external input - BMP image. + This external input must be validated carefully to avoid security issue = such + as buffer overflow, integer overflow. + + TranslateBmpToGopBlt() receives untrusted input and performs basic valid= ation. + + Copyright (c) 2016-2017, Microsoft Corporation + Copyright (c) 2018, Intel Corporation. All rights reserved.
+ + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are m= et: + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright not= ice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS = IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IM= PLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE D= ISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY= DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCL= UDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF= USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY TH= EORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEG= LIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +**/ + +#include +#include +#include +#include +#include +#include + +#include + +// +// BMP Image header for an uncompressed 24-bit per pixel BMP image. +// +const BMP_IMAGE_HEADER mBmpImageHeaderTemplate =3D { + 'B', // CharB + 'M', // CharM + 0, // Size will be updated at runtime + {0, 0}, // Reserved + sizeof (BMP_IMAGE_HEADER), // ImageOffset + sizeof (BMP_IMAGE_HEADER) - OFFSET_OF (BMP_IMAGE_HEADER, HeaderSize), //= HeaderSize + 0, // PixelWidth will be updated at runtime + 0, // PixelHeight will be updated at runtime + 1, // Planes + 24, // BitPerPixel + 0, // CompressionType + 0, // ImageSize will be updated at runtime + 0, // XPixelsPerMeter + 0, // YPixelsPerMeter + 0, // NumberOfColors + 0 // ImportantColors +}; + +/** + Translate a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buff= er + is passed in a GopBlt buffer will be allocated by this routine using + EFI_BOOT_SERVICES.AllocatePool(). If a GopBlt buffer is passed in it wil= l be + used if it is big enough. + + @param[in] BmpImage Pointer to BMP file. + @param[in] BmpImageSize Number of bytes in BmpImage. + @param[in, out] GopBlt Buffer containing GOP version of BmpImage. + @param[in, out] GopBltSize Size of GopBlt in bytes. + @param[out] PixelHeight Height of GopBlt/BmpImage in pixels. + @param[out] PixelWidth Width of GopBlt/BmpImage in pixels. + + @retval RETURN_SUCCESS GopBlt and GopBltSize are returned. + @retval RETURN_INVALID_PARAMETER BmpImage is NULL. + @retval RETURN_INVALID_PARAMETER GopBlt is NULL. + @retval RETURN_INVALID_PARAMETER GopBltSize is NULL. + @retval RETURN_INVALID_PARAMETER PixelHeight is NULL. + @retval RETURN_INVALID_PARAMETER PixelWidth is NULL. + @retval RETURN_UNSUPPORTED BmpImage is not a valid *.BMP image. + @retval RETURN_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big + enough. The required size is returne= d in + GopBltSize. + @retval RETURN_OUT_OF_RESOURCES The GopBlt buffer could not be alloca= ted. + +**/ +RETURN_STATUS +EFIAPI +TranslateBmpToGopBlt ( + IN VOID *BmpImage, + IN UINTN BmpImageSize, + IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **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; + UINT32 BltBufferSize; + UINTN Index; + UINTN Height; + UINTN Width; + UINTN ImageIndex; + UINT32 DataSizePerLine; + BOOLEAN IsAllocated; + UINT32 ColorMapNum; + RETURN_STATUS Status; + UINT32 DataSize; + UINT32 Temp; + + if (BmpImage =3D=3D NULL || GopBlt =3D=3D NULL || GopBltSize =3D=3D NULL= ) { + return RETURN_INVALID_PARAMETER; + } + if (PixelHeight =3D=3D NULL || PixelWidth =3D=3D NULL) { + return RETURN_INVALID_PARAMETER; + } + + if (BmpImageSize < sizeof (BMP_IMAGE_HEADER)) { + DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: BmpImageSize too small\n")= ); + return RETURN_UNSUPPORTED; + } + + BmpHeader =3D (BMP_IMAGE_HEADER *)BmpImage; + + if (BmpHeader->CharB !=3D 'B' || BmpHeader->CharM !=3D 'M') { + DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: BmpHeader->Char fields inc= orrect\n")); + return RETURN_UNSUPPORTED; + } + + // + // Doesn't support compress. + // + if (BmpHeader->CompressionType !=3D 0) { + DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: Compression Type unsupport= ed.\n")); + return RETURN_UNSUPPORTED; + } + + // + // Only support BITMAPINFOHEADER format. + // BITMAPFILEHEADER + BITMAPINFOHEADER =3D BMP_IMAGE_HEADER + // + if (BmpHeader->HeaderSize !=3D sizeof (BMP_IMAGE_HEADER) - OFFSET_OF (BM= P_IMAGE_HEADER, HeaderSize)) { + DEBUG (( + DEBUG_ERROR, + "TranslateBmpToGopBlt: BmpHeader->Headership is not as expected. He= adersize is 0x%x\n", + BmpHeader->HeaderSize + )); + return RETURN_UNSUPPORTED; + } + + // + // The data size in each line must be 4 byte alignment. + // + Status =3D SafeUint32Mult ( + BmpHeader->PixelWidth, + BmpHeader->BitPerPixel, + &DataSizePerLine + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateBmpToGopBlt: invalid BmpImage... PixelWidth:0x%x BitPerPix= el:0x%x\n", + BmpHeader->PixelWidth, + BmpHeader->BitPerPixel + )); + return RETURN_UNSUPPORTED; + } + + Status =3D SafeUint32Add (DataSizePerLine, 31, &DataSizePerLine); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateBmpToGopBlt: invalid BmpImage... DataSizePerLine:0x%x\n", + DataSizePerLine + )); + + return RETURN_UNSUPPORTED; + } + + DataSizePerLine =3D (DataSizePerLine >> 3) &(~0x3); + Status =3D SafeUint32Mult ( + DataSizePerLine, + BmpHeader->PixelHeight, + &BltBufferSize + ); + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateBmpToGopBlt: invalid BmpImage... DataSizePerLine:0x%x Pixe= lHeight:0x%x\n", + DataSizePerLine, BmpHeader->PixelHeight + )); + + return RETURN_UNSUPPORTED; + } + + Status =3D SafeUint32Mult ( + BmpHeader->PixelHeight, + DataSizePerLine, + &DataSize + ); + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateBmpToGopBlt: invalid BmpImage... PixelHeight:0x%x DataSize= PerLine:0x%x\n", + BmpHeader->PixelHeight, DataSizePerLine + )); + + return RETURN_UNSUPPORTED; + } + + if ((BmpHeader->Size !=3D BmpImageSize) || + (BmpHeader->Size < BmpHeader->ImageOffset) || + (BmpHeader->Size - BmpHeader->ImageOffset !=3D DataSize)) { + + DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n")); + DEBUG ((DEBUG_ERROR, " BmpHeader->Size: 0x%x\n", BmpHeader->Size)); + DEBUG ((DEBUG_ERROR, " BmpHeader->ImageOffset: 0x%x\n", BmpHeader->I= mageOffset)); + DEBUG ((DEBUG_ERROR, " BmpImageSize: 0x%lx\n", (UINTN)BmpImageSize)); + DEBUG ((DEBUG_ERROR, " DataSize: 0x%lx\n", (UINTN)DataSize)); + + return RETURN_UNSUPPORTED; + } + + // + // 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 RETURN_UNSUPPORTED; + } + + 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 the + // bmp data section. + // + if (BmpHeader->ImageOffset - sizeof (BMP_IMAGE_HEADER) < sizeof (BMP_C= OLOR_MAP) * ColorMapNum) { + return RETURN_UNSUPPORTED; + } + } + + // + // Calculate graphics image data address in the image + // + Image =3D ((UINT8 *)BmpImage) + BmpHeader->ImageOffset; + ImageHeader =3D Image; + + // + // Calculate the BltBuffer needed size. + // + Status =3D SafeUint32Mult ( + BmpHeader->PixelWidth, + BmpHeader->PixelHeight, + &BltBufferSize + ); + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateBmpToGopBlt: invalid BltBuffer needed size... PixelWidth:0= x%x PixelHeight:0x%x\n", + BltBufferSize + )); + + return RETURN_UNSUPPORTED; + } + + Temp =3D BltBufferSize; + Status =3D SafeUint32Mult ( + BltBufferSize, + sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), + &BltBufferSize + ); + + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateBmpToGopBlt: invalid BltBuffer needed size... BltBufferSiz= e:0x%lx struct size:0x%x\n", + Temp, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) + )); + + return RETURN_UNSUPPORTED; + } + + IsAllocated =3D FALSE; + if (*GopBlt =3D=3D NULL) { + // + // GopBlt is not allocated by caller. + // + DEBUG ((DEBUG_INFO, "Bmp Support: Allocating 0x%X bytes of memory\n", = BltBufferSize)); + *GopBltSize =3D (UINTN)BltBufferSize; + *GopBlt =3D AllocatePool (*GopBltSize); + IsAllocated =3D TRUE; + if (*GopBlt =3D=3D NULL) { + return RETURN_OUT_OF_RESOURCES; + } + } else { + // + // GopBlt has been allocated by caller. + // + if (*GopBltSize < (UINTN)BltBufferSize) { + *GopBltSize =3D (UINTN)BltBufferSize; + return RETURN_BUFFER_TOO_SMALL; + } + } + + *PixelWidth =3D BmpHeader->PixelWidth; + *PixelHeight =3D BmpHeader->PixelHeight; + DEBUG ((DEBUG_INFO, "BmpHeader->ImageOffset 0x%X\n", BmpHeader->ImageOff= set)); + DEBUG ((DEBUG_INFO, "BmpHeader->PixelWidth 0x%X\n", BmpHeader->PixelWidt= h)); + DEBUG ((DEBUG_INFO, "BmpHeader->PixelHeight 0x%X\n", BmpHeader->PixelHei= ght)); + DEBUG ((DEBUG_INFO, "BmpHeader->BitPerPixel 0x%X\n", BmpHeader->BitPerPi= xel)); + DEBUG ((DEBUG_INFO, "BmpHeader->ImageSize 0x%X\n", BmpHeader->ImageSize)= ); + DEBUG ((DEBUG_INFO, "BmpHeader->HeaderSize 0x%X\n", BmpHeader->HeaderSiz= e)); + DEBUG ((DEBUG_INFO, "BmpHeader->Size 0x%X\n", BmpHeader->Size)); + + // + // Translate 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: + // + // Translate 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: + // + // Translate 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: + // + // Translate 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; + + case 32: + // + //Conver 32 bit to 24bit bmp - just ignore the final byte of each = pixel + 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; + } + DEBUG ((DEBUG_ERROR, "Bmp Bit format not supported. 0x%X\n", BmpH= eader->BitPerPixel)); + return RETURN_UNSUPPORTED; + break; + }; + + } + + ImageIndex =3D (UINTN)(Image - ImageHeader); + if ((ImageIndex % 4) !=3D 0) { + // + // Bmp Image starts each row on a 32-bit boundary! + // + Image =3D Image + (4 - (ImageIndex % 4)); + } + } + + return RETURN_SUCCESS; +} + +/** + Translate a GOP blt buffer to an uncompressed 24-bit per pixel BMP graph= ics + image. If a NULL BmpImage is passed in a BmpImage buffer will be allocat= ed by + this routine using EFI_BOOT_SERVICES.AllocatePool(). If a BmpImage buffe= r is + passed in it will be used if it is big enough. + + @param [in] GopBlt Pointer to GOP blt buffer. + @param [in] PixelHeight Height of GopBlt/BmpImage in pixels. + @param [in] PixelWidth Width of GopBlt/BmpImage in pixels. + @param [in, out] BmpImage Buffer containing BMP version of GopBlt. + @param [in, out] BmpImageSize Size of BmpImage in bytes. + + @retval RETURN_SUCCESS BmpImage and BmpImageSize are returned. + @retval RETURN_INVALID_PARAMETER GopBlt is NULL. + @retval RETURN_INVALID_PARAMETER BmpImage is NULL. + @retval RETURN_INVALID_PARAMETER BmpImageSize is NULL. + @retval RETURN_UNSUPPORTED GopBlt cannot be converted to a *.BMP = image. + @retval RETURN_BUFFER_TOO_SMALL The passed in BmpImage buffer is not b= ig + enough. The required size is returned= in + BmpImageSize. + @retval RETURN_OUT_OF_RESOURCES The BmpImage buffer could not be alloc= ated. + +**/ +RETURN_STATUS +EFIAPI +TranslateGopBltToBmp ( + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *GopBlt, + IN UINT32 PixelHeight, + IN UINT32 PixelWidth, + IN OUT VOID **BmpImage, + IN OUT UINT32 *BmpImageSize + ) +{ + RETURN_STATUS Status; + UINT32 PaddingSize; + UINT32 BmpSize; + BMP_IMAGE_HEADER *BmpImageHeader; + UINT8 *Image; + UINTN Col; + UINTN Row; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltPixel; + + if (GopBlt =3D=3D NULL || BmpImage =3D=3D NULL || BmpImageSize =3D=3D NU= LL) { + return RETURN_INVALID_PARAMETER; + } + + // + // Allocate memory for BMP file. + // + PaddingSize =3D PixelWidth & 0x3; + + // + // First check PixelWidth * 3 + PaddingSize doesn't overflow + // + Status =3D SafeUint32Mult (PixelWidth, 3, &BmpSize); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateGopBltToBmp: GopBlt is too large. PixelHeight:0x%x PixelWi= dth:0x%x\n", + PixelHeight, + PixelWidth + )); + return RETURN_UNSUPPORTED; + } + Status =3D SafeUint32Add (BmpSize, PaddingSize, &BmpSize); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateGopBltToBmp: GopBlt is too large. PixelHeight:0x%x PixelWi= dth:0x%x\n", + PixelHeight, + PixelWidth + )); + return RETURN_UNSUPPORTED; + } + + // + // Second check (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (B= MP_IMAGE_HEADER) doesn't overflow + // + Status =3D SafeUint32Mult (BmpSize, PixelHeight, &BmpSize); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateGopBltToBmp: GopBlt is too large. PixelHeight:0x%x PixelWi= dth:0x%x\n", + PixelHeight, + PixelWidth + )); + return RETURN_UNSUPPORTED; + } + Status =3D SafeUint32Add (BmpSize, sizeof (BMP_IMAGE_HEADER), &BmpSize); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "TranslateGopBltToBmp: GopBlt is too large. PixelHeight:0x%x PixelWi= dth:0x%x\n", + PixelHeight, + PixelWidth + )); + return RETURN_UNSUPPORTED; + } + + // + // The image should be stored in EfiBootServicesData, allowing the syste= m to + // reclaim the memory + // + if (*BmpImage =3D=3D NULL) { + *BmpImage =3D AllocateZeroPool (BmpSize); + if (*BmpImage =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + *BmpImageSize =3D BmpSize; + } else if (*BmpImageSize < BmpSize) { + *BmpImageSize =3D BmpSize; + return RETURN_BUFFER_TOO_SMALL; + } + + BmpImageHeader =3D (BMP_IMAGE_HEADER *)*BmpImage; + CopyMem (BmpImageHeader, &mBmpImageHeaderTemplate, sizeof (BMP_IMAGE_HEA= DER)); + BmpImageHeader->Size =3D *BmpImageSize; + BmpImageHeader->ImageSize =3D *BmpImageSize - sizeof (BMP_IMAGE_HEADER= ); + BmpImageHeader->PixelWidth =3D PixelWidth; + BmpImageHeader->PixelHeight =3D PixelHeight; + + // + // Convert BLT buffer to BMP file. + // + Image =3D (UINT8 *)BmpImageHeader + sizeof (BMP_IMAGE_HEADER); + for (Row =3D 0; Row < PixelHeight; Row++) { + BltPixel =3D &GopBlt[(PixelHeight - Row - 1) * PixelWidth]; + + for (Col =3D 0; Col < PixelWidth; Col++) { + *Image++ =3D BltPixel->Blue; + *Image++ =3D BltPixel->Green; + *Image++ =3D BltPixel->Red; + BltPixel++; + } + + // + // Padding for 4 byte alignment. + // + Image +=3D PaddingSize; + } + + return RETURN_SUCCESS; +} diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 61d034fba8..e3f87a4d28 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -7,7 +7,7 @@ # Copyright (c) 2016, Linaro Ltd. All rights reserved.
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
# Copyright (c) 2017, AMD Incorporated. All rights reserved.
-# +# Copyright (c) 2016, Microsoft Corporation
# This program and the accompanying materials are licensed and made availa= ble under # the terms and conditions of the BSD License that accompanies this distri= bution. # The full text of the license may be found at @@ -167,6 +167,10 @@ ## NonDiscoverableDeviceRegistrationLib|Include/Library/NonDiscoverableDevi= ceRegistrationLib.h =20 + ## @libraryclass Provides services to convert a BMP graphics image to a= GOP BLT buffer. + # + BmpSupportLib|Include/Library/BmpSupportLib.h + [Guids] ## MdeModule package token space guid # Include/Guid/MdeModulePkgTokenSpace.h diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 1c0085aee6..efd33f4b82 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -321,6 +321,7 @@ MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol= .inf MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverabl= eDeviceRegistrationLib.inf + MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf =20 MdeModulePkg/Universal/BdsDxe/BdsDxe.inf MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 1 22:38:33 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 1518044315567965.3901386707514; Wed, 7 Feb 2018 14:58:35 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CA219222DE142; Wed, 7 Feb 2018 14:52:46 -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 E4E49222DE136 for ; Wed, 7 Feb 2018 14:52:43 -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:27 -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:27 -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="16135172" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:14 -0800 Message-Id: <20180207225822.28876-3-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 02/10] MdeModulePkg/DxeCapsuleLibFmp: 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: Ruiyu Ni , Eric Dong , Jiewen Yao , Michael D Kinney , Star Zeng 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 Use BmpSupportLib to convert a BMP graphics image to a GOP BLT buffer. Cc: Sean Brogan Cc: Jiewen Yao Cc: Star Zeng Cc: Eric Dong Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com --- .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c | 268 +----------------= ---- .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf | 3 +- .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf | 3 +- MdeModulePkg/MdeModulePkg.dsc | 2 + 4 files changed, 12 insertions(+), 264 deletions(-) diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeMod= ulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 2f397789b5..56c8e98b84 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -7,10 +7,10 @@ buffer overflow, integer overflow. =20 SupportCapsuleImage(), ProcessCapsuleImage(), IsValidCapsuleHeader(), - ValidateFmpCapsule(), DisplayCapsuleImage(), ConvertBmpToGopBlt() will - receive untrusted input and do basic validation. + ValidateFmpCapsule(), and DisplayCapsuleImage() receives untrusted input= and + performs basic validation. =20 - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -23,7 +23,6 @@ =20 #include =20 -#include #include =20 #include @@ -41,6 +40,7 @@ #include #include #include +#include =20 #include #include @@ -306,262 +306,6 @@ ValidateFmpCapsule ( return EFI_SUCCESS; } =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. - - Caution: This function may receive untrusted input. - - @param[in] BmpImage Pointer to BMP file - @param[in] BmpImageSize Number of bytes in BmpImage - @param[in, out] GopBlt Buffer containing GOP version of BmpImage. - @param[in, out] GopBltSize Size of GopBlt in bytes. - @param[out] PixelHeight Height of GopBlt/BmpImage in pixels - @param[out] 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. - -**/ -STATIC -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) || - (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; - - case 32: - // - // it is 32-bit BMP. Skip pixel's highest byte - // - 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; -} - - /** Those capsules supported by the firmwares. =20 @@ -620,10 +364,10 @@ DisplayCapsuleImage ( Blt =3D NULL; Width =3D 0; Height =3D 0; - Status =3D ConvertBmpToGopBlt ( + Status =3D TranslateBmpToGopBlt ( ImagePayload + 1, PayloadSize - sizeof(DISPLAY_DISPLAY_PAYLOAD), - (VOID **)&Blt, + &Blt, &BltSize, &Height, &Width diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf b/MdeM= odulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf index a7c36993c4..9eb50337a2 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf @@ -3,7 +3,7 @@ # # Capsule library instance for DXE_DRIVER module types. # -# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 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 @@ -51,6 +51,7 @@ ReportStatusCodeLib PrintLib HobLib + BmpSupportLib =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax = ## CONSUMES diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf= b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf index 41916755da..1659b13ef4 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf @@ -3,7 +3,7 @@ # # Capsule library instance for DXE_RUNTIME_DRIVER module types. # -# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 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 @@ -54,6 +54,7 @@ ReportStatusCodeLib PrintLib HobLib + BmpSupportLib =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax = ## CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index efd33f4b82..a7c3dded8b 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -106,6 +106,8 @@ =20 FmpAuthenticationLib|MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAu= thenticationLibNull.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf =20 [LibraryClasses.EBC.PEIM] IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 1 22:38:33 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 1518044320385838.4883499825249; Wed, 7 Feb 2018 14:58:40 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 850AA222DE141; 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 1EE75222DE137 for ; Wed, 7 Feb 2018 14:52:43 -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:27 -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="16135176" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:15 -0800 Message-Id: <20180207225822.28876-4-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 03/10] MdeModulePkg/BootGraphicsResourceTableDxe: 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: Ruiyu Ni , Eric Dong , Jiewen Yao , Michael D Kinney , Star Zeng 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 Use BmpSupportLib to convert a GOP BLT Buffer to the BMP graphics image that is published in an ACPI BGRT table. * Remove use of IndustryStandard/Bmp.h include file * Remove mBmpImageHeaderTemplate. This is handled by BmpSupportLib * Clean up code style with function prototypes at top and all module global variables together * Update SetBootLogo() to use SafeIntLib to check input parameters for overflows. * Remove internal function BgrtAcpiTableChecksum(). Use CalculateCheckSum8() directly from BgrtReadyToBootEventNotify() * Remove InstallBootGraphicsResourceTable(). Move all the code into BgrtReadyToBootEventNotify() that is signaled at ready to boot. * Remove all logic that converts a GOP BLT buffer to a BMP graphics image and use BmpSupportLib function TranslateGopBltToBmp() instead. * Use AllocatePool() instead of AllocatePages() to allocate copy of BMP image that is provided by BGRT. This is required to be compatible with BmpSupportLib function TranslateGopBltToBmp() that uses AllocatePool(). * Zero OemId in BGRT header before filling in value from PCD. * Get size of PcdAcpiDefaultOemId and only copy the the size of the PCD if it is smaller than the size of the OemId field in the BGRT header. * Use WriteUnaligned24() instead of CopyMem() for the OemTableId field of the BGRT header. Cc: Sean Brogan Cc: Jiewen Yao Cc: Star Zeng Cc: Eric Dong Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com --- .../BootGraphicsResourceTableDxe.c | 425 ++++++++++-------= ---- .../BootGraphicsResourceTableDxe.inf | 4 +- 2 files changed, 197 insertions(+), 232 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootG= raphicsResourceTableDxe.c b/MdeModulePkg/Universal/Acpi/BootGraphicsResourc= eTableDxe/BootGraphicsResourceTableDxe.c index 6a7165a954..118fb4a922 100644 --- a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphics= ResourceTableDxe.c +++ b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphics= ResourceTableDxe.c @@ -1,7 +1,7 @@ /** @file This module install ACPI Boot Graphics Resource Table (BGRT). =20 - Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
+ Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -14,7 +14,6 @@ #include =20 #include -#include =20 #include #include @@ -28,44 +27,65 @@ #include #include #include +#include +#include =20 +/** + Update information of logo image drawn on screen. + + @param This The pointer to the Boot Logo protocol instance. + @param BltBuffer The BLT buffer for logo drawn on screen. If BltBu= ffer + is set to NULL, it indicates that logo image is no + longer on the screen. + @param DestinationX X coordinate of destination for the BltBuffer. + @param DestinationY Y coordinate of destination for the BltBuffer. + @param Width Width of rectangle in BltBuffer in pixels. + @param Height Hight of rectangle in BltBuffer in pixels. + + @retval EFI_SUCCESS The boot logo information was updated. + @retval EFI_INVALID_PARAMETER One of the parameters has an invalid val= ue. + @retval EFI_OUT_OF_RESOURCES The logo information was not updated due= to + insufficient memory resources. + +**/ +EFI_STATUS +EFIAPI +SetBootLogo ( + IN EFI_BOOT_LOGO_PROTOCOL *This, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height + ); + +// +// Boot Logo Protocol Handle // -// Module globals. +EFI_HANDLE mBootLogoHandle =3D NULL; + +// +// Boot Logo Protocol Instance // -EFI_EVENT mBootGraphicsReadyToBootEvent; -UINTN mBootGraphicsResourceTableKey =3D 0; +EFI_BOOT_LOGO_PROTOCOL mBootLogoProtocolTemplate =3D { + SetBootLogo +}; =20 -EFI_HANDLE mBootLogoHandle =3D NULL; +EFI_EVENT mBootGraphicsReadyToBootEvent; +UINTN mBootGraphicsResourceTableKey =3D 0; BOOLEAN mIsLogoValid =3D FALSE; EFI_GRAPHICS_OUTPUT_BLT_PIXEL *mLogoBltBuffer =3D NULL; -UINTN mLogoDestX =3D 0; -UINTN mLogoDestY =3D 0; -UINTN mLogoWidth =3D 0; +UINTN mLogoDestX =3D 0; +UINTN mLogoDestY =3D 0; +UINTN mLogoWidth =3D 0; UINTN mLogoHeight =3D 0; +BOOLEAN mAcpiBgrtInstalled =3D FALSE; +BOOLEAN mAcpiBgrtStatusChanged =3D FALSE; +BOOLEAN mAcpiBgrtBufferChanged =3D FALSE; =20 -BMP_IMAGE_HEADER mBmpImageHeaderTemplate =3D { - 'B', // CharB - 'M', // CharM - 0, // Size will be updated at runtime - {0, 0}, // Reserved - sizeof (BMP_IMAGE_HEADER), // ImageOffset - sizeof (BMP_IMAGE_HEADER) - OFFSET_OF (BMP_IMAGE_HEADER, HeaderSize), //= HeaderSize - 0, // PixelWidth will be updated at runtime - 0, // PixelHeight will be updated at runtime - 1, // Planes - 24, // BitPerPixel - 0, // CompressionType - 0, // ImageSize will be updated at runtime - 0, // XPixelsPerMeter - 0, // YPixelsPerMeter - 0, // NumberOfColors - 0 // ImportantColors -}; - -BOOLEAN mAcpiBgrtInstalled =3D FALSE; -BOOLEAN mAcpiBgrtStatusChanged =3D FALSE; -BOOLEAN mAcpiBgrtBufferChanged =3D FALSE; - +// +// ACPI Boot Graphics Resource Table template +// EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphicsResourceTableTempla= te =3D { { EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE, @@ -89,37 +109,6 @@ EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphics= ResourceTableTemplate =3D { 0 // Image Offset Y }; =20 -/** - Update information of logo image drawn on screen. - - @param This The pointer to the Boot Logo protocol instance. - @param BltBuffer The BLT buffer for logo drawn on screen. If BltBu= ffer - is set to NULL, it indicates that logo image is no - longer on the screen. - @param DestinationX X coordinate of destination for the BltBuffer. - @param DestinationY Y coordinate of destination for the BltBuffer. - @param Width Width of rectangle in BltBuffer in pixels. - @param Height Hight of rectangle in BltBuffer in pixels. - - @retval EFI_SUCCESS The boot logo information was updated. - @retval EFI_INVALID_PARAMETER One of the parameters has an invalid val= ue. - @retval EFI_OUT_OF_RESOURCES The logo information was not updated due= to - insufficient memory resources. - -**/ -EFI_STATUS -EFIAPI -SetBootLogo ( - IN EFI_BOOT_LOGO_PROTOCOL *This, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height - ); - -EFI_BOOT_LOGO_PROTOCOL mBootLogoProtocolTemplate =3D { SetBootLogo }; - /** Update information of logo image drawn on screen. =20 @@ -149,7 +138,9 @@ SetBootLogo ( IN UINTN Height ) { - UINT64 BufferSize; + EFI_STATUS Status; + UINTN BufferSize; + UINT32 Result32; =20 if (BltBuffer =3D=3D NULL) { mIsLogoValid =3D FALSE; @@ -157,103 +148,115 @@ SetBootLogo ( return EFI_SUCCESS; } =20 + // + // Width and height are not allowed to be zero. + // if (Width =3D=3D 0 || Height =3D=3D 0) { return EFI_INVALID_PARAMETER; } - =20 - mAcpiBgrtBufferChanged =3D TRUE; - if (mLogoBltBuffer !=3D NULL) { - FreePool (mLogoBltBuffer); - mLogoBltBuffer =3D NULL; + + // + // Verify destination, width, and height do not overflow 32-bit values. + // The Boot Graphics Resource Table only has 32-bit fields for these val= ues. + // + Status =3D SafeUintnToUint32 (DestinationX, &Result32); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; } - =20 + Status =3D SafeUintnToUint32 (DestinationY, &Result32); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + Status =3D SafeUintnToUint32 (Width, &Result32); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + Status =3D SafeUintnToUint32 (Height, &Result32); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + // - // Ensure the Height * Width doesn't overflow + // Ensure the Height * Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) do= es + // not overflow UINTN // - if (Height > DivU64x64Remainder ((UINTN) ~0, Width, NULL)) { + Status =3D SafeUintnMult ( + Width, + Height, + &BufferSize + ); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + Status =3D SafeUintnMult ( + BufferSize, + sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), + &BufferSize + ); + if (EFI_ERROR (Status)) { return EFI_UNSUPPORTED; } - BufferSize =3D MultU64x64 (Width, Height); - =20 + // - // Ensure the BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn'= t overflow + // Update state // - if (BufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_= PIXEL))) { - return EFI_UNSUPPORTED; + mAcpiBgrtBufferChanged =3D TRUE; + + // + // Free old logo buffer + // + if (mLogoBltBuffer !=3D NULL) { + FreePool (mLogoBltBuffer); + mLogoBltBuffer =3D NULL; } =20 - mLogoBltBuffer =3D AllocateCopyPool ( - (UINTN)BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_P= IXEL), - BltBuffer - ); + // + // Allocate new logo buffer + // + mLogoBltBuffer =3D AllocateCopyPool (BufferSize, BltBuffer); if (mLogoBltBuffer =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } - mLogoDestX =3D DestinationX; - mLogoDestY =3D DestinationY; - mLogoWidth =3D Width; - mLogoHeight =3D Height; + + mLogoDestX =3D DestinationX; + mLogoDestY =3D DestinationY; + mLogoWidth =3D Width; + mLogoHeight =3D Height; mIsLogoValid =3D TRUE; =20 return EFI_SUCCESS; } =20 /** - This function calculates and updates an UINT8 checksum. + Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is u= sed to + install the Boot Graphics Resource Table. =20 - @param[in] Buffer Pointer to buffer to checksum. - @param[in] Size Number of bytes to checksum. + @param[in] Event The Event that is being processed. + @param[in] Context The Event Context. =20 **/ VOID -BgrtAcpiTableChecksum ( - IN UINT8 *Buffer, - IN UINTN Size - ) -{ - UINTN ChecksumOffset; - - ChecksumOffset =3D OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum); - - // - // Set checksum to 0 first. - // - Buffer[ChecksumOffset] =3D 0; - - // - // Update checksum value. - // - Buffer[ChecksumOffset] =3D CalculateCheckSum8 (Buffer, Size); -} - -/** - Install Boot Graphics Resource Table to ACPI table. - - @return Status code. - -**/ -EFI_STATUS -InstallBootGraphicsResourceTable ( - VOID +EFIAPI +BgrtReadyToBootEventNotify ( + IN EFI_EVENT Event, + IN VOID *Context ) { - EFI_STATUS Status; - EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; - UINT8 *ImageBuffer; - UINTN PaddingSize; - UINTN BmpSize; - UINTN OrigBmpSize; - UINT8 *Image; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltPixel; - UINTN Col; - UINTN Row; + EFI_STATUS Status; + EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; + VOID *ImageBuffer; + UINT32 BmpSize; =20 // // Get ACPI Table protocol. // - Status =3D gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID = **) &AcpiTableProtocol); + Status =3D gBS->LocateProtocol ( + &gEfiAcpiTableProtocolGuid, + NULL, + (VOID **) &AcpiTableProtocol + ); if (EFI_ERROR (Status)) { - return Status; + return; } =20 // @@ -264,109 +267,85 @@ InstallBootGraphicsResourceTable ( // // Nothing has changed // - return EFI_SUCCESS; + return; } else { // - // If BGRT data change happens. Uninstall Orignal AcpiTable first + // If BGRT data change happens, then uninstall orignal AcpiTable fir= st // Status =3D AcpiTableProtocol->UninstallAcpiTable ( AcpiTableProtocol, mBootGraphicsResourceTableKey ); if (EFI_ERROR (Status)) { - return Status; - }=20 + return; + } } } else { // - // Check whether Logo exist. + // Check whether Logo exists // - if ( mLogoBltBuffer =3D=3D NULL) { - return EFI_NOT_FOUND; + if (mLogoBltBuffer =3D=3D NULL) { + return; } } =20 if (mAcpiBgrtBufferChanged) { // - // reserve original BGRT buffer size + // Free the old BMP image buffer // - OrigBmpSize =3D mBmpImageHeaderTemplate.ImageSize + sizeof (BMP_IMAGE_= HEADER); - // - // Free orignal BMP memory=20 - //=20 - if (mBootGraphicsResourceTableTemplate.ImageAddress) { - gBS->FreePages(mBootGraphicsResourceTableTemplate.ImageAddress, EFI_= SIZE_TO_PAGES(OrigBmpSize)); + ImageBuffer =3D (UINT8 *)(UINTN)mBootGraphicsResourceTableTemplate.Ima= geAddress; + if (ImageBuffer !=3D NULL) { + FreePool (ImageBuffer); } =20 // - // Allocate memory for BMP file. + // Convert GOP Blt buffer to BMP image. Pass in ImageBuffer set to NU= LL + // so the BMP image is allocated by TranslateGopBltToBmp(). // - PaddingSize =3D mLogoWidth & 0x3; - - // - // First check mLogoWidth * 3 + PaddingSize doesn't overflow - // - if (mLogoWidth > (((UINT32) ~0) - PaddingSize) / 3 ) { - return EFI_UNSUPPORTED; - } - - // - // Second check (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof = (BMP_IMAGE_HEADER) doesn't overflow - // - if (mLogoHeight > (((UINT32) ~0) - sizeof (BMP_IMAGE_HEADER)) / (mLogo= Width * 3 + PaddingSize)) { - return EFI_UNSUPPORTED; + ImageBuffer =3D NULL; + Status =3D TranslateGopBltToBmp ( + mLogoBltBuffer, + (UINT32)mLogoHeight, + (UINT32)mLogoWidth, + &ImageBuffer, + &BmpSize + ); + if (EFI_ERROR (Status)) { + return; } =20 // - // The image should be stored in EfiBootServicesData, allowing the sys= tem to reclaim the memory - // - BmpSize =3D (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP= _IMAGE_HEADER); - ImageBuffer =3D AllocatePages (EFI_SIZE_TO_PAGES (BmpSize)); - if (ImageBuffer =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - ZeroMem (ImageBuffer, BmpSize); - - mBmpImageHeaderTemplate.Size =3D (UINT32) BmpSize; - mBmpImageHeaderTemplate.ImageSize =3D (UINT32) BmpSize - sizeof (BMP_I= MAGE_HEADER); - mBmpImageHeaderTemplate.PixelWidth =3D (UINT32) mLogoWidth; - mBmpImageHeaderTemplate.PixelHeight =3D (UINT32) mLogoHeight; - CopyMem (ImageBuffer, &mBmpImageHeaderTemplate, sizeof (BMP_IMAGE_HEAD= ER)); - =20 - // - // Convert BLT buffer to BMP file. + // Free the logo buffer // - Image =3D ImageBuffer + sizeof (BMP_IMAGE_HEADER); - for (Row =3D 0; Row < mLogoHeight; Row++) { - BltPixel =3D &mLogoBltBuffer[(mLogoHeight - Row - 1) * mLogoWidth]; - - for (Col =3D 0; Col < mLogoWidth; Col++) { - *Image++ =3D BltPixel->Blue; - *Image++ =3D BltPixel->Green; - *Image++ =3D BltPixel->Red; - BltPixel++; - } - - // - // Padding for 4 byte alignment. - // - Image +=3D PaddingSize; - } FreePool (mLogoBltBuffer); mLogoBltBuffer =3D NULL; =20 - mBootGraphicsResourceTableTemplate.ImageAddress =3D (UINT64) (UINTN) I= mageBuffer; - mBootGraphicsResourceTableTemplate.ImageOffsetX =3D (UINT32) mLogoDest= X; - mBootGraphicsResourceTableTemplate.ImageOffsetY =3D (UINT32) mLogoDest= Y; + // + // Update BMP image fields of the Boot Graphics Resource Table + // + mBootGraphicsResourceTableTemplate.ImageAddress =3D (UINT64)(UINTN)Ima= geBuffer; + mBootGraphicsResourceTableTemplate.ImageOffsetX =3D (UINT32)mLogoDestX; + mBootGraphicsResourceTableTemplate.ImageOffsetY =3D (UINT32)mLogoDestY; } =20 - mBootGraphicsResourceTableTemplate.Status =3D (UINT8) (mIsLogoValid ? EF= I_ACPI_5_0_BGRT_STATUS_VALID : EFI_ACPI_5_0_BGRT_STATUS_INVALID); + // + // Update Status field of Boot Graphics Resource Table + // + if (mIsLogoValid) { + mBootGraphicsResourceTableTemplate.Status =3D EFI_ACPI_5_0_BGRT_STATUS= _VALID; + } else { + mBootGraphicsResourceTableTemplate.Status =3D EFI_ACPI_5_0_BGRT_STATUS= _INVALID; + } =20 // - // Update Checksum. + // Update Checksum of Boot Graphics Resource Table // - BgrtAcpiTableChecksum ((UINT8 *) &mBootGraphicsResourceTableTemplate, si= zeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE)); + mBootGraphicsResourceTableTemplate.Header.Checksum =3D 0; + mBootGraphicsResourceTableTemplate.Header.Checksum =3D + CalculateCheckSum8 ( + (UINT8 *)&mBootGraphicsResourceTableTemplate, + sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE) + ); =20 // // Publish Boot Graphics Resource Table. @@ -378,32 +357,12 @@ InstallBootGraphicsResourceTable ( &mBootGraphicsResourceTableKey ); if (EFI_ERROR (Status)) { - return Status; + return; } =20 - mAcpiBgrtInstalled =3D TRUE; + mAcpiBgrtInstalled =3D TRUE; mAcpiBgrtStatusChanged =3D FALSE; mAcpiBgrtBufferChanged =3D FALSE; - =20 - return Status; -} - -/** - Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is u= sed to - install the Boot Graphics Resource Table. - - @param[in] Event The Event that is being processed. - @param[in] Context The Event Context. - -**/ -VOID -EFIAPI -BgrtReadyToBootEventNotify ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - InstallBootGraphicsResourceTable (); } =20 /** @@ -419,23 +378,27 @@ BgrtReadyToBootEventNotify ( EFI_STATUS EFIAPI BootGraphicsDxeEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - UINT64 OemTableId; + EFI_STATUS Status; + EFI_ACPI_DESCRIPTION_HEADER *Header; =20 + // + // Update Header fields of Boot Graphics Resource Table from PCDs + // + Header =3D &mBootGraphicsResourceTableTemplate.Header; + ZeroMem (Header->OemId, sizeof (Header->OemId)); CopyMem ( - mBootGraphicsResourceTableTemplate.Header.OemId, + Header->OemId, PcdGetPtr (PcdAcpiDefaultOemId), - sizeof (mBootGraphicsResourceTableTemplate.Header.OemId) + MIN (PcdGetSize (PcdAcpiDefaultOemId), sizeof (Header->OemId)) ); - OemTableId =3D PcdGet64 (PcdAcpiDefaultOemTableId); - CopyMem (&mBootGraphicsResourceTableTemplate.Header.OemTableId, &OemTabl= eId, sizeof (UINT64)); - mBootGraphicsResourceTableTemplate.Header.OemRevision =3D PcdGet32 = (PcdAcpiDefaultOemRevision); - mBootGraphicsResourceTableTemplate.Header.CreatorId =3D PcdGet32 = (PcdAcpiDefaultCreatorId); - mBootGraphicsResourceTableTemplate.Header.CreatorRevision =3D PcdGet32 = (PcdAcpiDefaultCreatorRevision); + WriteUnaligned64 (&Header->OemTableId, PcdGet64 (PcdAcpiDefaultOemTableI= d)); + Header->OemRevision =3D PcdGet32 (PcdAcpiDefaultOemRevision); + Header->CreatorId =3D PcdGet32 (PcdAcpiDefaultCreatorId); + Header->CreatorRevision =3D PcdGet32 (PcdAcpiDefaultCreatorRevision); =20 // // Install Boot Logo protocol. diff --git a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootG= raphicsResourceTableDxe.inf b/MdeModulePkg/Universal/Acpi/BootGraphicsResou= rceTableDxe/BootGraphicsResourceTableDxe.inf index 9fd1da448c..ff33405acd 100644 --- a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphics= ResourceTableDxe.inf +++ b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphics= ResourceTableDxe.inf @@ -1,7 +1,7 @@ ## @file # This module install ACPI Boot Graphics Resource Table (BGRT). # -# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 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 @@ -43,6 +43,8 @@ UefiBootServicesTableLib DebugLib PcdLib + SafeIntLib + BmpSupportLib =20 [Protocols] gEfiAcpiTableProtocolGuid ## CONSUMES --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 1 22:38:33 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 Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com --- .../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 From nobody Wed May 1 22:38:33 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 1518044323106439.6543454403751; Wed, 7 Feb 2018 14:58:43 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DC663222DE14A; 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 B2346222DE135 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="16135185" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:17 -0800 Message-Id: <20180207225822.28876-6-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 05/10] OvmfPkg: Add SafeIntLib and BmpSupportLib to DSC files 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: Ard Biesheuvel , Jordan Justen , Jiewen Yao , Michael D Kinney , Laszlo Ersek 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 The BootGraphicsResourceTableDxe module uses the BmpSupportLib and SafeIntLib to convert a GOP BLT buffer to a BMP graphics image. Add library mappings for these new library classes. Cc: Sean Brogan Cc: Jiewen Yao Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com Reviewed-by: Laszlo Ersek --- OvmfPkg/OvmfPkgIa32.dsc | 2 ++ OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++ OvmfPkg/OvmfPkgX64.dsc | 2 ++ 3 files changed, 6 insertions(+) diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index d762955c5d..e10f898607 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -104,6 +104,8 @@ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza= tionLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibN= ull.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 6bcbe70d64..a31c7919ad 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -109,6 +109,8 @@ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza= tionLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibN= ull.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 70fcdcba11..bc433a9724 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -109,6 +109,8 @@ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza= tionLib.inf CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibN= ull.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 1 22:38:33 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 1518044325775280.4369363208415; Wed, 7 Feb 2018 14:58:45 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3DD5E222DE14D; Wed, 7 Feb 2018 14:52:48 -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 E087F222DE132 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:29 -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="16135189" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:18 -0800 Message-Id: <20180207225822.28876-7-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 06/10] Vlv2TbltDevicePkg/Override/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 , David Wei 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: David Wei Cc: Mang Guo Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com --- .../Library/GenericBdsLib/BdsConsole.c | 251 +----------------= ---- .../Library/GenericBdsLib/GenericBdsLib.inf | 3 +- .../Library/GenericBdsLib/InternalBdsLib.h | 3 +- Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 4 +- Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 4 +- Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 4 +- 6 files changed, 16 insertions(+), 253 deletions(-) diff --git a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/Gen= ericBdsLib/BdsConsole.c b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePk= g/Library/GenericBdsLib/BdsConsole.c index eefec0642a..9c21cfcd59 100644 --- a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBds= Lib/BdsConsole.c +++ b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBds= Lib/BdsConsole.c @@ -1,7 +1,7 @@ /** @file BDS Lib functions which contain all the code to connect console device =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 @@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER= EXPRESS OR IMPLIED. **/ =20 #include "InternalBdsLib.h" -#include =20 =20 /** @@ -642,250 +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; - break; - }; - - } - - ImageIndex =3D (UINTN) (Image - 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. @@ -1043,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/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/Gen= ericBdsLib/GenericBdsLib.inf b/Vlv2TbltDevicePkg/Override/IntelFrameworkMod= ulePkg/Library/GenericBdsLib/GenericBdsLib.inf index 33ca29835d..75bff59fda 100644 --- a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBds= Lib/GenericBdsLib.inf +++ b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBds= Lib/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 @@ -71,6 +71,7 @@ HiiLib ReportStatusCodeLib NetLib + BmpSupportLib =20 [Guids] ## SOMETIMES_CONSUMES ## HOB # The hob holding memory type infor= mation diff --git a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/Gen= ericBdsLib/InternalBdsLib.h b/Vlv2TbltDevicePkg/Override/IntelFrameworkModu= lePkg/Library/GenericBdsLib/InternalBdsLib.h index c32579bfc5..b964f41425 100644 --- a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBds= Lib/InternalBdsLib.h +++ b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBds= Lib/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 @@ -72,6 +72,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) diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/Pl= atformPkgGccX64.dsc index f98263d8a5..7467642e8b 100644 --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc @@ -1,7 +1,7 @@ #/** @file # Platform description. # -# Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials are licensed and made availa= ble under # the terms and conditions of the BSD License that accompanies this distri= bution. @@ -146,6 +146,8 @@ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf GenericBdsLib|$(PLATFORM_PACKAGE)/Override/IntelFrameworkModulePkg/Libra= ry/GenericBdsLib/GenericBdsLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf PlatformBdsLib|$(PLATFORM_PACKAGE)/Library/PlatformBdsLib/PlatformBdsLib= .inf NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/Plat= formPkgIA32.dsc index c755df2fe2..94fe744e2b 100644 --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc @@ -1,7 +1,7 @@ #/** @file # Platform description. # -# Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials are licensed and made availa= ble under # the terms and conditions of the BSD License that accompanies this distri= bution. @@ -146,6 +146,8 @@ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf GenericBdsLib|$(PLATFORM_PACKAGE)/Override/IntelFrameworkModulePkg/Libra= ry/GenericBdsLib/GenericBdsLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf PlatformBdsLib|$(PLATFORM_PACKAGE)/Library/PlatformBdsLib/PlatformBdsLib= .inf NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/Platf= ormPkgX64.dsc index dda8216e6a..59e75326d9 100644 --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc @@ -1,7 +1,7 @@ #/** @file # Platform description. # -# Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
# # This program and the accompanying materials are licensed and made availa= ble under # the terms and conditions of the BSD License that accompanies this distri= bution. @@ -146,6 +146,8 @@ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf GenericBdsLib|$(PLATFORM_PACKAGE)/Override/IntelFrameworkModulePkg/Libra= ry/GenericBdsLib/GenericBdsLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf PlatformBdsLib|$(PLATFORM_PACKAGE)/Library/PlatformBdsLib/PlatformBdsLib= .inf NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 1 22:38:33 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 1518044328354104.51533791927955; Wed, 7 Feb 2018 14:58:48 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8FCAB222DE135; Wed, 7 Feb 2018 14:52:48 -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 9DBAD222DE132 for ; Wed, 7 Feb 2018 14:52:45 -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:29 -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:29 -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="16135192" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:19 -0800 Message-Id: <20180207225822.28876-8-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 07/10] QuarkPlatformPkg: Add SafeIntLib and BmpSupportLib to DSC files 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 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 Add BmpSupportLib and SafeIntLib mappings that are required by the DxeCapsuleLib when CAPSULE_ENABLE is set. Cc: Sean Brogan Cc: Jiewen Yao Cc: Kelly Steele Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com --- QuarkPlatformPkg/Quark.dsc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc index 5624451e12..7365a3a1bf 100644 --- a/QuarkPlatformPkg/Quark.dsc +++ b/QuarkPlatformPkg/Quark.dsc @@ -2,7 +2,7 @@ # Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices. # # This package provides Clanton Peak CRB platform specific modules. -# Copyright (c) 2013 - 2017 Intel Corporation. +# Copyright (c) 2013 - 2018 Intel Corporation. # # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License @@ -231,6 +231,8 @@ =20 !if $(CAPSULE_ENABLE) CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf !else CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf !endif --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 1 22:38:33 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 1518044333260363.30328251454057; Wed, 7 Feb 2018 14:58:53 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4C4C521F0DA76; Wed, 7 Feb 2018 14:52:49 -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 52DF4222DE13D for ; Wed, 7 Feb 2018 14:52:46 -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:30 -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:29 -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="16135195" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:20 -0800 Message-Id: <20180207225822.28876-9-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 08/10] DuetPkg: Add SafeIntLib and BmpSupportLib to DSC files 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 , Ruiyu Ni , Jiewen Yao , Hao Wu 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 Add BmpSupportLib and SafeIntLib mappings that are required by GenericBdsLib. Cc: Sean Brogan Cc: Jiewen Yao Cc: Ruiyu Ni Cc: Hao Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com --- DuetPkg/DuetPkgIa32.dsc | 4 +++- DuetPkg/DuetPkgX64.dsc | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DuetPkg/DuetPkgIa32.dsc b/DuetPkg/DuetPkgIa32.dsc index ca3fbc2662..06cc61deb6 100644 --- a/DuetPkg/DuetPkgIa32.dsc +++ b/DuetPkg/DuetPkgIa32.dsc @@ -4,7 +4,7 @@ # Developer's UEFI Emulation. DUET provides an EFI/UEFI IA32/X64 environm= ent on legacy BIOS, # to help developing and debugging native EFI/UEFI drivers. # -# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 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 @@ -87,6 +87,8 @@ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLi= b.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeC= offExtraActionLibNull.inf diff --git a/DuetPkg/DuetPkgX64.dsc b/DuetPkg/DuetPkgX64.dsc index c41b9fbe8d..ee97dc2da2 100644 --- a/DuetPkg/DuetPkgX64.dsc +++ b/DuetPkg/DuetPkgX64.dsc @@ -4,7 +4,7 @@ # Developer's UEFI Emulation. DUET provides an EFI/UEFI IA32/X64 environm= ent on legacy BIOS, # to help developing and debugging native EFI/UEFI drivers. # -# Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 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 @@ -87,6 +87,8 @@ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLi= b.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeC= offExtraActionLibNull.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 1 22:38:33 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 1518044330830369.047849956973; Wed, 7 Feb 2018 14:58:50 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E3694222DE151; Wed, 7 Feb 2018 14:52:48 -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 27484222DE132 for ; Wed, 7 Feb 2018 14:52:46 -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:30 -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:29 -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="16135199" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:21 -0800 Message-Id: <20180207225822.28876-10-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 09/10] EmulatorPkg: Add SafeIntLib and BmpSupportLib to DSC files 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 , Jordan Justen , Jiewen Yao , Andrew Fish 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 Add BmpSupportLib and SafeIntLib mappings that are required by GenericBdsLib. Cc: Sean Brogan Cc: Jiewen Yao Cc: Jordan Justen Cc: Andrew Fish Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com Reviewed-by: Jordan Justen --- EmulatorPkg/EmulatorPkg.dsc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc index 818691ce3a..1c274cb723 100644 --- a/EmulatorPkg/EmulatorPkg.dsc +++ b/EmulatorPkg/EmulatorPkg.dsc @@ -83,6 +83,8 @@ DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHo= okStatusCodeLibNull.inf GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLi= b.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Customize= dDisplayLib.inf SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeS= ecurityManagementLib.inf TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplat= e.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Wed May 1 22:38:33 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 1518044335911309.81071922946774; Wed, 7 Feb 2018 14:58:55 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A96AF222DE153; Wed, 7 Feb 2018 14:52:49 -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 7CB86222DE141 for ; Wed, 7 Feb 2018 14:52:46 -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:30 -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:30 -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="16135203" From: "Kinney, Michael D" To: edk2-devel@lists.01.org Date: Wed, 7 Feb 2018 14:58:22 -0800 Message-Id: <20180207225822.28876-11-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 10/10] ArmVirtPkg: Add SafeIntLib and BmpSupportLib to DSC files 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 , Laszlo Ersek , Jiewen Yao , Ard Biesheuvel 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 The BootGraphicsResourceTableDxe module uses the BmpSupportLib and SafeIntLib to convert a GOP BLT buffer to a BMP graphics image. Add library mappings for these new library classes. Cc: Sean Brogan Cc: Jiewen Yao Cc: Laszlo Ersek Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com --- ArmVirtPkg/ArmVirt.dsc.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 5144bb10df..0cb48f08e9 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -1,7 +1,7 @@ # # Copyright (c) 2011-2015, ARM Limited. All rights reserved. # Copyright (c) 2014, Linaro Limited. All rights reserved. -# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2015 - 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 @@ -34,6 +34,8 @@ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseD= ebugPrintErrorLevelLib.inf =20 BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf + BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.i= nf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniza= tionLib.inf PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibN= ull.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf --=20 2.14.2.windows.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel