+++ /dev/null
-/** @file\r
- GopBltLib - Library to perform blt using the UEFI Graphics Output Protocol.\r
-\r
- Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "PiDxe.h"\r
-\r
-#include <Protocol/GraphicsOutput.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/BltLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-EFI_GRAPHICS_OUTPUT_PROTOCOL *mGop = NULL;\r
-\r
-\r
-/**\r
- Configure the FrameBufferLib instance\r
-\r
- @param[in] FrameBuffer Pointer to the start of the frame buffer\r
- @param[in] FrameBufferInfo Describes the frame buffer characteristics\r
-\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter\r
- @retval EFI_UNSUPPORTED - The BltLib does not support this configuration\r
- @retval EFI_SUCCESS - Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibConfigure (\r
- IN VOID *FrameBuffer,\r
- IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_HANDLE *HandleBuffer;\r
- UINTN HandleCount;\r
- UINTN Index;\r
- EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;\r
-\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiGraphicsOutputProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuffer\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (\r
- HandleBuffer[Index],\r
- &gEfiGraphicsOutputProtocolGuid,\r
- (VOID*) &Gop\r
- );\r
- if (!EFI_ERROR (Status) &&\r
- (FrameBuffer == (VOID*)(UINTN) Gop->Mode->FrameBufferBase)) {\r
- mGop = Gop;\r
- FreePool (HandleBuffer);\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- FreePool (HandleBuffer);\r
- }\r
-\r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-/**\r
- Performs a UEFI Graphics Output Protocol Blt operation.\r
-\r
- @param[in,out] BltBuffer - The data to transfer to screen\r
- @param[in] BltOperation - The operation to perform\r
- @param[in] SourceX - The X coordinate of the source for BltOperation\r
- @param[in] SourceY - The Y coordinate of the source for BltOperation\r
- @param[in] DestinationX - The X coordinate of the destination for BltOperation\r
- @param[in] DestinationY - The Y coordinate of the destination for BltOperation\r
- @param[in] Width - The width of a rectangle in the blt rectangle in pixels\r
- @param[in] Height - The height of a rectangle in the blt rectangle in pixels\r
- @param[in] Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
- If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
- If a subrectangle of the BltBuffer is used, then Delta represents\r
- the number of bytes in a row of the BltBuffer.\r
-\r
- @retval EFI_DEVICE_ERROR - A hardware error occured\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-InternalGopBltCommon (\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
- IN UINTN SourceX,\r
- IN UINTN SourceY,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height,\r
- IN UINTN Delta\r
- )\r
-{\r
- if (mGop == NULL) {\r
- return EFI_DEVICE_ERROR;\r
- }\r
-\r
- return mGop->Blt (\r
- mGop,\r
- BltBuffer,\r
- BltOperation,\r
- SourceX,\r
- SourceY,\r
- DestinationX,\r
- DestinationY,\r
- Width,\r
- Height,\r
- Delta\r
- );\r
-}\r
-\r
-\r
-/**\r
- Performs a UEFI Graphics Output Protocol Blt operation.\r
-\r
- @param[in,out] BltBuffer - The data to transfer to screen\r
- @param[in] BltOperation - The operation to perform\r
- @param[in] SourceX - The X coordinate of the source for BltOperation\r
- @param[in] SourceY - The Y coordinate of the source for BltOperation\r
- @param[in] DestinationX - The X coordinate of the destination for BltOperation\r
- @param[in] DestinationY - The Y coordinate of the destination for BltOperation\r
- @param[in] Width - The width of a rectangle in the blt rectangle in pixels\r
- @param[in] Height - The height of a rectangle in the blt rectangle in pixels\r
- @param[in] Delta - Not used for EfiBltVideoFill and EfiBltVideoToVideo operation.\r
- If a Delta of 0 is used, the entire BltBuffer will be operated on.\r
- If a subrectangle of the BltBuffer is used, then Delta represents\r
- the number of bytes in a row of the BltBuffer.\r
-\r
- @retval EFI_DEVICE_ERROR - A hardware error occured\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - Blt operation success\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibGopBlt (\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
- IN UINTN SourceX,\r
- IN UINTN SourceY,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height,\r
- IN UINTN Delta\r
- )\r
-{\r
- return InternalGopBltCommon (\r
- BltBuffer,\r
- BltOperation,\r
- SourceX,\r
- SourceY,\r
- DestinationX,\r
- DestinationY,\r
- Width,\r
- Height,\r
- Delta\r
- );\r
-}\r
-\r
-\r
-/**\r
- Performs a UEFI Graphics Output Protocol Blt Video Fill.\r
-\r
- @param[in] Color Color to fill the region with\r
- @param[in] DestinationX X location to start fill operation\r
- @param[in] DestinationY Y location to start fill operation\r
- @param[in] Width Width (in pixels) to fill\r
- @param[in] Height Height to fill\r
-\r
- @retval EFI_DEVICE_ERROR - A hardware error occured\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - The sizes were returned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibVideoFill (\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height\r
- )\r
-{\r
- return InternalGopBltCommon (\r
- Color,\r
- EfiBltVideoFill,\r
- 0,\r
- 0,\r
- DestinationX,\r
- DestinationY,\r
- Width,\r
- Height,\r
- 0\r
- );\r
-}\r
-\r
-\r
-/**\r
- Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation.\r
-\r
- @param[out] BltBuffer Output buffer for pixel color data\r
- @param[in] SourceX X location within video\r
- @param[in] SourceY Y location within video\r
- @param[in] Width Width (in pixels)\r
- @param[in] Height Height\r
-\r
- @retval EFI_DEVICE_ERROR - A hardware error occured\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - The sizes were returned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibVideoToBltBuffer (\r
- OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,\r
- IN UINTN SourceX,\r
- IN UINTN SourceY,\r
- IN UINTN Width,\r
- IN UINTN Height\r
- )\r
-{\r
- return InternalGopBltCommon (\r
- BltBuffer,\r
- EfiBltVideoToBltBuffer,\r
- SourceX,\r
- SourceY,\r
- 0,\r
- 0,\r
- Width,\r
- Height,\r
- 0\r
- );\r
-}\r
-\r
-\r
-/**\r
- Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation\r
- with extended parameters.\r
-\r
- @param[out] BltBuffer Output buffer for pixel color data\r
- @param[in] SourceX X location within video\r
- @param[in] SourceY Y location within video\r
- @param[in] DestinationX X location within BltBuffer\r
- @param[in] DestinationY Y location within BltBuffer\r
- @param[in] Width Width (in pixels)\r
- @param[in] Height Height\r
- @param[in] Delta Number of bytes in a row of BltBuffer\r
-\r
- @retval EFI_DEVICE_ERROR - A hardware error occured\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - The sizes were returned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibVideoToBltBufferEx (\r
- OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,\r
- IN UINTN SourceX,\r
- IN UINTN SourceY,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height,\r
- IN UINTN Delta\r
- )\r
-{\r
- return InternalGopBltCommon (\r
- BltBuffer,\r
- EfiBltVideoToBltBuffer,\r
- SourceX,\r
- SourceY,\r
- DestinationX,\r
- DestinationY,\r
- Width,\r
- Height,\r
- Delta\r
- );\r
-}\r
-\r
-\r
-/**\r
- Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation.\r
-\r
- @param[in] BltBuffer Output buffer for pixel color data\r
- @param[in] DestinationX X location within video\r
- @param[in] DestinationY Y location within video\r
- @param[in] Width Width (in pixels)\r
- @param[in] Height Height\r
-\r
- @retval EFI_DEVICE_ERROR - A hardware error occured\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - The sizes were returned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibBufferToVideo (\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height\r
- )\r
-{\r
- return InternalGopBltCommon (\r
- BltBuffer,\r
- EfiBltBufferToVideo,\r
- 0,\r
- 0,\r
- DestinationX,\r
- DestinationY,\r
- Width,\r
- Height,\r
- 0\r
- );\r
-}\r
-\r
-\r
-/**\r
- Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation\r
- with extended parameters.\r
-\r
- @param[in] BltBuffer Output buffer for pixel color data\r
- @param[in] SourceX X location within BltBuffer\r
- @param[in] SourceY Y location within BltBuffer\r
- @param[in] DestinationX X location within video\r
- @param[in] DestinationY Y location within video\r
- @param[in] Width Width (in pixels)\r
- @param[in] Height Height\r
- @param[in] Delta Number of bytes in a row of BltBuffer\r
-\r
- @retval EFI_DEVICE_ERROR - A hardware error occured\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - The sizes were returned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibBufferToVideoEx (\r
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,\r
- IN UINTN SourceX,\r
- IN UINTN SourceY,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height,\r
- IN UINTN Delta\r
- )\r
-{\r
- return InternalGopBltCommon (\r
- BltBuffer,\r
- EfiBltBufferToVideo,\r
- SourceX,\r
- SourceY,\r
- DestinationX,\r
- DestinationY,\r
- Width,\r
- Height,\r
- Delta\r
- );\r
-}\r
-\r
-\r
-/**\r
- Performs a UEFI Graphics Output Protocol Blt Video to Video operation\r
-\r
- @param[in] SourceX X location within video\r
- @param[in] SourceY Y location within video\r
- @param[in] DestinationX X location within video\r
- @param[in] DestinationY Y location within video\r
- @param[in] Width Width (in pixels)\r
- @param[in] Height Height\r
-\r
- @retval EFI_DEVICE_ERROR - A hardware error occured\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - The sizes were returned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibVideoToVideo (\r
- IN UINTN SourceX,\r
- IN UINTN SourceY,\r
- IN UINTN DestinationX,\r
- IN UINTN DestinationY,\r
- IN UINTN Width,\r
- IN UINTN Height\r
- )\r
-{\r
- return InternalGopBltCommon (\r
- NULL,\r
- EfiBltVideoToVideo,\r
- SourceX,\r
- SourceY,\r
- DestinationX,\r
- DestinationY,\r
- Width,\r
- Height,\r
- 0\r
- );\r
-}\r
-\r
-/**\r
- Returns the sizes related to the video device\r
-\r
- @param[out] Width Width (in pixels)\r
- @param[out] Height Height (in pixels)\r
-\r
- @retval EFI_INVALID_PARAMETER - Invalid parameter passed in\r
- @retval EFI_SUCCESS - The sizes were returned\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BltLibGetSizes (\r
- OUT UINTN *Width, OPTIONAL\r
- OUT UINTN *Height OPTIONAL\r
- )\r
-{\r
- ASSERT (mGop != NULL);\r
-\r
- if (Width != NULL) {\r
- *Width = mGop->Mode->Info->HorizontalResolution;\r
- }\r
- if (Height != NULL) {\r
- *Height = mGop->Mode->Info->VerticalResolution;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r