Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu...@intel.com> Cc: Laszlo Ersek <ler...@redhat.com> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Kinney Michael <michael.d.kin...@intel.com> Cc: Feng Tian <feng.t...@intel.com> --- MdeModulePkg/Include/Library/BltLib.h | 147 ++++++ .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 573 +++++++++++++++++++++ .../FrameBufferBltLib/FrameBufferBltLib.inf | 33 ++ MdeModulePkg/Library/GopBltLib/GopBltLib.c | 324 ++++++++++++ MdeModulePkg/Library/GopBltLib/GopBltLib.inf | 35 ++ MdeModulePkg/MdeModulePkg.dec | 4 + MdeModulePkg/MdeModulePkg.dsc | 2 + .../Application/BltLibSample/BltLibSample.inf | 4 +- OptionRomPkg/Include/Library/BltLib.h | 147 ------ .../Library/FrameBufferBltLib/FrameBufferBltLib.c | 573 --------------------- .../FrameBufferBltLib/FrameBufferBltLib.inf | 35 -- OptionRomPkg/Library/GopBltLib/GopBltLib.c | 324 ------------ OptionRomPkg/Library/GopBltLib/GopBltLib.inf | 37 -- OptionRomPkg/OptionRomPkg.dsc | 7 +- OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 3 +- 18 files changed, 1127 insertions(+), 1127 deletions(-) create mode 100644 MdeModulePkg/Include/Library/BltLib.h create mode 100644 MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c create mode 100644 MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf create mode 100644 MdeModulePkg/Library/GopBltLib/GopBltLib.c create mode 100644 MdeModulePkg/Library/GopBltLib/GopBltLib.inf delete mode 100644 OptionRomPkg/Include/Library/BltLib.h delete mode 100644 OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c delete mode 100644 OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf delete mode 100644 OptionRomPkg/Library/GopBltLib/GopBltLib.c delete mode 100644 OptionRomPkg/Library/GopBltLib/GopBltLib.inf
diff --git a/MdeModulePkg/Include/Library/BltLib.h b/MdeModulePkg/Include/Library/BltLib.h new file mode 100644 index 0000000..65ea9d4 --- /dev/null +++ b/MdeModulePkg/Include/Library/BltLib.h @@ -0,0 +1,147 @@ +/** @file + Library for performing video blt operations + + Copyright (c) 2009 - 2015, 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 + 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 IMPLIED. + +**/ + +#ifndef __BLT_LIB__ +#define __BLT_LIB__ + +#include <Protocol/GraphicsOutput.h> + +/** + Performs a UEFI Graphics Output Protocol Blt Video Fill. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] Color Color to fill the region with + @param[in] DestinationX X location to start fill operation + @param[in] DestinationY Y location to start fill operation + @param[in] Width Width (in pixels) to fill + @param[in] Height Height to fill + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoFill ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height + ); + +/** + Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[out] BltBuffer Output buffer for pixel color data + @param[in] SourceX X location within video + @param[in] SourceY Y location within video + @param[in] DestinationX X location within BltBuffer + @param[in] DestinationY Y location within BltBuffer + @param[in] Width Width (in pixels) + @param[in] Height Height + @param[in] Delta Number of bytes in a row of BltBuffer + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoToBuffer ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta + ); + +/** + Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] BltBuffer Output buffer for pixel color data + @param[in] SourceX X location within BltBuffer + @param[in] SourceY Y location within BltBuffer + @param[in] DestinationX X location within video + @param[in] DestinationY Y location within video + @param[in] Width Width (in pixels) + @param[in] Height Height + @param[in] Delta Number of bytes in a row of BltBuffer + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltBufferToVideo ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta + ); + +/** + Performs a UEFI Graphics Output Protocol Blt Video to Video operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] SourceX X location within video + @param[in] SourceY Y location within video + @param[in] DestinationX X location within video + @param[in] DestinationY Y location within video + @param[in] Width Width (in pixels) + @param[in] Height Height + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoToVideo ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height + ); + +#endif + diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c new file mode 100644 index 0000000..977f852 --- /dev/null +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c @@ -0,0 +1,573 @@ +/** @file + FrameBufferBltLib - Library to perform blt operations on a frame buffer. + + Copyright (c) 2007 - 2015, 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 + 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 IMPLIED. + +**/ + +#include <Uefi.h> +#include <Library/BaseLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/DebugLib.h> +#include <Protocol/GraphicsOutput.h> + +#if 0 +#define VDEBUG DEBUG +#else +#define VDEBUG(x) +#endif + +#define MAX_LINE_BUFFER_SIZE (SIZE_4KB * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) + +UINT8 mBltLibLineBuffer[MAX_LINE_BUFFER_SIZE]; +EFI_PIXEL_BITMASK mBltLibRgbPixelMasks = {0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}; +EFI_PIXEL_BITMASK mBltLibBgrPixelMasks = {0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}; + +EFI_STATUS +BltLibParsePixelFormat ( + IN EFI_GRAPHICS_PIXEL_FORMAT PixelFormat, + IN EFI_PIXEL_BITMASK *PixelInformation, + OUT UINT8 *PixelShl, + OUT UINT8 *PixelShr, + OUT UINT32 *PixelMask, + OUT UINT8 *BytesPerPixel + ) +{ + UINTN Index; + UINT32 MergedMasks; + UINT32 *Mask; + + switch (PixelFormat) { + case PixelRedGreenBlueReserved8BitPerColor: + return BltLibParsePixelFormat (PixelBitMask, &mBltLibRgbPixelMasks, PixelShl, PixelShr, PixelMask, BytesPerPixel); + + case PixelBlueGreenRedReserved8BitPerColor: + return BltLibParsePixelFormat (PixelBitMask, &mBltLibBgrPixelMasks, PixelShl, PixelShr, PixelMask, BytesPerPixel); + + case PixelBitMask: + break; + + default: + return EFI_INVALID_PARAMETER; + } + + MergedMasks = 0; + Mask = (UINT32 *) PixelInformation; + for (Index = 0; Index < 4; Index++) { + // + // Only ReservedMask can be 0 + // + if (Index != 3 && Mask[Index] == 0) { + return EFI_INVALID_PARAMETER; + } + // + // The Mask of each color shouldn't overlap + // + if ((MergedMasks & Mask[Index]) != 0) { + return EFI_INVALID_PARAMETER; + } + MergedMasks |= Mask[Index]; + + if (PixelShl != NULL && PixelShr != NULL) { + PixelShl[Index] = (UINT8) (HighBitSet32 (Mask[Index]) - 23 + (Index * 8)); + PixelShl[Index] %= 32; + if ((INT8) PixelShl[Index] < 0) { + PixelShr[Index] = -PixelShl[Index]; + PixelShl[Index] = 0; + } else { + PixelShr[Index] = 0; + } + VDEBUG ((EFI_D_INFO, "%d: shl:%d shr:%d mask:%x\n", Index, PixelShl[Index], PixelShr[Index], Mask[Index])); + } + } + if (PixelMask != NULL) { + CopyMem (PixelMask, PixelInformation, sizeof (EFI_PIXEL_BITMASK)); + } + + if (BytesPerPixel != NULL) { + *BytesPerPixel = (UINT8) ((HighBitSet32 (MergedMasks) + 7) / 8); + VDEBUG ((EFI_D_INFO, "Bytes per pixel: %d\n", *BytesPerPixel)); + } + + return EFI_SUCCESS; +} + +EFI_STATUS +BltLibVerifyLocation ( + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN UINTN X, + IN UINTN Y, + IN UINTN Width, + IN UINTN Height + ) +{ + if ((X >= FrameBufferInfo->HorizontalResolution) || + (Width > FrameBufferInfo->HorizontalResolution - X) + ) { + VDEBUG ((EFI_D_INFO, "VideoFill: Past screen (X)\n")); + return EFI_INVALID_PARAMETER; + } + + if ((Y >= FrameBufferInfo->VerticalResolution) || + (Height > FrameBufferInfo->VerticalResolution - Y) + ) { + VDEBUG ((EFI_D_INFO, "VideoFill: Past screen (Y)\n")); + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} + +/** + Performs a UEFI Graphics Output Protocol Blt Video Fill. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] Color Color to fill the region with + @param[in] DestinationX X location to start fill operation + @param[in] DestinationY Y location to start fill operation + @param[in] Width Width (in pixels) to fill + @param[in] Height Height to fill + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoFill ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height + ) +{ + EFI_STATUS Status; + UINTN Y; + UINT8 *Destination; + UINTN X; + UINT8 Uint8; + UINT32 Uint32; + UINT64 WideFill; + BOOLEAN UseWideFill; + BOOLEAN LineBufferReady; + UINTN Offset; + UINTN WidthInBytes; + UINTN SizeInBytes; + UINT8 PixelShr[4]; + UINT8 PixelShl[4]; + UINT32 PixelMask[4]; + UINT8 BytesPerPixel; + + Status = BltLibVerifyLocation (FrameBufferInfo, DestinationX, DestinationY, Width, Height); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = BltLibParsePixelFormat ( + FrameBufferInfo->PixelFormat, + &FrameBufferInfo->PixelInformation, + PixelShr, PixelShl, PixelMask, &BytesPerPixel + ); + if (EFI_ERROR (Status)) { + return Status; + } + + WidthInBytes = Width * BytesPerPixel; + + Uint32 = *(UINT32 *) Color; + WideFill = (((Uint32 << PixelShl[0]) >> PixelShr[0]) & PixelMask[0]) | + (((Uint32 << PixelShl[1]) >> PixelShr[1]) & PixelMask[1]) | + (((Uint32 << PixelShl[2]) >> PixelShr[2]) & PixelMask[2]) | + (((Uint32 << PixelShl[3]) >> PixelShr[3]) & PixelMask[3]); + VDEBUG ((EFI_D_INFO, "VideoFill: color=0x%x, wide-fill=0x%x\n", Uint32, WideFill)); + + // + // If the size of the pixel data evenly divides the sizeof + // WideFill, then a wide fill operation can be used + // + UseWideFill = TRUE; + if (sizeof (WideFill) % BytesPerPixel == 0) { + for (X = BytesPerPixel; X < sizeof (WideFill); X++) { + ((UINT8 *) &WideFill)[X] = ((UINT8 *) &WideFill)[X % BytesPerPixel]; + } + } else { + // + // If all the bytes in the pixel are the same value, then use + // a wide fill operation. + // + for (X = 1, Uint8 = ((UINT8*) &WideFill)[0]; X < BytesPerPixel; X++) { + if (Uint8 != ((UINT8*) &WideFill)[X]) { + UseWideFill = FALSE; + break; + } + } + if (UseWideFill) { + SetMem (&WideFill, sizeof (WideFill), Uint8); + } + } + + if (UseWideFill && (DestinationX == 0) && (Width == FrameBufferInfo->HorizontalResolution)) { + VDEBUG ((EFI_D_INFO, "VideoFill (wide, one-shot)\n")); + Offset = DestinationY * FrameBufferInfo->PixelsPerScanLine * BytesPerPixel; + Destination = (UINT8 *) FrameBuffer + Offset; + SizeInBytes = WidthInBytes * Height; + if (SizeInBytes >= 8) { + SetMem64 (Destination, SizeInBytes & ~7, WideFill); + Destination += (SizeInBytes & ~7); + SizeInBytes &= 7; + } + if (SizeInBytes > 0) { + CopyMem (Destination, &WideFill, SizeInBytes); + } + } else { + LineBufferReady = FALSE; + for (Y = DestinationY; Y < (Height + DestinationY); Y++) { + Offset = ((Y * FrameBufferInfo->PixelsPerScanLine) + DestinationX) * BytesPerPixel; + Destination = (UINT8 *) FrameBuffer + Offset; + + if (UseWideFill && (((UINTN) Destination & 7) == 0)) { + VDEBUG ((EFI_D_INFO, "VideoFill (wide)\n")); + SizeInBytes = WidthInBytes; + if (SizeInBytes >= 8) { + SetMem64 (Destination, SizeInBytes & ~7, WideFill); + Destination += (SizeInBytes & ~7); + SizeInBytes &= 7; + } + if (SizeInBytes > 0) { + CopyMem (Destination, &WideFill, SizeInBytes); + } + } else { + VDEBUG ((EFI_D_INFO, "VideoFill (not wide)\n")); + if (!LineBufferReady) { + CopyMem (mBltLibLineBuffer, &WideFill, BytesPerPixel); + for (X = 1; X < Width; ) { + CopyMem ( + (mBltLibLineBuffer + (X * BytesPerPixel)), + mBltLibLineBuffer, + MIN (X, Width - X) * BytesPerPixel + ); + X += MIN (X, Width - X); + } + LineBufferReady = TRUE; + } + CopyMem (Destination, mBltLibLineBuffer, WidthInBytes); + } + } + } + + return EFI_SUCCESS; +} + +/** + Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[out] BltBuffer Output buffer for pixel color data + @param[in] SourceX X location within video + @param[in] SourceY Y location within video + @param[in] DestinationX X location within BltBuffer + @param[in] DestinationY Y location within BltBuffer + @param[in] Width Width (in pixels) + @param[in] Height Height + @param[in] Delta Number of bytes in a row of BltBuffer + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoToBuffer ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta + ) +{ + EFI_STATUS Status; + UINTN DstY; + UINTN SrcY; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; + UINT8 *Source; + UINT8 *Destination; + UINTN X; + UINT32 Uint32; + UINTN Offset; + UINTN WidthInBytes; + UINT8 PixelShr[4]; + UINT8 PixelShl[4]; + UINT32 PixelMask[4]; + UINT8 BytesPerPixel; + + // + // Video to BltBuffer: Source is Video, destination is BltBuffer + // + Status = BltLibVerifyLocation (FrameBufferInfo, SourceX, SourceY, Width, Height); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = BltLibParsePixelFormat ( + FrameBufferInfo->PixelFormat, + &FrameBufferInfo->PixelInformation, + PixelShl, PixelShr, PixelMask, &BytesPerPixel + ); + if (EFI_ERROR (Status)) { + return Status; + } + // + // If Delta is zero, then the entire BltBuffer is being used, so Delta + // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size, + // the number of bytes in each row can be computed. + // + if (Delta == 0) { + Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); + } + + WidthInBytes = Width * BytesPerPixel; + + // + // Video to BltBuffer: Source is Video, destination is BltBuffer + // + for (SrcY = SourceY, DstY = DestinationY; DstY < (DestinationY + Height); SrcY++, DstY++) { + + Offset = ((SrcY * FrameBufferInfo->PixelsPerScanLine) + SourceX) * BytesPerPixel; + Source = (UINT8 *) FrameBuffer + Offset; + + if (FrameBufferInfo->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) { + Destination = (UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); + } else { + Destination = mBltLibLineBuffer; + } + + CopyMem (Destination, Source, WidthInBytes); + + if (FrameBufferInfo->PixelFormat != PixelBlueGreenRedReserved8BitPerColor) { + for (X = 0; X < Width; X++) { + Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX + X) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); + Uint32 = * (UINT32 *) (mBltLibLineBuffer + (X * BytesPerPixel)); + *(UINT32*) Blt = (((Uint32 & PixelMask[0]) >> PixelShl[0]) << PixelShr[0]) | + (((Uint32 & PixelMask[1]) >> PixelShl[1]) << PixelShr[1]) | + (((Uint32 & PixelMask[2]) >> PixelShl[2]) << PixelShr[2]) | + (((Uint32 & PixelMask[3]) >> PixelShl[3]) << PixelShr[3]); + } + } + } + + return EFI_SUCCESS; +} + +/** + Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] BltBuffer Output buffer for pixel color data + @param[in] SourceX X location within BltBuffer + @param[in] SourceY Y location within BltBuffer + @param[in] DestinationX X location within video + @param[in] DestinationY Y location within video + @param[in] Width Width (in pixels) + @param[in] Height Height + @param[in] Delta Number of bytes in a row of BltBuffer + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltBufferToVideo ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta + ) +{ + EFI_STATUS Status; + UINTN DstY; + UINTN SrcY; + EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; + UINT8 *Source; + UINT8 *Destination; + UINTN X; + UINT32 Uint32; + UINTN Offset; + UINTN WidthInBytes; + UINT8 PixelShr[4]; + UINT8 PixelShl[4]; + UINT32 PixelMask[4]; + UINT8 BytesPerPixel; + + // + // BltBuffer to Video: Source is BltBuffer, destination is Video + // + Status = BltLibVerifyLocation (FrameBufferInfo, DestinationX, DestinationY, Width, Height); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = BltLibParsePixelFormat ( + FrameBufferInfo->PixelFormat, + &FrameBufferInfo->PixelInformation, + PixelShl, PixelShr, PixelMask, &BytesPerPixel + ); + if (EFI_ERROR (Status)) { + return Status; + } + // + // If Delta is zero, then the entire BltBuffer is being used, so Delta + // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size, + // the number of bytes in each row can be computed. + // + if (Delta == 0) { + Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); + } + + WidthInBytes = Width * BytesPerPixel; + + for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) { + + Offset = ((DstY * FrameBufferInfo->PixelsPerScanLine) + DestinationX) * BytesPerPixel; + Destination = (UINT8 *) FrameBuffer + Offset; + + if (FrameBufferInfo->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) { + Source = (UINT8 *) BltBuffer + (SrcY * Delta); + } else { + for (X = 0; X < Width; X++) { + Blt = + (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ( + (UINT8 *) BltBuffer + + (SrcY * Delta) + + ((SourceX + X) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) + ); + Uint32 = *(UINT32*) Blt; + *(UINT32*) (mBltLibLineBuffer + (X * BytesPerPixel)) = + (((Uint32 << PixelShl[0]) >> PixelShr[0]) & PixelMask[0]) | + (((Uint32 << PixelShl[1]) >> PixelShr[1]) & PixelMask[1]) | + (((Uint32 << PixelShl[2]) >> PixelShr[2]) & PixelMask[2]) | + (((Uint32 << PixelShl[3]) >> PixelShr[3]) & PixelMask[3]); + } + Source = mBltLibLineBuffer; + } + + CopyMem (Destination, Source, WidthInBytes); + } + + return EFI_SUCCESS; +} + +/** + Performs a UEFI Graphics Output Protocol Blt Video to Video operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] SourceX X location within video + @param[in] SourceY Y location within video + @param[in] DestinationX X location within video + @param[in] DestinationY Y location within video + @param[in] Width Width (in pixels) + @param[in] Height Height + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoToVideo ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height + ) +{ + EFI_STATUS Status; + UINT8 *Source; + UINT8 *Destination; + UINTN Offset; + UINTN WidthInBytes; + INTN LineStride; + UINT8 BytesPerPixel; + + // + // Video to Video: Source is Video, destination is Video + // + Status = BltLibVerifyLocation (FrameBufferInfo, SourceX, SourceY, Width, Height); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = BltLibVerifyLocation (FrameBufferInfo, DestinationX, DestinationY, Width, Height); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = BltLibParsePixelFormat ( + FrameBufferInfo->PixelFormat, + &FrameBufferInfo->PixelInformation, + NULL, NULL, NULL, &BytesPerPixel + ); + if (EFI_ERROR (Status)) { + return Status; + } + + WidthInBytes = Width * BytesPerPixel; + + Offset = ((SourceY * FrameBufferInfo->PixelsPerScanLine) + SourceX) * BytesPerPixel; + Source = (UINT8 *) FrameBuffer + Offset; + + Offset = ((DestinationY * FrameBufferInfo->PixelsPerScanLine) + DestinationX) * BytesPerPixel; + Destination = (UINT8 *) FrameBuffer + Offset; + + LineStride = FrameBufferInfo->PixelsPerScanLine * BytesPerPixel; + if (Destination > Source) { + // + // Copy from last line to avoid source is corrupted by copying + // + Source += Height * LineStride; + Destination += Height * LineStride; + LineStride = -LineStride; + } + + while (Height-- > 0) { + CopyMem (Destination, Source, WidthInBytes); + + Source += LineStride; + Destination += LineStride; + } + + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf new file mode 100644 index 0000000..f9beae9 --- /dev/null +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf @@ -0,0 +1,33 @@ +## @file +# FrameBufferBltLib - Library to perform blt operations on a frame buffer. +# +# Copyright (c) 2006 - 2015, 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 +# 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 IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = FrameBufferBltLib + FILE_GUID = 2a40f516-c852-4baa-b7a8-0e9ea090d659 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = BltLib + +[Sources.common] + FrameBufferBltLib.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + +[Packages] + MdePkg/MdePkg.dec \ No newline at end of file diff --git a/MdeModulePkg/Library/GopBltLib/GopBltLib.c b/MdeModulePkg/Library/GopBltLib/GopBltLib.c new file mode 100644 index 0000000..486690f --- /dev/null +++ b/MdeModulePkg/Library/GopBltLib/GopBltLib.c @@ -0,0 +1,324 @@ +/** @file + GopBltLib - Library to perform blt using the UEFI Graphics Output Protocol. + + Copyright (c) 2007 - 2015, 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 + 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 IMPLIED. + +**/ + +#include <Uefi.h> + +#include <Protocol/GraphicsOutput.h> + +#include <Library/BaseLib.h> +#include <Library/BaseMemoryLib.h> +#include <Library/DebugLib.h> +#include <Library/MemoryAllocationLib.h> +#include <Library/UefiBootServicesTableLib.h> + +/** + Look for the GOP instance based on the FrameBuffer and the FrameBufferInfo. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + + @return The found GOP instance. +**/ +EFI_GRAPHICS_OUTPUT_PROTOCOL * +BltLibFindGopInstance ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; + + Gop = NULL; + + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiGraphicsOutputProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return NULL; + } + + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiGraphicsOutputProtocolGuid, + (VOID **) &Gop + ); + if (!EFI_ERROR (Status) && + (FrameBuffer == (VOID *) (UINTN) Gop->Mode->FrameBufferBase) && + (CompareMem (FrameBufferInfo, Gop->Mode->Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)) == 0) + ) { + break; + } + } + + FreePool (HandleBuffer); + + if (Index == HandleCount) { + return NULL; + } else { + return Gop; + } +} + +/** + Performs a UEFI Graphics Output Protocol Blt operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in,out] BltBuffer The data to transfer to screen + @param[in] BltOperation The operation to perform + @param[in] SourceX The X coordinate of the source for BltOperation + @param[in] SourceY The Y coordinate of the source for BltOperation + @param[in] DestinationX The X coordinate of the destination for BltOperation + @param[in] DestinationY The Y coordinate of the destination for BltOperation + @param[in] Width The width of a rectangle in the blt rectangle in pixels + @param[in] Height The height of a rectangle in the blt rectangle in pixels + @param[in] Delta Not used for EfiBltVideoFill and EfiBltVideoToVideo operation. + If a Delta of 0 is used, the entire BltBuffer will be operated on. + If a subrectangle of the BltBuffer is used, then Delta represents + the number of bytes in a row of the BltBuffer. + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +BltLibGopBltCommon ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL + IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta + ) +{ + EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; + + Gop = BltLibFindGopInstance (FrameBuffer, FrameBufferInfo); + if (Gop == NULL) { + return EFI_INVALID_PARAMETER; + } + + return Gop->Blt ( + Gop, + BltBuffer, + BltOperation, + SourceX, + SourceY, + DestinationX, + DestinationY, + Width, + Height, + Delta + ); +} + +/** + Performs a UEFI Graphics Output Protocol Blt Video Fill. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] Color Color to fill the region with + @param[in] DestinationX X location to start fill operation + @param[in] DestinationY Y location to start fill operation + @param[in] Width Width (in pixels) to fill + @param[in] Height Height to fill + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoFill ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height + ) +{ + return BltLibGopBltCommon ( + FrameBuffer, + FrameBufferInfo, + Color, + EfiBltVideoFill, + 0, + 0, + DestinationX, + DestinationY, + Width, + Height, + 0 + ); +} + +/** + Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[out] BltBuffer Output buffer for pixel color data + @param[in] SourceX X location within video + @param[in] SourceY Y location within video + @param[in] DestinationX X location within BltBuffer + @param[in] DestinationY Y location within BltBuffer + @param[in] Width Width (in pixels) + @param[in] Height Height + @param[in] Delta Number of bytes in a row of BltBuffer + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoToBuffer ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta + ) +{ + return BltLibGopBltCommon ( + FrameBuffer, + FrameBufferInfo, + BltBuffer, + EfiBltVideoToBltBuffer, + SourceX, + SourceY, + DestinationX, + DestinationY, + Width, + Height, + Delta + ); +} + +/** + Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] BltBuffer Output buffer for pixel color data + @param[in] SourceX X location within BltBuffer + @param[in] SourceY Y location within BltBuffer + @param[in] DestinationX X location within video + @param[in] DestinationY Y location within video + @param[in] Width Width (in pixels) + @param[in] Height Height + @param[in] Delta Number of bytes in a row of BltBuffer + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltBufferToVideo ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height, + IN UINTN Delta + ) +{ + return BltLibGopBltCommon ( + FrameBuffer, + FrameBufferInfo, + BltBuffer, + EfiBltBufferToVideo, + SourceX, + SourceY, + DestinationX, + DestinationY, + Width, + Height, + Delta + ); +} + +/** + Performs a UEFI Graphics Output Protocol Blt Video to Video operation. + + @param[in] FrameBuffer Pointer to the start of the frame buffer + @param[in] FrameBufferInfo Describes the frame buffer characteristics + @param[in] SourceX X location within video + @param[in] SourceY Y location within video + @param[in] DestinationX X location within video + @param[in] DestinationY Y location within video + @param[in] Width Width (in pixels) + @param[in] Height Height + + @retval EFI_DEVICE_ERROR A hardware error occured + @retval EFI_INVALID_PARAMETER Invalid parameter passed in + @retval EFI_SUCCESS Blt operation success + +**/ +EFI_STATUS +EFIAPI +BltVideoToVideo ( + IN VOID *FrameBuffer, + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, + IN UINTN SourceX, + IN UINTN SourceY, + IN UINTN DestinationX, + IN UINTN DestinationY, + IN UINTN Width, + IN UINTN Height + ) +{ + return BltLibGopBltCommon ( + FrameBuffer, + FrameBufferInfo, + NULL, + EfiBltVideoToVideo, + SourceX, + SourceY, + DestinationX, + DestinationY, + Width, + Height, + 0 + ); +} diff --git a/MdeModulePkg/Library/GopBltLib/GopBltLib.inf b/MdeModulePkg/Library/GopBltLib/GopBltLib.inf new file mode 100644 index 0000000..0d90474 --- /dev/null +++ b/MdeModulePkg/Library/GopBltLib/GopBltLib.inf @@ -0,0 +1,35 @@ +## @file +# GopBltLib - Library to perform blt using the UEFI Graphics Output Protocol. +# +# Copyright (c) 2006 - 2015, 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 +# 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 IMPLIED. +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = GopBltLib + FILE_GUID = b75b91f0-a0b4-42fe-ba62-849027999b39 + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = BltLib + +[Sources.common] + GopBltLib.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + UefiBootServicesTableLib + +[Packages] + MdePkg/MdePkg.dec \ No newline at end of file diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 9a3f2cd..f037067 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -123,6 +123,10 @@ # AuthVariableLib|Include/Library/AuthVariableLib.h + ## @libraryclass Provides video blt operations. + # + BltLib|Include/Library/BltLib.h + [Guids] ## MdeModule package token space guid # Include/Guid/MdeModulePkgTokenSpace.h diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 20edc08..e475dc1 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -80,6 +80,8 @@ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf PalLib|MdePkg/Library/BasePalLibNull/BasePalLibNull.inf CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf + BltLib|MdeModulePkg/Library/GopBltLib/GopBltLib.inf + BltLib|MdeModulePkg/Library/GopBltLib/FrameBufferBltLib.inf # # Misc # diff --git a/OptionRomPkg/Application/BltLibSample/BltLibSample.inf b/OptionRomPkg/Application/BltLibSample/BltLibSample.inf index a1334f8..66725c9 100644 --- a/OptionRomPkg/Application/BltLibSample/BltLibSample.inf +++ b/OptionRomPkg/Application/BltLibSample/BltLibSample.inf @@ -1,7 +1,7 @@ ## @file # Test the BltLib interface # -# Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2008 - 2015, 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 @@ -26,7 +26,7 @@ [Packages] MdePkg/MdePkg.dec - OptionRomPkg/OptionRomPkg.dec + MdeModulePkg/MdeModulePkg.dec [LibraryClasses] BltLib diff --git a/OptionRomPkg/Include/Library/BltLib.h b/OptionRomPkg/Include/Library/BltLib.h deleted file mode 100644 index 65ea9d4..0000000 --- a/OptionRomPkg/Include/Library/BltLib.h +++ /dev/null @@ -1,147 +0,0 @@ -/** @file - Library for performing video blt operations - - Copyright (c) 2009 - 2015, 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 - 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 IMPLIED. - -**/ - -#ifndef __BLT_LIB__ -#define __BLT_LIB__ - -#include <Protocol/GraphicsOutput.h> - -/** - Performs a UEFI Graphics Output Protocol Blt Video Fill. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] Color Color to fill the region with - @param[in] DestinationX X location to start fill operation - @param[in] DestinationY Y location to start fill operation - @param[in] Width Width (in pixels) to fill - @param[in] Height Height to fill - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoFill ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height - ); - -/** - Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[out] BltBuffer Output buffer for pixel color data - @param[in] SourceX X location within video - @param[in] SourceY Y location within video - @param[in] DestinationX X location within BltBuffer - @param[in] DestinationY Y location within BltBuffer - @param[in] Width Width (in pixels) - @param[in] Height Height - @param[in] Delta Number of bytes in a row of BltBuffer - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoToBuffer ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta - ); - -/** - Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] BltBuffer Output buffer for pixel color data - @param[in] SourceX X location within BltBuffer - @param[in] SourceY Y location within BltBuffer - @param[in] DestinationX X location within video - @param[in] DestinationY Y location within video - @param[in] Width Width (in pixels) - @param[in] Height Height - @param[in] Delta Number of bytes in a row of BltBuffer - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltBufferToVideo ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta - ); - -/** - Performs a UEFI Graphics Output Protocol Blt Video to Video operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] SourceX X location within video - @param[in] SourceY Y location within video - @param[in] DestinationX X location within video - @param[in] DestinationY Y location within video - @param[in] Width Width (in pixels) - @param[in] Height Height - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoToVideo ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height - ); - -#endif - diff --git a/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c deleted file mode 100644 index 977f852..0000000 --- a/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.c +++ /dev/null @@ -1,573 +0,0 @@ -/** @file - FrameBufferBltLib - Library to perform blt operations on a frame buffer. - - Copyright (c) 2007 - 2015, 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 - 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 IMPLIED. - -**/ - -#include <Uefi.h> -#include <Library/BaseLib.h> -#include <Library/BaseMemoryLib.h> -#include <Library/DebugLib.h> -#include <Protocol/GraphicsOutput.h> - -#if 0 -#define VDEBUG DEBUG -#else -#define VDEBUG(x) -#endif - -#define MAX_LINE_BUFFER_SIZE (SIZE_4KB * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) - -UINT8 mBltLibLineBuffer[MAX_LINE_BUFFER_SIZE]; -EFI_PIXEL_BITMASK mBltLibRgbPixelMasks = {0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}; -EFI_PIXEL_BITMASK mBltLibBgrPixelMasks = {0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}; - -EFI_STATUS -BltLibParsePixelFormat ( - IN EFI_GRAPHICS_PIXEL_FORMAT PixelFormat, - IN EFI_PIXEL_BITMASK *PixelInformation, - OUT UINT8 *PixelShl, - OUT UINT8 *PixelShr, - OUT UINT32 *PixelMask, - OUT UINT8 *BytesPerPixel - ) -{ - UINTN Index; - UINT32 MergedMasks; - UINT32 *Mask; - - switch (PixelFormat) { - case PixelRedGreenBlueReserved8BitPerColor: - return BltLibParsePixelFormat (PixelBitMask, &mBltLibRgbPixelMasks, PixelShl, PixelShr, PixelMask, BytesPerPixel); - - case PixelBlueGreenRedReserved8BitPerColor: - return BltLibParsePixelFormat (PixelBitMask, &mBltLibBgrPixelMasks, PixelShl, PixelShr, PixelMask, BytesPerPixel); - - case PixelBitMask: - break; - - default: - return EFI_INVALID_PARAMETER; - } - - MergedMasks = 0; - Mask = (UINT32 *) PixelInformation; - for (Index = 0; Index < 4; Index++) { - // - // Only ReservedMask can be 0 - // - if (Index != 3 && Mask[Index] == 0) { - return EFI_INVALID_PARAMETER; - } - // - // The Mask of each color shouldn't overlap - // - if ((MergedMasks & Mask[Index]) != 0) { - return EFI_INVALID_PARAMETER; - } - MergedMasks |= Mask[Index]; - - if (PixelShl != NULL && PixelShr != NULL) { - PixelShl[Index] = (UINT8) (HighBitSet32 (Mask[Index]) - 23 + (Index * 8)); - PixelShl[Index] %= 32; - if ((INT8) PixelShl[Index] < 0) { - PixelShr[Index] = -PixelShl[Index]; - PixelShl[Index] = 0; - } else { - PixelShr[Index] = 0; - } - VDEBUG ((EFI_D_INFO, "%d: shl:%d shr:%d mask:%x\n", Index, PixelShl[Index], PixelShr[Index], Mask[Index])); - } - } - if (PixelMask != NULL) { - CopyMem (PixelMask, PixelInformation, sizeof (EFI_PIXEL_BITMASK)); - } - - if (BytesPerPixel != NULL) { - *BytesPerPixel = (UINT8) ((HighBitSet32 (MergedMasks) + 7) / 8); - VDEBUG ((EFI_D_INFO, "Bytes per pixel: %d\n", *BytesPerPixel)); - } - - return EFI_SUCCESS; -} - -EFI_STATUS -BltLibVerifyLocation ( - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN UINTN X, - IN UINTN Y, - IN UINTN Width, - IN UINTN Height - ) -{ - if ((X >= FrameBufferInfo->HorizontalResolution) || - (Width > FrameBufferInfo->HorizontalResolution - X) - ) { - VDEBUG ((EFI_D_INFO, "VideoFill: Past screen (X)\n")); - return EFI_INVALID_PARAMETER; - } - - if ((Y >= FrameBufferInfo->VerticalResolution) || - (Height > FrameBufferInfo->VerticalResolution - Y) - ) { - VDEBUG ((EFI_D_INFO, "VideoFill: Past screen (Y)\n")); - return EFI_INVALID_PARAMETER; - } - - return EFI_SUCCESS; -} - -/** - Performs a UEFI Graphics Output Protocol Blt Video Fill. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] Color Color to fill the region with - @param[in] DestinationX X location to start fill operation - @param[in] DestinationY Y location to start fill operation - @param[in] Width Width (in pixels) to fill - @param[in] Height Height to fill - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoFill ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height - ) -{ - EFI_STATUS Status; - UINTN Y; - UINT8 *Destination; - UINTN X; - UINT8 Uint8; - UINT32 Uint32; - UINT64 WideFill; - BOOLEAN UseWideFill; - BOOLEAN LineBufferReady; - UINTN Offset; - UINTN WidthInBytes; - UINTN SizeInBytes; - UINT8 PixelShr[4]; - UINT8 PixelShl[4]; - UINT32 PixelMask[4]; - UINT8 BytesPerPixel; - - Status = BltLibVerifyLocation (FrameBufferInfo, DestinationX, DestinationY, Width, Height); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = BltLibParsePixelFormat ( - FrameBufferInfo->PixelFormat, - &FrameBufferInfo->PixelInformation, - PixelShr, PixelShl, PixelMask, &BytesPerPixel - ); - if (EFI_ERROR (Status)) { - return Status; - } - - WidthInBytes = Width * BytesPerPixel; - - Uint32 = *(UINT32 *) Color; - WideFill = (((Uint32 << PixelShl[0]) >> PixelShr[0]) & PixelMask[0]) | - (((Uint32 << PixelShl[1]) >> PixelShr[1]) & PixelMask[1]) | - (((Uint32 << PixelShl[2]) >> PixelShr[2]) & PixelMask[2]) | - (((Uint32 << PixelShl[3]) >> PixelShr[3]) & PixelMask[3]); - VDEBUG ((EFI_D_INFO, "VideoFill: color=0x%x, wide-fill=0x%x\n", Uint32, WideFill)); - - // - // If the size of the pixel data evenly divides the sizeof - // WideFill, then a wide fill operation can be used - // - UseWideFill = TRUE; - if (sizeof (WideFill) % BytesPerPixel == 0) { - for (X = BytesPerPixel; X < sizeof (WideFill); X++) { - ((UINT8 *) &WideFill)[X] = ((UINT8 *) &WideFill)[X % BytesPerPixel]; - } - } else { - // - // If all the bytes in the pixel are the same value, then use - // a wide fill operation. - // - for (X = 1, Uint8 = ((UINT8*) &WideFill)[0]; X < BytesPerPixel; X++) { - if (Uint8 != ((UINT8*) &WideFill)[X]) { - UseWideFill = FALSE; - break; - } - } - if (UseWideFill) { - SetMem (&WideFill, sizeof (WideFill), Uint8); - } - } - - if (UseWideFill && (DestinationX == 0) && (Width == FrameBufferInfo->HorizontalResolution)) { - VDEBUG ((EFI_D_INFO, "VideoFill (wide, one-shot)\n")); - Offset = DestinationY * FrameBufferInfo->PixelsPerScanLine * BytesPerPixel; - Destination = (UINT8 *) FrameBuffer + Offset; - SizeInBytes = WidthInBytes * Height; - if (SizeInBytes >= 8) { - SetMem64 (Destination, SizeInBytes & ~7, WideFill); - Destination += (SizeInBytes & ~7); - SizeInBytes &= 7; - } - if (SizeInBytes > 0) { - CopyMem (Destination, &WideFill, SizeInBytes); - } - } else { - LineBufferReady = FALSE; - for (Y = DestinationY; Y < (Height + DestinationY); Y++) { - Offset = ((Y * FrameBufferInfo->PixelsPerScanLine) + DestinationX) * BytesPerPixel; - Destination = (UINT8 *) FrameBuffer + Offset; - - if (UseWideFill && (((UINTN) Destination & 7) == 0)) { - VDEBUG ((EFI_D_INFO, "VideoFill (wide)\n")); - SizeInBytes = WidthInBytes; - if (SizeInBytes >= 8) { - SetMem64 (Destination, SizeInBytes & ~7, WideFill); - Destination += (SizeInBytes & ~7); - SizeInBytes &= 7; - } - if (SizeInBytes > 0) { - CopyMem (Destination, &WideFill, SizeInBytes); - } - } else { - VDEBUG ((EFI_D_INFO, "VideoFill (not wide)\n")); - if (!LineBufferReady) { - CopyMem (mBltLibLineBuffer, &WideFill, BytesPerPixel); - for (X = 1; X < Width; ) { - CopyMem ( - (mBltLibLineBuffer + (X * BytesPerPixel)), - mBltLibLineBuffer, - MIN (X, Width - X) * BytesPerPixel - ); - X += MIN (X, Width - X); - } - LineBufferReady = TRUE; - } - CopyMem (Destination, mBltLibLineBuffer, WidthInBytes); - } - } - } - - return EFI_SUCCESS; -} - -/** - Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[out] BltBuffer Output buffer for pixel color data - @param[in] SourceX X location within video - @param[in] SourceY Y location within video - @param[in] DestinationX X location within BltBuffer - @param[in] DestinationY Y location within BltBuffer - @param[in] Width Width (in pixels) - @param[in] Height Height - @param[in] Delta Number of bytes in a row of BltBuffer - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoToBuffer ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta - ) -{ - EFI_STATUS Status; - UINTN DstY; - UINTN SrcY; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; - UINT8 *Source; - UINT8 *Destination; - UINTN X; - UINT32 Uint32; - UINTN Offset; - UINTN WidthInBytes; - UINT8 PixelShr[4]; - UINT8 PixelShl[4]; - UINT32 PixelMask[4]; - UINT8 BytesPerPixel; - - // - // Video to BltBuffer: Source is Video, destination is BltBuffer - // - Status = BltLibVerifyLocation (FrameBufferInfo, SourceX, SourceY, Width, Height); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = BltLibParsePixelFormat ( - FrameBufferInfo->PixelFormat, - &FrameBufferInfo->PixelInformation, - PixelShl, PixelShr, PixelMask, &BytesPerPixel - ); - if (EFI_ERROR (Status)) { - return Status; - } - // - // If Delta is zero, then the entire BltBuffer is being used, so Delta - // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size, - // the number of bytes in each row can be computed. - // - if (Delta == 0) { - Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); - } - - WidthInBytes = Width * BytesPerPixel; - - // - // Video to BltBuffer: Source is Video, destination is BltBuffer - // - for (SrcY = SourceY, DstY = DestinationY; DstY < (DestinationY + Height); SrcY++, DstY++) { - - Offset = ((SrcY * FrameBufferInfo->PixelsPerScanLine) + SourceX) * BytesPerPixel; - Source = (UINT8 *) FrameBuffer + Offset; - - if (FrameBufferInfo->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) { - Destination = (UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - } else { - Destination = mBltLibLineBuffer; - } - - CopyMem (Destination, Source, WidthInBytes); - - if (FrameBufferInfo->PixelFormat != PixelBlueGreenRedReserved8BitPerColor) { - for (X = 0; X < Width; X++) { - Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ((UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX + X) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - Uint32 = * (UINT32 *) (mBltLibLineBuffer + (X * BytesPerPixel)); - *(UINT32*) Blt = (((Uint32 & PixelMask[0]) >> PixelShl[0]) << PixelShr[0]) | - (((Uint32 & PixelMask[1]) >> PixelShl[1]) << PixelShr[1]) | - (((Uint32 & PixelMask[2]) >> PixelShl[2]) << PixelShr[2]) | - (((Uint32 & PixelMask[3]) >> PixelShl[3]) << PixelShr[3]); - } - } - } - - return EFI_SUCCESS; -} - -/** - Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] BltBuffer Output buffer for pixel color data - @param[in] SourceX X location within BltBuffer - @param[in] SourceY Y location within BltBuffer - @param[in] DestinationX X location within video - @param[in] DestinationY Y location within video - @param[in] Width Width (in pixels) - @param[in] Height Height - @param[in] Delta Number of bytes in a row of BltBuffer - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltBufferToVideo ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta - ) -{ - EFI_STATUS Status; - UINTN DstY; - UINTN SrcY; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; - UINT8 *Source; - UINT8 *Destination; - UINTN X; - UINT32 Uint32; - UINTN Offset; - UINTN WidthInBytes; - UINT8 PixelShr[4]; - UINT8 PixelShl[4]; - UINT32 PixelMask[4]; - UINT8 BytesPerPixel; - - // - // BltBuffer to Video: Source is BltBuffer, destination is Video - // - Status = BltLibVerifyLocation (FrameBufferInfo, DestinationX, DestinationY, Width, Height); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = BltLibParsePixelFormat ( - FrameBufferInfo->PixelFormat, - &FrameBufferInfo->PixelInformation, - PixelShl, PixelShr, PixelMask, &BytesPerPixel - ); - if (EFI_ERROR (Status)) { - return Status; - } - // - // If Delta is zero, then the entire BltBuffer is being used, so Delta - // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size, - // the number of bytes in each row can be computed. - // - if (Delta == 0) { - Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); - } - - WidthInBytes = Width * BytesPerPixel; - - for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) { - - Offset = ((DstY * FrameBufferInfo->PixelsPerScanLine) + DestinationX) * BytesPerPixel; - Destination = (UINT8 *) FrameBuffer + Offset; - - if (FrameBufferInfo->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) { - Source = (UINT8 *) BltBuffer + (SrcY * Delta); - } else { - for (X = 0; X < Width; X++) { - Blt = - (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) ( - (UINT8 *) BltBuffer + - (SrcY * Delta) + - ((SourceX + X) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) - ); - Uint32 = *(UINT32*) Blt; - *(UINT32*) (mBltLibLineBuffer + (X * BytesPerPixel)) = - (((Uint32 << PixelShl[0]) >> PixelShr[0]) & PixelMask[0]) | - (((Uint32 << PixelShl[1]) >> PixelShr[1]) & PixelMask[1]) | - (((Uint32 << PixelShl[2]) >> PixelShr[2]) & PixelMask[2]) | - (((Uint32 << PixelShl[3]) >> PixelShr[3]) & PixelMask[3]); - } - Source = mBltLibLineBuffer; - } - - CopyMem (Destination, Source, WidthInBytes); - } - - return EFI_SUCCESS; -} - -/** - Performs a UEFI Graphics Output Protocol Blt Video to Video operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] SourceX X location within video - @param[in] SourceY Y location within video - @param[in] DestinationX X location within video - @param[in] DestinationY Y location within video - @param[in] Width Width (in pixels) - @param[in] Height Height - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoToVideo ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height - ) -{ - EFI_STATUS Status; - UINT8 *Source; - UINT8 *Destination; - UINTN Offset; - UINTN WidthInBytes; - INTN LineStride; - UINT8 BytesPerPixel; - - // - // Video to Video: Source is Video, destination is Video - // - Status = BltLibVerifyLocation (FrameBufferInfo, SourceX, SourceY, Width, Height); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = BltLibVerifyLocation (FrameBufferInfo, DestinationX, DestinationY, Width, Height); - if (EFI_ERROR (Status)) { - return Status; - } - - Status = BltLibParsePixelFormat ( - FrameBufferInfo->PixelFormat, - &FrameBufferInfo->PixelInformation, - NULL, NULL, NULL, &BytesPerPixel - ); - if (EFI_ERROR (Status)) { - return Status; - } - - WidthInBytes = Width * BytesPerPixel; - - Offset = ((SourceY * FrameBufferInfo->PixelsPerScanLine) + SourceX) * BytesPerPixel; - Source = (UINT8 *) FrameBuffer + Offset; - - Offset = ((DestinationY * FrameBufferInfo->PixelsPerScanLine) + DestinationX) * BytesPerPixel; - Destination = (UINT8 *) FrameBuffer + Offset; - - LineStride = FrameBufferInfo->PixelsPerScanLine * BytesPerPixel; - if (Destination > Source) { - // - // Copy from last line to avoid source is corrupted by copying - // - Source += Height * LineStride; - Destination += Height * LineStride; - LineStride = -LineStride; - } - - while (Height-- > 0) { - CopyMem (Destination, Source, WidthInBytes); - - Source += LineStride; - Destination += LineStride; - } - - return EFI_SUCCESS; -} diff --git a/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf b/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf deleted file mode 100644 index b94b52a..0000000 --- a/OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf +++ /dev/null @@ -1,35 +0,0 @@ -## @file -# FrameBufferBltLib - Library to perform blt operations on a frame buffer. -# -# Copyright (c) 2006 - 2011, 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 -# 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 IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = FrameBufferBltLib - FILE_GUID = 2a40f516-c852-4baa-b7a8-0e9ea090d659 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = BltLib - -[Sources.common] - FrameBufferBltLib.c - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - -[Packages] - MdePkg/MdePkg.dec - OptionRomPkg/OptionRomPkg.dec - diff --git a/OptionRomPkg/Library/GopBltLib/GopBltLib.c b/OptionRomPkg/Library/GopBltLib/GopBltLib.c deleted file mode 100644 index 486690f..0000000 --- a/OptionRomPkg/Library/GopBltLib/GopBltLib.c +++ /dev/null @@ -1,324 +0,0 @@ -/** @file - GopBltLib - Library to perform blt using the UEFI Graphics Output Protocol. - - Copyright (c) 2007 - 2015, 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 - 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 IMPLIED. - -**/ - -#include <Uefi.h> - -#include <Protocol/GraphicsOutput.h> - -#include <Library/BaseLib.h> -#include <Library/BaseMemoryLib.h> -#include <Library/DebugLib.h> -#include <Library/MemoryAllocationLib.h> -#include <Library/UefiBootServicesTableLib.h> - -/** - Look for the GOP instance based on the FrameBuffer and the FrameBufferInfo. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - - @return The found GOP instance. -**/ -EFI_GRAPHICS_OUTPUT_PROTOCOL * -BltLibFindGopInstance ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo - ) -{ - EFI_STATUS Status; - EFI_HANDLE *HandleBuffer; - UINTN HandleCount; - UINTN Index; - EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; - - Gop = NULL; - - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiGraphicsOutputProtocolGuid, - NULL, - &HandleCount, - &HandleBuffer - ); - if (EFI_ERROR (Status)) { - return NULL; - } - - for (Index = 0; Index < HandleCount; Index++) { - Status = gBS->HandleProtocol ( - HandleBuffer[Index], - &gEfiGraphicsOutputProtocolGuid, - (VOID **) &Gop - ); - if (!EFI_ERROR (Status) && - (FrameBuffer == (VOID *) (UINTN) Gop->Mode->FrameBufferBase) && - (CompareMem (FrameBufferInfo, Gop->Mode->Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)) == 0) - ) { - break; - } - } - - FreePool (HandleBuffer); - - if (Index == HandleCount) { - return NULL; - } else { - return Gop; - } -} - -/** - Performs a UEFI Graphics Output Protocol Blt operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in,out] BltBuffer The data to transfer to screen - @param[in] BltOperation The operation to perform - @param[in] SourceX The X coordinate of the source for BltOperation - @param[in] SourceY The Y coordinate of the source for BltOperation - @param[in] DestinationX The X coordinate of the destination for BltOperation - @param[in] DestinationY The Y coordinate of the destination for BltOperation - @param[in] Width The width of a rectangle in the blt rectangle in pixels - @param[in] Height The height of a rectangle in the blt rectangle in pixels - @param[in] Delta Not used for EfiBltVideoFill and EfiBltVideoToVideo operation. - If a Delta of 0 is used, the entire BltBuffer will be operated on. - If a subrectangle of the BltBuffer is used, then Delta represents - the number of bytes in a row of the BltBuffer. - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -BltLibGopBltCommon ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL - IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta - ) -{ - EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop; - - Gop = BltLibFindGopInstance (FrameBuffer, FrameBufferInfo); - if (Gop == NULL) { - return EFI_INVALID_PARAMETER; - } - - return Gop->Blt ( - Gop, - BltBuffer, - BltOperation, - SourceX, - SourceY, - DestinationX, - DestinationY, - Width, - Height, - Delta - ); -} - -/** - Performs a UEFI Graphics Output Protocol Blt Video Fill. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] Color Color to fill the region with - @param[in] DestinationX X location to start fill operation - @param[in] DestinationY Y location to start fill operation - @param[in] Width Width (in pixels) to fill - @param[in] Height Height to fill - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoFill ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height - ) -{ - return BltLibGopBltCommon ( - FrameBuffer, - FrameBufferInfo, - Color, - EfiBltVideoFill, - 0, - 0, - DestinationX, - DestinationY, - Width, - Height, - 0 - ); -} - -/** - Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[out] BltBuffer Output buffer for pixel color data - @param[in] SourceX X location within video - @param[in] SourceY Y location within video - @param[in] DestinationX X location within BltBuffer - @param[in] DestinationY Y location within BltBuffer - @param[in] Width Width (in pixels) - @param[in] Height Height - @param[in] Delta Number of bytes in a row of BltBuffer - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoToBuffer ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta - ) -{ - return BltLibGopBltCommon ( - FrameBuffer, - FrameBufferInfo, - BltBuffer, - EfiBltVideoToBltBuffer, - SourceX, - SourceY, - DestinationX, - DestinationY, - Width, - Height, - Delta - ); -} - -/** - Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] BltBuffer Output buffer for pixel color data - @param[in] SourceX X location within BltBuffer - @param[in] SourceY Y location within BltBuffer - @param[in] DestinationX X location within video - @param[in] DestinationY Y location within video - @param[in] Width Width (in pixels) - @param[in] Height Height - @param[in] Delta Number of bytes in a row of BltBuffer - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltBufferToVideo ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height, - IN UINTN Delta - ) -{ - return BltLibGopBltCommon ( - FrameBuffer, - FrameBufferInfo, - BltBuffer, - EfiBltBufferToVideo, - SourceX, - SourceY, - DestinationX, - DestinationY, - Width, - Height, - Delta - ); -} - -/** - Performs a UEFI Graphics Output Protocol Blt Video to Video operation. - - @param[in] FrameBuffer Pointer to the start of the frame buffer - @param[in] FrameBufferInfo Describes the frame buffer characteristics - @param[in] SourceX X location within video - @param[in] SourceY Y location within video - @param[in] DestinationX X location within video - @param[in] DestinationY Y location within video - @param[in] Width Width (in pixels) - @param[in] Height Height - - @retval EFI_DEVICE_ERROR A hardware error occured - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BltVideoToVideo ( - IN VOID *FrameBuffer, - IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo, - IN UINTN SourceX, - IN UINTN SourceY, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN Width, - IN UINTN Height - ) -{ - return BltLibGopBltCommon ( - FrameBuffer, - FrameBufferInfo, - NULL, - EfiBltVideoToVideo, - SourceX, - SourceY, - DestinationX, - DestinationY, - Width, - Height, - 0 - ); -} diff --git a/OptionRomPkg/Library/GopBltLib/GopBltLib.inf b/OptionRomPkg/Library/GopBltLib/GopBltLib.inf deleted file mode 100644 index 8a09696..0000000 --- a/OptionRomPkg/Library/GopBltLib/GopBltLib.inf +++ /dev/null @@ -1,37 +0,0 @@ -## @file -# GopBltLib - Library to perform blt using the UEFI Graphics Output Protocol. -# -# Copyright (c) 2006 - 2011, 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 -# 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 IMPLIED. -# -## - -[Defines] - INF_VERSION = 0x00010005 - BASE_NAME = GopBltLib - FILE_GUID = b75b91f0-a0b4-42fe-ba62-849027999b39 - MODULE_TYPE = BASE - VERSION_STRING = 1.0 - LIBRARY_CLASS = BltLib - -[Sources.common] - GopBltLib.c - -[LibraryClasses] - BaseLib - BaseMemoryLib - DebugLib - MemoryAllocationLib - UefiBootServicesTableLib - -[Packages] - MdePkg/MdePkg.dec - OptionRomPkg/OptionRomPkg.dec - diff --git a/OptionRomPkg/OptionRomPkg.dsc b/OptionRomPkg/OptionRomPkg.dsc index 03592f8..2e3f5ee 100644 --- a/OptionRomPkg/OptionRomPkg.dsc +++ b/OptionRomPkg/OptionRomPkg.dsc @@ -6,7 +6,7 @@ # Option ROM image for all CPU architectures, including EBC target. # A single driver can support mixes of EFI 1.1, UEFI 2.0 and UEFI 2.1. # -# Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2007 - 2015, 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 @@ -47,7 +47,7 @@ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf BaseLib|MdePkg/Library/BaseLib/BaseLib.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf - BltLib|OptionRomPkg/Library/GopBltLib/GopBltLib.inf + BltLib|MdeModulePkg/Library/GopBltLib/GopBltLib.inf PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf @@ -98,9 +98,6 @@ ################################################################################################### [Components] - OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf - OptionRomPkg/Library/GopBltLib/GopBltLib.inf - OptionRomPkg/AtapiPassThruDxe/AtapiPassThruDxe.inf OptionRomPkg/CirrusLogic5430Dxe/CirrusLogic5430Dxe.inf OptionRomPkg/UndiRuntimeDxe/UndiRuntimeDxe.inf diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 4ab618d..7cf6943 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -491,7 +491,7 @@ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { <LibraryClasses> - BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf + BltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf } # diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 90ca42a..f181c67 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -498,7 +498,7 @@ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { <LibraryClasses> - BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf + BltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf } # diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index b72eaa9..7b6bd9d 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -496,7 +496,7 @@ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf { <LibraryClasses> - BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf + BltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf } # diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf index ce1ff93..178db11 100644 --- a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf +++ b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf @@ -2,7 +2,7 @@ # This driver is a sample implementation of the Graphics Output Protocol for # the QEMU (Cirrus Logic 5446) video controller. # -# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2006 - 2015, 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 @@ -44,6 +44,7 @@ [Packages] MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec OptionRomPkg/OptionRomPkg.dec OvmfPkg/OvmfPkg.dec -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel