* [PATCH 0/3] Fix two bugs in FrameBufferBltLib.
@ 2018-01-15 3:46 Ruiyu Ni
2018-01-15 3:46 ` [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data Ruiyu Ni
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Ruiyu Ni @ 2018-01-15 3:46 UTC (permalink / raw)
To: edk2-devel
Ruiyu Ni (3):
MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data
MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted
MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory
.../Library/FrameBufferBltLib/FrameBufferBltLib.c | 61 ++++++++++++----------
1 file changed, 33 insertions(+), 28 deletions(-)
--
2.15.1.windows.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data
2018-01-15 3:46 [PATCH 0/3] Fix two bugs in FrameBufferBltLib Ruiyu Ni
@ 2018-01-15 3:46 ` Ruiyu Ni
[not found] ` <0C09AFA07DD0434D9E2A0C6AEB0483103B9FC6E6@shsmsx102.ccr.corp.intel.com>
2018-01-15 3:46 ` [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted Ruiyu Ni
2018-01-15 3:46 ` [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory Ruiyu Ni
2 siblings, 1 reply; 7+ messages in thread
From: Ruiyu Ni @ 2018-01-15 3:46 UTC (permalink / raw)
To: edk2-devel; +Cc: Star Zeng
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
---
.../Library/FrameBufferBltLib/FrameBufferBltLib.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/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.
- Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
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
@@ -21,11 +21,10 @@
#include <Library/FrameBufferBltLib.h>
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 = {
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 = (UINT32) (MergedMasks | Masks[3]);
ASSERT (MergedMasks != 0);
- *BytesPerPixel = (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8);
+ *BytesPerPixel = (UINT32) ((HighBitSet32 (MergedMasks) + 7) / 8);
DEBUG ((DEBUG_INFO, "Bytes per pixel: %d\n", *BytesPerPixel));
}
@@ -115,7 +114,7 @@ FrameBufferBltConfigure (
)
{
CONST EFI_PIXEL_BITMASK *BitMask;
- UINTN BytesPerPixel;
+ UINT32 BytesPerPixel;
INT8 PixelShl[4];
INT8 PixelShr[4];
@@ -164,8 +163,8 @@ FrameBufferBltConfigure (
Configure->BytesPerPixel = BytesPerPixel;
Configure->PixelFormat = FrameBufferInfo->PixelFormat;
Configure->FrameBuffer = (UINT8*) FrameBuffer;
- Configure->WidthInPixels = (UINTN) FrameBufferInfo->HorizontalResolution;
- Configure->Height = (UINTN) FrameBufferInfo->VerticalResolution;
+ Configure->WidthInPixels = FrameBufferInfo->HorizontalResolution;
+ Configure->Height = FrameBufferInfo->VerticalResolution;
Configure->WidthInBytes = Configure->WidthInPixels * Configure->BytesPerPixel;
return RETURN_SUCCESS;
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted
2018-01-15 3:46 [PATCH 0/3] Fix two bugs in FrameBufferBltLib Ruiyu Ni
2018-01-15 3:46 ` [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data Ruiyu Ni
@ 2018-01-15 3:46 ` Ruiyu Ni
2018-01-16 5:18 ` Zeng, Star
2018-01-15 3:46 ` [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory Ruiyu Ni
2 siblings, 1 reply; 7+ messages in thread
From: Ruiyu Ni @ 2018-01-15 3:46 UTC (permalink / raw)
To: edk2-devel; +Cc: Christian Ehrhardt, Star Zeng
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 <ehrhardt@genua.de>
Signed-off-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Christian Ehrhardt <ehrhardt@genua.de>
---
.../Library/FrameBufferBltLib/FrameBufferBltLib.c | 46 ++++++++++++----------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/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 <Library/FrameBufferBltLib.h>
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;
}
+ if (FrameBufferInfo->PixelsPerScanLine < FrameBufferInfo->HorizontalResolution) {
+ return RETURN_UNSUPPORTED;
+ }
+
FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, PixelShl, PixelShr);
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 = BytesPerPixel;
- Configure->PixelFormat = FrameBufferInfo->PixelFormat;
- Configure->FrameBuffer = (UINT8*) FrameBuffer;
- Configure->WidthInPixels = FrameBufferInfo->HorizontalResolution;
- Configure->Height = FrameBufferInfo->VerticalResolution;
- Configure->WidthInBytes = Configure->WidthInPixels * Configure->BytesPerPixel;
+ Configure->BytesPerPixel = BytesPerPixel;
+ Configure->PixelFormat = FrameBufferInfo->PixelFormat;
+ Configure->FrameBuffer = (UINT8*) FrameBuffer;
+ Configure->Width = FrameBufferInfo->HorizontalResolution;
+ Configure->Height = FrameBufferInfo->VerticalResolution;
+ Configure->PixelsPerScanLine = FrameBufferInfo->PixelsPerScanLine;
return RETURN_SUCCESS;
}
@@ -215,7 +219,7 @@ FrameBufferBltLibVideoFill (
return RETURN_INVALID_PARAMETER;
}
- 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 (
}
}
- if (UseWideFill && (DestinationX == 0) && (Width == Configure->WidthInPixels)) {
+ if (UseWideFill && (DestinationX == 0) && (Width == Configure->PixelsPerScanLine)) {
DEBUG ((EFI_D_VERBOSE, "VideoFill (wide, one-shot)\n"));
- Offset = DestinationY * Configure->WidthInPixels;
+ Offset = DestinationY * Configure->PixelsPerScanLine;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
SizeInBytes = WidthInBytes * Height;
@@ -284,7 +288,7 @@ FrameBufferBltLibVideoFill (
} else {
LineBufferReady = FALSE;
for (IndexY = DestinationY; IndexY < (Height + DestinationY); IndexY++) {
- Offset = (IndexY * Configure->WidthInPixels) + DestinationX;
+ Offset = (IndexY * Configure->PixelsPerScanLine) + DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
@@ -368,7 +372,7 @@ FrameBufferBltLibVideoToBltBuffer (
return RETURN_INVALID_PARAMETER;
}
- if (SourceX + Width > Configure->WidthInPixels) {
+ if (SourceX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -394,7 +398,7 @@ FrameBufferBltLibVideoToBltBuffer (
DstY < (Height + DestinationY);
SrcY++, DstY++) {
- Offset = (SrcY * Configure->WidthInPixels) + SourceX;
+ Offset = (SrcY * Configure->PixelsPerScanLine) + SourceX;
Offset = Configure->BytesPerPixel * Offset;
Source = Configure->FrameBuffer + Offset;
@@ -476,7 +480,7 @@ FrameBufferBltLibBufferToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (DestinationX + Width > Configure->WidthInPixels) {
+ if (DestinationX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -499,7 +503,7 @@ FrameBufferBltLibBufferToVideo (
SrcY < (Height + SourceY);
SrcY++, DstY++) {
- Offset = (DstY * Configure->WidthInPixels) + DestinationX;
+ Offset = (DstY * Configure->PixelsPerScanLine) + DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
@@ -572,7 +576,7 @@ FrameBufferBltLibVideoToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (SourceX + Width > Configure->WidthInPixels) {
+ if (SourceX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -580,7 +584,7 @@ FrameBufferBltLibVideoToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (DestinationX + Width > Configure->WidthInPixels) {
+ if (DestinationX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -590,15 +594,15 @@ FrameBufferBltLibVideoToVideo (
WidthInBytes = Width * Configure->BytesPerPixel;
- Offset = (SourceY * Configure->WidthInPixels) + SourceX;
+ Offset = (SourceY * Configure->PixelsPerScanLine) + SourceX;
Offset = Configure->BytesPerPixel * Offset;
Source = Configure->FrameBuffer + Offset;
- Offset = (DestinationY * Configure->WidthInPixels) + DestinationX;
+ Offset = (DestinationY * Configure->PixelsPerScanLine) + DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
- LineStride = Configure->WidthInBytes;
+ LineStride = Configure->BytesPerPixel * Configure->PixelsPerScanLine;
if (Destination > Source) {
//
// Copy from last line to avoid source is corrupted by copying
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory
2018-01-15 3:46 [PATCH 0/3] Fix two bugs in FrameBufferBltLib Ruiyu Ni
2018-01-15 3:46 ` [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data Ruiyu Ni
2018-01-15 3:46 ` [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted Ruiyu Ni
@ 2018-01-15 3:46 ` Ruiyu Ni
2018-01-16 5:18 ` Zeng, Star
2 siblings, 1 reply; 7+ messages in thread
From: Ruiyu Ni @ 2018-01-15 3:46 UTC (permalink / raw)
To: edk2-devel; +Cc: Christian Ehrhardt, Star Zeng
Contributed-under: TianoCore Contribution Agreement 1.1
Reported-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Christian Ehrhardt <ehrhardt@genua.de>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/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 = WidthInBytes * Height;
if (SizeInBytes >= 8) {
SetMem32 (Destination, SizeInBytes & ~3, (UINT32) WideFill);
+ Destination += SizeInBytes & ~3;
SizeInBytes &= 3;
}
if (SizeInBytes > 0) {
@@ -297,6 +298,7 @@ FrameBufferBltLibVideoFill (
SizeInBytes = WidthInBytes;
if (SizeInBytes >= 8) {
SetMem64 (Destination, SizeInBytes & ~7, WideFill);
+ Destination += SizeInBytes & ~7;
SizeInBytes &= 7;
}
if (SizeInBytes > 0) {
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted
2018-01-15 3:46 ` [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted Ruiyu Ni
@ 2018-01-16 5:18 ` Zeng, Star
0 siblings, 0 replies; 7+ messages in thread
From: Zeng, Star @ 2018-01-16 5:18 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Christian Ehrhardt, Zeng, Star
Reviewed-by: Star Zeng <star.zeng@intel.com>
Thanks,
Star
-----Original Message-----
From: Ni, Ruiyu
Sent: Monday, January 15, 2018 11:46 AM
To: edk2-devel@lists.01.org
Cc: Christian Ehrhardt <ehrhardt@genua.de>; Zeng, Star <star.zeng@intel.com>
Subject: [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted
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 <ehrhardt@genua.de>
Signed-off-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Christian Ehrhardt <ehrhardt@genua.de>
---
.../Library/FrameBufferBltLib/FrameBufferBltLib.c | 46 ++++++++++++----------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/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 <Library/FrameBufferBltLib.h>
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;
}
+ if (FrameBufferInfo->PixelsPerScanLine < FrameBufferInfo->HorizontalResolution) {
+ return RETURN_UNSUPPORTED;
+ }
+
FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, PixelShl, PixelShr);
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 = BytesPerPixel;
- Configure->PixelFormat = FrameBufferInfo->PixelFormat;
- Configure->FrameBuffer = (UINT8*) FrameBuffer;
- Configure->WidthInPixels = FrameBufferInfo->HorizontalResolution;
- Configure->Height = FrameBufferInfo->VerticalResolution;
- Configure->WidthInBytes = Configure->WidthInPixels * Configure->BytesPerPixel;
+ Configure->BytesPerPixel = BytesPerPixel;
+ Configure->PixelFormat = FrameBufferInfo->PixelFormat;
+ Configure->FrameBuffer = (UINT8*) FrameBuffer;
+ Configure->Width = FrameBufferInfo->HorizontalResolution;
+ Configure->Height = FrameBufferInfo->VerticalResolution;
+ Configure->PixelsPerScanLine = FrameBufferInfo->PixelsPerScanLine;
return RETURN_SUCCESS;
}
@@ -215,7 +219,7 @@ FrameBufferBltLibVideoFill (
return RETURN_INVALID_PARAMETER;
}
- 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 (
}
}
- if (UseWideFill && (DestinationX == 0) && (Width == Configure->WidthInPixels)) {
+ if (UseWideFill && (DestinationX == 0) && (Width ==
+ Configure->PixelsPerScanLine)) {
DEBUG ((EFI_D_VERBOSE, "VideoFill (wide, one-shot)\n"));
- Offset = DestinationY * Configure->WidthInPixels;
+ Offset = DestinationY * Configure->PixelsPerScanLine;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
SizeInBytes = WidthInBytes * Height; @@ -284,7 +288,7 @@ FrameBufferBltLibVideoFill (
} else {
LineBufferReady = FALSE;
for (IndexY = DestinationY; IndexY < (Height + DestinationY); IndexY++) {
- Offset = (IndexY * Configure->WidthInPixels) + DestinationX;
+ Offset = (IndexY * Configure->PixelsPerScanLine) + DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
@@ -368,7 +372,7 @@ FrameBufferBltLibVideoToBltBuffer (
return RETURN_INVALID_PARAMETER;
}
- if (SourceX + Width > Configure->WidthInPixels) {
+ if (SourceX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -394,7 +398,7 @@ FrameBufferBltLibVideoToBltBuffer (
DstY < (Height + DestinationY);
SrcY++, DstY++) {
- Offset = (SrcY * Configure->WidthInPixels) + SourceX;
+ Offset = (SrcY * Configure->PixelsPerScanLine) + SourceX;
Offset = Configure->BytesPerPixel * Offset;
Source = Configure->FrameBuffer + Offset;
@@ -476,7 +480,7 @@ FrameBufferBltLibBufferToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (DestinationX + Width > Configure->WidthInPixels) {
+ if (DestinationX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -499,7 +503,7 @@ FrameBufferBltLibBufferToVideo (
SrcY < (Height + SourceY);
SrcY++, DstY++) {
- Offset = (DstY * Configure->WidthInPixels) + DestinationX;
+ Offset = (DstY * Configure->PixelsPerScanLine) + DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
@@ -572,7 +576,7 @@ FrameBufferBltLibVideoToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (SourceX + Width > Configure->WidthInPixels) {
+ if (SourceX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -580,7 +584,7 @@ FrameBufferBltLibVideoToVideo (
return RETURN_INVALID_PARAMETER;
}
- if (DestinationX + Width > Configure->WidthInPixels) {
+ if (DestinationX + Width > Configure->Width) {
return RETURN_INVALID_PARAMETER;
}
@@ -590,15 +594,15 @@ FrameBufferBltLibVideoToVideo (
WidthInBytes = Width * Configure->BytesPerPixel;
- Offset = (SourceY * Configure->WidthInPixels) + SourceX;
+ Offset = (SourceY * Configure->PixelsPerScanLine) + SourceX;
Offset = Configure->BytesPerPixel * Offset;
Source = Configure->FrameBuffer + Offset;
- Offset = (DestinationY * Configure->WidthInPixels) + DestinationX;
+ Offset = (DestinationY * Configure->PixelsPerScanLine) +
+ DestinationX;
Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
- LineStride = Configure->WidthInBytes;
+ LineStride = Configure->BytesPerPixel * Configure->PixelsPerScanLine;
if (Destination > Source) {
//
// Copy from last line to avoid source is corrupted by copying
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory
2018-01-15 3:46 ` [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory Ruiyu Ni
@ 2018-01-16 5:18 ` Zeng, Star
0 siblings, 0 replies; 7+ messages in thread
From: Zeng, Star @ 2018-01-16 5:18 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Christian Ehrhardt, Zeng, Star
Reviewed-by: Star Zeng <star.zeng@intel.com>
Thanks,
Star
-----Original Message-----
From: Ni, Ruiyu
Sent: Monday, January 15, 2018 11:46 AM
To: edk2-devel@lists.01.org
Cc: Christian Ehrhardt <ehrhardt@genua.de>; Zeng, Star <star.zeng@intel.com>
Subject: [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory
Contributed-under: TianoCore Contribution Agreement 1.1
Reported-by: Christian Ehrhardt <ehrhardt@genua.de>
Signed-off-by: Christian Ehrhardt <ehrhardt@genua.de>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/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 = WidthInBytes * Height;
if (SizeInBytes >= 8) {
SetMem32 (Destination, SizeInBytes & ~3, (UINT32) WideFill);
+ Destination += SizeInBytes & ~3;
SizeInBytes &= 3;
}
if (SizeInBytes > 0) {
@@ -297,6 +298,7 @@ FrameBufferBltLibVideoFill (
SizeInBytes = WidthInBytes;
if (SizeInBytes >= 8) {
SetMem64 (Destination, SizeInBytes & ~7, WideFill);
+ Destination += SizeInBytes & ~7;
SizeInBytes &= 7;
}
if (SizeInBytes > 0) {
--
2.15.1.windows.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data
[not found] ` <0C09AFA07DD0434D9E2A0C6AEB0483103B9FC6E6@shsmsx102.ccr.corp.intel.com>
@ 2018-01-16 5:24 ` Ni, Ruiyu
0 siblings, 0 replies; 7+ messages in thread
From: Ni, Ruiyu @ 2018-01-16 5:24 UTC (permalink / raw)
To: Zeng, Star, edk2-devel@lists.01.org
On 1/16/2018 1:19 PM, Zeng, Star wrote:
> Reviewed-by: Star Zeng <star.zeng@intel.com>
>
> The patch also removes the unused ColorDepth field, right?
yes. I will mentioned in the commit message body.
>
> Thanks,
> Star
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, January 15, 2018 11:46 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>
> Subject: [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> ---
> .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/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.
>
> - Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2007 - 2018, Intel Corporation. All rights
> + reserved.<BR>
> 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 @@ -21,11 +21,10 @@ #include <Library/FrameBufferBltLib.h>
>
> 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 = { 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 = (UINT32) (MergedMasks | Masks[3]);
>
> ASSERT (MergedMasks != 0);
> - *BytesPerPixel = (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8);
> + *BytesPerPixel = (UINT32) ((HighBitSet32 (MergedMasks) + 7) / 8);
> DEBUG ((DEBUG_INFO, "Bytes per pixel: %d\n", *BytesPerPixel)); }
>
> @@ -115,7 +114,7 @@ FrameBufferBltConfigure (
> )
> {
> CONST EFI_PIXEL_BITMASK *BitMask;
> - UINTN BytesPerPixel;
> + UINT32 BytesPerPixel;
> INT8 PixelShl[4];
> INT8 PixelShr[4];
>
> @@ -164,8 +163,8 @@ FrameBufferBltConfigure (
> Configure->BytesPerPixel = BytesPerPixel;
> Configure->PixelFormat = FrameBufferInfo->PixelFormat;
> Configure->FrameBuffer = (UINT8*) FrameBuffer;
> - Configure->WidthInPixels = (UINTN) FrameBufferInfo->HorizontalResolution;
> - Configure->Height = (UINTN) FrameBufferInfo->VerticalResolution;
> + Configure->WidthInPixels = FrameBufferInfo->HorizontalResolution;
> + Configure->Height = FrameBufferInfo->VerticalResolution;
> Configure->WidthInBytes = Configure->WidthInPixels * Configure->BytesPerPixel;
>
> return RETURN_SUCCESS;
> --
> 2.15.1.windows.2
>
--
Thanks,
Ray
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-01-16 5:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 3:46 [PATCH 0/3] Fix two bugs in FrameBufferBltLib Ruiyu Ni
2018-01-15 3:46 ` [PATCH 1/3] MdeModulePkg/FrameBufferBltLib: Use UINT32 type for internal data Ruiyu Ni
[not found] ` <0C09AFA07DD0434D9E2A0C6AEB0483103B9FC6E6@shsmsx102.ccr.corp.intel.com>
2018-01-16 5:24 ` Ni, Ruiyu
2018-01-15 3:46 ` [PATCH 2/3] MdeModulePkg/FrameBufferBltLib: Fix a bug causing display corrupted Ruiyu Ni
2018-01-16 5:18 ` Zeng, Star
2018-01-15 3:46 ` [PATCH 3/3] MdeModulePkg/FrameBufferBltLib: Fix copying of unaligned memory Ruiyu Ni
2018-01-16 5:18 ` Zeng, Star
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox