From nobody Thu May 2 03:47:10 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 15159879800932.115146875214805; Sun, 14 Jan 2018 19:46:20 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7A28C222DDC0A; Sun, 14 Jan 2018 19:40:59 -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 B8818222DDBFB for ; Sun, 14 Jan 2018 19:40:57 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2018 19:46:15 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by FMSMGA003.fm.intel.com with ESMTP; 14 Jan 2018 19:46:14 -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: Permerror (SPF Permanent Error: Void lookup limit of 2 exceeded) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@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,361,1511856000"; d="scan'208";a="19601229" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 15 Jan 2018 11:46:10 +0800 Message-Id: <20180115034612.381104-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180115034612.381104-1-ruiyu.ni@intel.com> References: <20180115034612.381104-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data 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: 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" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng --- .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 21 ++++++++++-------= ---- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/M= deModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c index 011d9c52cd..3078fe6254 100644 --- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c @@ -1,7 +1,7 @@ /** @file FrameBufferBltLib - Library to perform blt operations on a frame buffer. =20 - Copyright (c) 2007 - 2017, 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -21,11 +21,10 @@ #include =20 struct FRAME_BUFFER_CONFIGURE { - UINTN ColorDepth; - UINTN WidthInBytes; - UINTN BytesPerPixel; - UINTN WidthInPixels; - UINTN Height; + UINT32 WidthInBytes; + UINT32 BytesPerPixel; + UINT32 WidthInPixels; + UINT32 Height; UINT8 *FrameBuffer; EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; EFI_PIXEL_BITMASK PixelMasks; @@ -53,7 +52,7 @@ CONST EFI_PIXEL_BITMASK mBgrPixelMasks =3D { VOID FrameBufferBltLibConfigurePixelFormat ( IN CONST EFI_PIXEL_BITMASK *BitMask, - OUT UINTN *BytesPerPixel, + OUT UINT32 *BytesPerPixel, OUT INT8 *PixelShl, OUT INT8 *PixelShr ) @@ -84,7 +83,7 @@ FrameBufferBltLibConfigurePixelFormat ( MergedMasks =3D (UINT32) (MergedMasks | Masks[3]); =20 ASSERT (MergedMasks !=3D 0); - *BytesPerPixel =3D (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8); + *BytesPerPixel =3D (UINT32) ((HighBitSet32 (MergedMasks) + 7) / 8); DEBUG ((DEBUG_INFO, "Bytes per pixel: %d\n", *BytesPerPixel)); } =20 @@ -115,7 +114,7 @@ FrameBufferBltConfigure ( ) { CONST EFI_PIXEL_BITMASK *BitMask; - UINTN BytesPerPixel; + UINT32 BytesPerPixel; INT8 PixelShl[4]; INT8 PixelShr[4]; =20 @@ -164,8 +163,8 @@ FrameBufferBltConfigure ( Configure->BytesPerPixel =3D BytesPerPixel; Configure->PixelFormat =3D FrameBufferInfo->PixelFormat; Configure->FrameBuffer =3D (UINT8*) FrameBuffer; - Configure->WidthInPixels =3D (UINTN) FrameBufferInfo->HorizontalResoluti= on; - Configure->Height =3D (UINTN) FrameBufferInfo->VerticalResolution; + Configure->WidthInPixels =3D FrameBufferInfo->HorizontalResolution; + Configure->Height =3D FrameBufferInfo->VerticalResolution; Configure->WidthInBytes =3D Configure->WidthInPixels * Configure->Bytes= PerPixel; =20 return RETURN_SUCCESS; --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 03:47:10 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 1515987982959958.4971913720505; Sun, 14 Jan 2018 19:46:22 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DF6B7222DDC0C; Sun, 14 Jan 2018 19:40:59 -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 31D40222DDBF4 for ; Sun, 14 Jan 2018 19:40:58 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2018 19:46:15 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by FMSMGA003.fm.intel.com with ESMTP; 14 Jan 2018 19:46:15 -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: Permerror (SPF Permanent Error: Void lookup limit of 2 exceeded) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@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,361,1511856000"; d="scan'208";a="19601233" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 15 Jan 2018 11:46:11 +0800 Message-Id: <20180115034612.381104-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180115034612.381104-1-ruiyu.ni@intel.com> References: <20180115034612.381104-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted 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: Christian Ehrhardt , 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" The Graphics Output Protocol's mode information specifies the PixelsPerScanLine property. Most of the time this is identical to HorizontalResolution. However, due to alignment requirements etc. it may be slightly larger. I.e. each scan line will have some "pixels" that are not visible on the screen but consume space in the frame buffer. If the graphics output protocol correctly initializes HorizontalResolution to 1366 and PixelsPerScanLine to 1376. As a result the graphics output is broken. If setting HorizontalResolution to 1376 instead, the output is fine (except for 10 invisible pixels on the right of the screen). The patch fixes this bug by using PixelsPerScanLine when calculating the line width. Contributed-under: TianoCore Contribution Agreement 1.1 Reported-by: Christian Ehrhardt Signed-off-by: Christian Ehrhardt Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Christian Ehrhardt Reviewed-by: Star Zeng --- .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 46 ++++++++++++------= ---- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/M= deModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c index 3078fe6254..c88469859b 100644 --- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c @@ -21,9 +21,9 @@ #include =20 struct FRAME_BUFFER_CONFIGURE { - UINT32 WidthInBytes; + UINT32 PixelsPerScanLine; UINT32 BytesPerPixel; - UINT32 WidthInPixels; + UINT32 Width; UINT32 Height; UINT8 *FrameBuffer; EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; @@ -144,6 +144,10 @@ FrameBufferBltConfigure ( return RETURN_INVALID_PARAMETER; } =20 + if (FrameBufferInfo->PixelsPerScanLine < FrameBufferInfo->HorizontalReso= lution) { + return RETURN_UNSUPPORTED; + } + FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, PixelShl= , PixelShr); =20 if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE) @@ -160,12 +164,12 @@ FrameBufferBltConfigure ( CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask)); CopyMem (Configure->PixelShl, PixelShl, sizeof (PixelShl)); CopyMem (Configure->PixelShr, PixelShr, sizeof (PixelShr)); - Configure->BytesPerPixel =3D BytesPerPixel; - Configure->PixelFormat =3D FrameBufferInfo->PixelFormat; - Configure->FrameBuffer =3D (UINT8*) FrameBuffer; - Configure->WidthInPixels =3D FrameBufferInfo->HorizontalResolution; - Configure->Height =3D FrameBufferInfo->VerticalResolution; - Configure->WidthInBytes =3D Configure->WidthInPixels * Configure->Bytes= PerPixel; + Configure->BytesPerPixel =3D BytesPerPixel; + Configure->PixelFormat =3D FrameBufferInfo->PixelFormat; + Configure->FrameBuffer =3D (UINT8*) FrameBuffer; + Configure->Width =3D FrameBufferInfo->HorizontalResolution; + Configure->Height =3D FrameBufferInfo->VerticalResolution; + Configure->PixelsPerScanLine =3D FrameBufferInfo->PixelsPerScanLine; =20 return RETURN_SUCCESS; } @@ -215,7 +219,7 @@ FrameBufferBltLibVideoFill ( return RETURN_INVALID_PARAMETER; } =20 - if (DestinationX + Width > Configure->WidthInPixels) { + if (DestinationX + Width > Configure->Width) { DEBUG ((EFI_D_VERBOSE, "VideoFill: Past screen (X)\n")); return RETURN_INVALID_PARAMETER; } @@ -268,9 +272,9 @@ FrameBufferBltLibVideoFill ( } } =20 - if (UseWideFill && (DestinationX =3D=3D 0) && (Width =3D=3D Configure->W= idthInPixels)) { + if (UseWideFill && (DestinationX =3D=3D 0) && (Width =3D=3D Configure->P= ixelsPerScanLine)) { DEBUG ((EFI_D_VERBOSE, "VideoFill (wide, one-shot)\n")); - Offset =3D DestinationY * Configure->WidthInPixels; + Offset =3D DestinationY * Configure->PixelsPerScanLine; Offset =3D Configure->BytesPerPixel * Offset; Destination =3D Configure->FrameBuffer + Offset; SizeInBytes =3D WidthInBytes * Height; @@ -284,7 +288,7 @@ FrameBufferBltLibVideoFill ( } else { LineBufferReady =3D FALSE; for (IndexY =3D DestinationY; IndexY < (Height + DestinationY); IndexY= ++) { - Offset =3D (IndexY * Configure->WidthInPixels) + DestinationX; + Offset =3D (IndexY * Configure->PixelsPerScanLine) + DestinationX; Offset =3D Configure->BytesPerPixel * Offset; Destination =3D Configure->FrameBuffer + Offset; =20 @@ -368,7 +372,7 @@ FrameBufferBltLibVideoToBltBuffer ( return RETURN_INVALID_PARAMETER; } =20 - if (SourceX + Width > Configure->WidthInPixels) { + if (SourceX + Width > Configure->Width) { return RETURN_INVALID_PARAMETER; } =20 @@ -394,7 +398,7 @@ FrameBufferBltLibVideoToBltBuffer ( DstY < (Height + DestinationY); SrcY++, DstY++) { =20 - Offset =3D (SrcY * Configure->WidthInPixels) + SourceX; + Offset =3D (SrcY * Configure->PixelsPerScanLine) + SourceX; Offset =3D Configure->BytesPerPixel * Offset; Source =3D Configure->FrameBuffer + Offset; =20 @@ -476,7 +480,7 @@ FrameBufferBltLibBufferToVideo ( return RETURN_INVALID_PARAMETER; } =20 - if (DestinationX + Width > Configure->WidthInPixels) { + if (DestinationX + Width > Configure->Width) { return RETURN_INVALID_PARAMETER; } =20 @@ -499,7 +503,7 @@ FrameBufferBltLibBufferToVideo ( SrcY < (Height + SourceY); SrcY++, DstY++) { =20 - Offset =3D (DstY * Configure->WidthInPixels) + DestinationX; + Offset =3D (DstY * Configure->PixelsPerScanLine) + DestinationX; Offset =3D Configure->BytesPerPixel * Offset; Destination =3D Configure->FrameBuffer + Offset; =20 @@ -572,7 +576,7 @@ FrameBufferBltLibVideoToVideo ( return RETURN_INVALID_PARAMETER; } =20 - if (SourceX + Width > Configure->WidthInPixels) { + if (SourceX + Width > Configure->Width) { return RETURN_INVALID_PARAMETER; } =20 @@ -580,7 +584,7 @@ FrameBufferBltLibVideoToVideo ( return RETURN_INVALID_PARAMETER; } =20 - if (DestinationX + Width > Configure->WidthInPixels) { + if (DestinationX + Width > Configure->Width) { return RETURN_INVALID_PARAMETER; } =20 @@ -590,15 +594,15 @@ FrameBufferBltLibVideoToVideo ( =20 WidthInBytes =3D Width * Configure->BytesPerPixel; =20 - Offset =3D (SourceY * Configure->WidthInPixels) + SourceX; + Offset =3D (SourceY * Configure->PixelsPerScanLine) + SourceX; Offset =3D Configure->BytesPerPixel * Offset; Source =3D Configure->FrameBuffer + Offset; =20 - Offset =3D (DestinationY * Configure->WidthInPixels) + DestinationX; + Offset =3D (DestinationY * Configure->PixelsPerScanLine) + DestinationX; Offset =3D Configure->BytesPerPixel * Offset; Destination =3D Configure->FrameBuffer + Offset; =20 - LineStride =3D Configure->WidthInBytes; + LineStride =3D Configure->BytesPerPixel * Configure->PixelsPerScanLine; if (Destination > Source) { // // Copy from last line to avoid source is corrupted by copying --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Thu May 2 03:47:10 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 1515987986018619.1375273422889; Sun, 14 Jan 2018 19:46:26 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 575E7222DDC0E; Sun, 14 Jan 2018 19:41:01 -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 1D003222DDC07 for ; Sun, 14 Jan 2018 19:40:59 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2018 19:46:16 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by FMSMGA003.fm.intel.com with ESMTP; 14 Jan 2018 19:46:16 -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: Permerror (SPF Permanent Error: Void lookup limit of 2 exceeded) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=ruiyu.ni@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,361,1511856000"; d="scan'208";a="19601240" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Mon, 15 Jan 2018 11:46:12 +0800 Message-Id: <20180115034612.381104-4-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 In-Reply-To: <20180115034612.381104-1-ruiyu.ni@intel.com> References: <20180115034612.381104-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory 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: Christian Ehrhardt , 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" Contributed-under: TianoCore Contribution Agreement 1.1 Reported-by: Christian Ehrhardt Signed-off-by: Christian Ehrhardt Cc: Star Zeng Reviewed-by: Ruiyu Ni Reviewed-by: Star Zeng --- MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/M= deModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c index c88469859b..78dc0c0b51 100644 --- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c @@ -280,6 +280,7 @@ FrameBufferBltLibVideoFill ( SizeInBytes =3D WidthInBytes * Height; if (SizeInBytes >=3D 8) { SetMem32 (Destination, SizeInBytes & ~3, (UINT32) WideFill); + Destination +=3D SizeInBytes & ~3; SizeInBytes &=3D 3; } if (SizeInBytes > 0) { @@ -297,6 +298,7 @@ FrameBufferBltLibVideoFill ( SizeInBytes =3D WidthInBytes; if (SizeInBytes >=3D 8) { SetMem64 (Destination, SizeInBytes & ~7, WideFill); + Destination +=3D SizeInBytes & ~7; SizeInBytes &=3D 7; } if (SizeInBytes > 0) { --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel