* [PATCH v2 1/5] MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo HOB GUID and structure
2016-10-09 8:49 [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe Ruiyu Ni
@ 2016-10-09 8:49 ` Ruiyu Ni
2016-10-10 2:34 ` [PATCH v3 " Ruiyu Ni
2016-10-09 8:49 ` [PATCH v2 2/5] MdeModulePkg: Add FrameBufferBltLib library class Ruiyu Ni
` (4 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Ruiyu Ni @ 2016-10-09 8:49 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
MdePkg/Include/Guid/GraphicsInfoHob.h | 17 ++++++++++++++++-
MdePkg/MdePkg.dec | 1 +
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/MdePkg/Include/Guid/GraphicsInfoHob.h b/MdePkg/Include/Guid/GraphicsInfoHob.h
index 3bcead0..b807213 100644
--- a/MdePkg/Include/Guid/GraphicsInfoHob.h
+++ b/MdePkg/Include/Guid/GraphicsInfoHob.h
@@ -1,7 +1,7 @@
/** @file
Hob guid for Information about the graphics mode.
- Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2016, 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
@@ -25,12 +25,27 @@
0x39f62cce, 0x6825, 0x4669, { 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 } \
}
+#define EFI_PEI_GRAPHICS_DEVICE_INFO_HOB_GUID \
+ { \
+ 0xe5cb2ac9, 0xd35d, 0x4430, { 0x93, 0x6e, 0x1d, 0xe3, 0x32, 0x47, 0x8d, 0xe7 } \
+ }
+
typedef struct {
EFI_PHYSICAL_ADDRESS FrameBufferBase;
UINT32 FrameBufferSize;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION GraphicsMode;
} EFI_PEI_GRAPHICS_INFO_HOB;
+typedef struct {
+ UINT16 VendorId; ///< Ignore if the value is 0xFFFF.
+ UINT16 DeviceId; ///< Ignore if the value is 0xFFFF.
+ UINT16 SubsystemVendorId; ///< Ignore if the value is 0xFFFF.
+ UINT16 SubsystemId; ///< Ignore if the value is 0xFFFF.
+ UINT8 RevisionId; ///< Ignore if the value is 0xFF.
+ UINT8 BarIndex; ///< Ignore if the value is 0xFF.
+} EFI_PEI_GRAPHICS_DEVICE_INFO_HOB;
+
extern EFI_GUID gEfiGraphicsInfoHobGuid;
+extern EFI_GUID gEfiGraphicsDeviceInfoHobGuid;
#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 606e2f1..60ba2ca 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -727,6 +727,7 @@ [Guids]
#
## Include/Guid/GraphicsInfoHob.h
gEfiGraphicsInfoHobGuid = { 0x39f62cce, 0x6825, 0x4669, { 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 }}
+ gEfiGraphicsDeviceInfoHobGuid = { 0xe5cb2ac9, 0xd35d, 0x4430, { 0x93, 0x6e, 0x1d, 0xe3, 0x32, 0x47, 0x8d, 0xe7 }}
## Guid for EFI_DISK_INFO_PROTOCOL.Interface to specify UFS interface.
## Include/Protocol/DiskInfo.h
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 1/5] MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo HOB GUID and structure
2016-10-09 8:49 ` [PATCH v2 1/5] MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo HOB GUID and structure Ruiyu Ni
@ 2016-10-10 2:34 ` Ruiyu Ni
2016-10-10 2:35 ` Ni, Ruiyu
2016-10-11 5:45 ` Gao, Liming
0 siblings, 2 replies; 12+ messages in thread
From: Ruiyu Ni @ 2016-10-10 2:34 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
MdePkg/Include/Guid/GraphicsInfoHob.h | 17 ++++++++++++++++-
MdePkg/MdePkg.dec | 6 ++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/MdePkg/Include/Guid/GraphicsInfoHob.h b/MdePkg/Include/Guid/GraphicsInfoHob.h
index 3bcead0..b807213 100644
--- a/MdePkg/Include/Guid/GraphicsInfoHob.h
+++ b/MdePkg/Include/Guid/GraphicsInfoHob.h
@@ -1,7 +1,7 @@
/** @file
Hob guid for Information about the graphics mode.
- Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2016, 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
@@ -25,12 +25,27 @@
0x39f62cce, 0x6825, 0x4669, { 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 } \
}
+#define EFI_PEI_GRAPHICS_DEVICE_INFO_HOB_GUID \
+ { \
+ 0xe5cb2ac9, 0xd35d, 0x4430, { 0x93, 0x6e, 0x1d, 0xe3, 0x32, 0x47, 0x8d, 0xe7 } \
+ }
+
typedef struct {
EFI_PHYSICAL_ADDRESS FrameBufferBase;
UINT32 FrameBufferSize;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION GraphicsMode;
} EFI_PEI_GRAPHICS_INFO_HOB;
+typedef struct {
+ UINT16 VendorId; ///< Ignore if the value is 0xFFFF.
+ UINT16 DeviceId; ///< Ignore if the value is 0xFFFF.
+ UINT16 SubsystemVendorId; ///< Ignore if the value is 0xFFFF.
+ UINT16 SubsystemId; ///< Ignore if the value is 0xFFFF.
+ UINT8 RevisionId; ///< Ignore if the value is 0xFF.
+ UINT8 BarIndex; ///< Ignore if the value is 0xFF.
+} EFI_PEI_GRAPHICS_DEVICE_INFO_HOB;
+
extern EFI_GUID gEfiGraphicsInfoHobGuid;
+extern EFI_GUID gEfiGraphicsDeviceInfoHobGuid;
#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 606e2f1..f1e5151 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -733,6 +733,12 @@ [Guids]
gEfiDiskInfoUfsInterfaceGuid = { 0x4b3029cc, 0x6b98, 0x47fb, { 0xbc, 0x96, 0x76, 0xdc, 0xb8, 0x4, 0x41, 0xf0 }}
#
+ # GUID defined in PI1.5
+ #
+ ## Include/Guid/GraphicsInfoHob.h
+ gEfiGraphicsDeviceInfoHobGuid = { 0xe5cb2ac9, 0xd35d, 0x4430, { 0x93, 0x6e, 0x1d, 0xe3, 0x32, 0x47, 0x8d, 0xe7 }}
+
+ #
# GUID defined in Windows UEFI Firmware Update Platform doc
#
## Include/IndustryStandard/WindowsUxCapsule.h
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/5] MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo HOB GUID and structure
2016-10-10 2:34 ` [PATCH v3 " Ruiyu Ni
@ 2016-10-10 2:35 ` Ni, Ruiyu
2016-10-11 5:45 ` Gao, Liming
1 sibling, 0 replies; 12+ messages in thread
From: Ni, Ruiyu @ 2016-10-10 2:35 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Gao, Liming
V3 of 1/5 adds "# GUID defined in PI1.5" comments to MdePkg.dec.
Thanks/Ray
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Monday, October 10, 2016 10:35 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH v3 1/5] MdePkg/GraphicsInfoHob: Add
> GraphicsDeviceInfo HOB GUID and structure
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> ---
> MdePkg/Include/Guid/GraphicsInfoHob.h | 17 ++++++++++++++++-
> MdePkg/MdePkg.dec | 6 ++++++
> 2 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/MdePkg/Include/Guid/GraphicsInfoHob.h
> b/MdePkg/Include/Guid/GraphicsInfoHob.h
> index 3bcead0..b807213 100644
> --- a/MdePkg/Include/Guid/GraphicsInfoHob.h
> +++ b/MdePkg/Include/Guid/GraphicsInfoHob.h
> @@ -1,7 +1,7 @@
> /** @file
> Hob guid for Information about the graphics mode.
>
> - Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2016, 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 @@ -25,12 +25,27 @@
> 0x39f62cce, 0x6825, 0x4669, { 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a,
> 0x07 } \
> }
>
> +#define EFI_PEI_GRAPHICS_DEVICE_INFO_HOB_GUID \
> + { \
> + 0xe5cb2ac9, 0xd35d, 0x4430, { 0x93, 0x6e, 0x1d, 0xe3, 0x32, 0x47,
> +0x8d, 0xe7 } \
> + }
> +
> typedef struct {
> EFI_PHYSICAL_ADDRESS FrameBufferBase;
> UINT32 FrameBufferSize;
> EFI_GRAPHICS_OUTPUT_MODE_INFORMATION GraphicsMode; }
> EFI_PEI_GRAPHICS_INFO_HOB;
>
> +typedef struct {
> + UINT16 VendorId; ///< Ignore if the value is 0xFFFF.
> + UINT16 DeviceId; ///< Ignore if the value is 0xFFFF.
> + UINT16 SubsystemVendorId; ///< Ignore if the value is
> 0xFFFF.
> + UINT16 SubsystemId; ///< Ignore if the value is 0xFFFF.
> + UINT8 RevisionId; ///< Ignore if the value is 0xFF.
> + UINT8 BarIndex; ///< Ignore if the value is 0xFF.
> +} EFI_PEI_GRAPHICS_DEVICE_INFO_HOB;
> +
> extern EFI_GUID gEfiGraphicsInfoHobGuid;
> +extern EFI_GUID gEfiGraphicsDeviceInfoHobGuid;
>
> #endif
> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index
> 606e2f1..f1e5151 100644
> --- a/MdePkg/MdePkg.dec
> +++ b/MdePkg/MdePkg.dec
> @@ -733,6 +733,12 @@ [Guids]
> gEfiDiskInfoUfsInterfaceGuid = { 0x4b3029cc, 0x6b98, 0x47fb, { 0xbc, 0x96,
> 0x76, 0xdc, 0xb8, 0x4, 0x41, 0xf0 }}
>
> #
> + # GUID defined in PI1.5
> + #
> + ## Include/Guid/GraphicsInfoHob.h
> + gEfiGraphicsDeviceInfoHobGuid = { 0xe5cb2ac9, 0xd35d, 0x4430, { 0x93,
> 0x6e, 0x1d, 0xe3, 0x32, 0x47, 0x8d, 0xe7 }}
> +
> + #
> # GUID defined in Windows UEFI Firmware Update Platform doc
> #
> ## Include/IndustryStandard/WindowsUxCapsule.h
> --
> 2.9.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3 1/5] MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo HOB GUID and structure
2016-10-10 2:34 ` [PATCH v3 " Ruiyu Ni
2016-10-10 2:35 ` Ni, Ruiyu
@ 2016-10-11 5:45 ` Gao, Liming
1 sibling, 0 replies; 12+ messages in thread
From: Gao, Liming @ 2016-10-11 5:45 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Monday, October 10, 2016 10:35 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [PATCH v3 1/5] MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo
> HOB GUID and structure
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> ---
> MdePkg/Include/Guid/GraphicsInfoHob.h | 17 ++++++++++++++++-
> MdePkg/MdePkg.dec | 6 ++++++
> 2 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/MdePkg/Include/Guid/GraphicsInfoHob.h
> b/MdePkg/Include/Guid/GraphicsInfoHob.h
> index 3bcead0..b807213 100644
> --- a/MdePkg/Include/Guid/GraphicsInfoHob.h
> +++ b/MdePkg/Include/Guid/GraphicsInfoHob.h
> @@ -1,7 +1,7 @@
> /** @file
> Hob guid for Information about the graphics mode.
>
> - Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2015 - 2016, 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
> @@ -25,12 +25,27 @@
> 0x39f62cce, 0x6825, 0x4669, { 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a,
> 0x07 } \
> }
>
> +#define EFI_PEI_GRAPHICS_DEVICE_INFO_HOB_GUID \
> + { \
> + 0xe5cb2ac9, 0xd35d, 0x4430, { 0x93, 0x6e, 0x1d, 0xe3, 0x32, 0x47, 0x8d,
> 0xe7 } \
> + }
> +
> typedef struct {
> EFI_PHYSICAL_ADDRESS FrameBufferBase;
> UINT32 FrameBufferSize;
> EFI_GRAPHICS_OUTPUT_MODE_INFORMATION GraphicsMode;
> } EFI_PEI_GRAPHICS_INFO_HOB;
>
> +typedef struct {
> + UINT16 VendorId; ///< Ignore if the value is 0xFFFF.
> + UINT16 DeviceId; ///< Ignore if the value is 0xFFFF.
> + UINT16 SubsystemVendorId; ///< Ignore if the value is
> 0xFFFF.
> + UINT16 SubsystemId; ///< Ignore if the value is 0xFFFF.
> + UINT8 RevisionId; ///< Ignore if the value is 0xFF.
> + UINT8 BarIndex; ///< Ignore if the value is 0xFF.
> +} EFI_PEI_GRAPHICS_DEVICE_INFO_HOB;
> +
> extern EFI_GUID gEfiGraphicsInfoHobGuid;
> +extern EFI_GUID gEfiGraphicsDeviceInfoHobGuid;
>
> #endif
> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> index 606e2f1..f1e5151 100644
> --- a/MdePkg/MdePkg.dec
> +++ b/MdePkg/MdePkg.dec
> @@ -733,6 +733,12 @@ [Guids]
> gEfiDiskInfoUfsInterfaceGuid = { 0x4b3029cc, 0x6b98, 0x47fb, { 0xbc, 0x96,
> 0x76, 0xdc, 0xb8, 0x4, 0x41, 0xf0 }}
>
> #
> + # GUID defined in PI1.5
> + #
> + ## Include/Guid/GraphicsInfoHob.h
> + gEfiGraphicsDeviceInfoHobGuid = { 0xe5cb2ac9, 0xd35d, 0x4430, { 0x93,
> 0x6e, 0x1d, 0xe3, 0x32, 0x47, 0x8d, 0xe7 }}
> +
> + #
> # GUID defined in Windows UEFI Firmware Update Platform doc
> #
> ## Include/IndustryStandard/WindowsUxCapsule.h
> --
> 2.9.0.windows.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 2/5] MdeModulePkg: Add FrameBufferBltLib library class
2016-10-09 8:49 [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe Ruiyu Ni
2016-10-09 8:49 ` [PATCH v2 1/5] MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo HOB GUID and structure Ruiyu Ni
@ 2016-10-09 8:49 ` Ruiyu Ni
2016-10-10 14:26 ` Laszlo Ersek
2016-10-09 8:49 ` [PATCH v2 3/5] MdeModulePkg: Add FrameBufferBltLib library instance Ruiyu Ni
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Ruiyu Ni @ 2016-10-09 8:49 UTC (permalink / raw)
To: edk2-devel; +Cc: Feng Tian, Justen Jordan, Laszlo Ersek
This library provides interfaces to perform UEFI Graphics
Output Protocol Video BLT operations.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Justen Jordan <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
MdeModulePkg/Include/Library/FrameBufferBltLib.h | 94 ++++++++++++++++++++++++
MdeModulePkg/MdeModulePkg.dec | 4 +
2 files changed, 98 insertions(+)
create mode 100644 MdeModulePkg/Include/Library/FrameBufferBltLib.h
diff --git a/MdeModulePkg/Include/Library/FrameBufferBltLib.h b/MdeModulePkg/Include/Library/FrameBufferBltLib.h
new file mode 100644
index 0000000..c92eb94
--- /dev/null
+++ b/MdeModulePkg/Include/Library/FrameBufferBltLib.h
@@ -0,0 +1,94 @@
+/** @file
+ Library for performing UEFI GOP Blt operations on a framebuffer
+
+ Copyright (c) 2009 - 2016, 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 __FRAMEBUFFER_BLT_LIB__
+#define __FRAMEBUFFER_BLT_LIB__
+
+#include <Protocol/GraphicsOutput.h>
+
+//
+// Opaque structure for the frame buffer configure.
+//
+typedef struct FRAME_BUFFER_CONFIGURE FRAME_BUFFER_CONFIGURE;
+
+/**
+ Create the configuration for a video frame buffer.
+
+ The configuration is returned in the caller provided buffer.
+
+ @param[in] FrameBuffer Pointer to the start of the frame buffer.
+ @param[in] FrameBufferInfo Describes the frame buffer characteristics.
+ @param[in,out] Configure The created configuration information.
+ @param[in,out] ConfigureSize Size of the configuration information.
+
+ @retval RETURN_SUCCESS The configuration was successful created.
+ @retval RETURN_BUFFER_TOO_SMALL The Configure is to too small. The required
+ size is returned in ConfigureSize.
+ @retval RETURN_UNSUPPORTED The requested mode is not supported by
+ this implementaion.
+**/
+RETURN_STATUS
+EFIAPI
+FrameBufferBltConfigure (
+ IN VOID *FrameBuffer,
+ IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo,
+ IN OUT FRAME_BUFFER_CONFIGURE *Configure,
+ IN OUT UINTN *ConfigureSize
+ );
+
+/**
+ Performs a UEFI Graphics Output Protocol Blt operation.
+
+ @param[in] Configure Pointer to a configuration which was successfully
+ created by FrameBufferBltConfigure ().
+ @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 RETURN_INVALID_PARAMETER Invalid parameter were passed in.
+ @retval RETURN_SUCCESS The Blt operation was performed successfully.
+**/
+RETURN_STATUS
+EFIAPI
+FrameBufferBlt (
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN OUT 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
+ );
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index f870b83..85ff1cf 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -153,6 +153,10 @@ [LibraryClasses]
#
MemoryProfileLib|Include/Library/MemoryProfileLib.h
+ ## @libraryclass Provides an interface for performing UEFI Graphics Output Protocol Video blt operations.
+ ##
+ FrameBufferBltLib|Include/Library/FrameBufferBltLib.h
+
[Guids]
## MdeModule package token space guid
# Include/Guid/MdeModulePkgTokenSpace.h
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/5] MdeModulePkg: Add FrameBufferBltLib library class
2016-10-09 8:49 ` [PATCH v2 2/5] MdeModulePkg: Add FrameBufferBltLib library class Ruiyu Ni
@ 2016-10-10 14:26 ` Laszlo Ersek
0 siblings, 0 replies; 12+ messages in thread
From: Laszlo Ersek @ 2016-10-10 14:26 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Justen Jordan, Feng Tian
On 10/09/16 10:49, Ruiyu Ni wrote:
> This library provides interfaces to perform UEFI Graphics
> Output Protocol Video BLT operations.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Justen Jordan <jordan.l.justen@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> ---
> MdeModulePkg/Include/Library/FrameBufferBltLib.h | 94 ++++++++++++++++++++++++
> MdeModulePkg/MdeModulePkg.dec | 4 +
> 2 files changed, 98 insertions(+)
> create mode 100644 MdeModulePkg/Include/Library/FrameBufferBltLib.h
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>
> diff --git a/MdeModulePkg/Include/Library/FrameBufferBltLib.h b/MdeModulePkg/Include/Library/FrameBufferBltLib.h
> new file mode 100644
> index 0000000..c92eb94
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/FrameBufferBltLib.h
> @@ -0,0 +1,94 @@
> +/** @file
> + Library for performing UEFI GOP Blt operations on a framebuffer
> +
> + Copyright (c) 2009 - 2016, 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 __FRAMEBUFFER_BLT_LIB__
> +#define __FRAMEBUFFER_BLT_LIB__
> +
> +#include <Protocol/GraphicsOutput.h>
> +
> +//
> +// Opaque structure for the frame buffer configure.
> +//
> +typedef struct FRAME_BUFFER_CONFIGURE FRAME_BUFFER_CONFIGURE;
> +
> +/**
> + Create the configuration for a video frame buffer.
> +
> + The configuration is returned in the caller provided buffer.
> +
> + @param[in] FrameBuffer Pointer to the start of the frame buffer.
> + @param[in] FrameBufferInfo Describes the frame buffer characteristics.
> + @param[in,out] Configure The created configuration information.
> + @param[in,out] ConfigureSize Size of the configuration information.
> +
> + @retval RETURN_SUCCESS The configuration was successful created.
> + @retval RETURN_BUFFER_TOO_SMALL The Configure is to too small. The required
> + size is returned in ConfigureSize.
> + @retval RETURN_UNSUPPORTED The requested mode is not supported by
> + this implementaion.
> +**/
> +RETURN_STATUS
> +EFIAPI
> +FrameBufferBltConfigure (
> + IN VOID *FrameBuffer,
> + IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo,
> + IN OUT FRAME_BUFFER_CONFIGURE *Configure,
> + IN OUT UINTN *ConfigureSize
> + );
> +
> +/**
> + Performs a UEFI Graphics Output Protocol Blt operation.
> +
> + @param[in] Configure Pointer to a configuration which was successfully
> + created by FrameBufferBltConfigure ().
> + @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 RETURN_INVALID_PARAMETER Invalid parameter were passed in.
> + @retval RETURN_SUCCESS The Blt operation was performed successfully.
> +**/
> +RETURN_STATUS
> +EFIAPI
> +FrameBufferBlt (
> + IN FRAME_BUFFER_CONFIGURE *Configure,
> + IN OUT 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
> + );
> +
> +#endif
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index f870b83..85ff1cf 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -153,6 +153,10 @@ [LibraryClasses]
> #
> MemoryProfileLib|Include/Library/MemoryProfileLib.h
>
> + ## @libraryclass Provides an interface for performing UEFI Graphics Output Protocol Video blt operations.
> + ##
> + FrameBufferBltLib|Include/Library/FrameBufferBltLib.h
> +
> [Guids]
> ## MdeModule package token space guid
> # Include/Guid/MdeModulePkgTokenSpace.h
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 3/5] MdeModulePkg: Add FrameBufferBltLib library instance
2016-10-09 8:49 [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe Ruiyu Ni
2016-10-09 8:49 ` [PATCH v2 1/5] MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo HOB GUID and structure Ruiyu Ni
2016-10-09 8:49 ` [PATCH v2 2/5] MdeModulePkg: Add FrameBufferBltLib library class Ruiyu Ni
@ 2016-10-09 8:49 ` Ruiyu Ni
2016-10-09 8:49 ` [PATCH v2 4/5] MdeModulePkg: Add GraphicsOutputDxe driver Ruiyu Ni
` (2 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2016-10-09 8:49 UTC (permalink / raw)
To: edk2-devel; +Cc: Feng Tian, Justen Jordan, Laszlo Ersek
This library provides interfaces to perform UEFI Graphics
Output Protocol Video BLT operations.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Justen Jordan <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
.../Library/FrameBufferBltLib/FrameBufferBltLib.c | 704 +++++++++++++++++++++
.../FrameBufferBltLib/FrameBufferBltLib.inf | 34 +
MdeModulePkg/MdeModulePkg.dsc | 1 +
3 files changed, 739 insertions(+)
create mode 100644 MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
create mode 100644 MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
new file mode 100644
index 0000000..c9bb206
--- /dev/null
+++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
@@ -0,0 +1,704 @@
+/** @file
+ FrameBufferBltLib - Library to perform blt operations on a frame buffer.
+
+ Copyright (c) 2007 - 2016, 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/UefiBaseType.h>
+#include <Protocol/GraphicsOutput.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/FrameBufferBltLib.h>
+
+struct FRAME_BUFFER_CONFIGURE {
+ UINTN ColorDepth;
+ UINTN WidthInBytes;
+ UINTN BytesPerPixel;
+ UINTN WidthInPixels;
+ UINTN Height;
+ UINT8 LineBuffer[SIZE_4KB * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)];
+ UINT8 *FrameBuffer;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+ EFI_PIXEL_BITMASK PixelMasks;
+ INTN PixelShl[4]; // R-G-B-Rsvd
+ INTN PixelShr[4]; // R-G-B-Rsvd
+};
+
+CONST EFI_PIXEL_BITMASK mRgbPixelMasks = {
+ 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
+};
+
+CONST EFI_PIXEL_BITMASK mBgrPixelMasks = {
+ 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000
+};
+
+/**
+ Initialize the bit mask in frame buffer configure.
+
+ @param Configure The frame buffer configure.
+ @param BitMask The bit mask of pixel.
+**/
+VOID
+ConfigurePixelBitMaskFormat (
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN CONST EFI_PIXEL_BITMASK *BitMask
+ )
+{
+ UINTN Loop;
+ UINT32 *Masks;
+ UINT32 MergedMasks;
+
+ MergedMasks = 0;
+ Masks = (UINT32*) BitMask;
+ for (Loop = 0; Loop < 3; Loop++) {
+ ASSERT ((Loop == 3) || (Masks[Loop] != 0));
+ ASSERT ((MergedMasks & Masks[Loop]) == 0);
+ Configure->PixelShl[Loop] = HighBitSet32 (Masks[Loop]) - 23 + (Loop * 8);
+ if (Configure->PixelShl[Loop] < 0) {
+ Configure->PixelShr[Loop] = -Configure->PixelShl[Loop];
+ Configure->PixelShl[Loop] = 0;
+ } else {
+ Configure->PixelShr[Loop] = 0;
+ }
+ MergedMasks = (UINT32) (MergedMasks | Masks[Loop]);
+ DEBUG ((EFI_D_VERBOSE, "%d: shl:%d shr:%d mask:%x\n", Loop,
+ Configure->PixelShl[Loop], Configure->PixelShr[Loop], Masks[Loop]));
+ }
+ MergedMasks = (UINT32) (MergedMasks | Masks[3]);
+
+ ASSERT (MergedMasks != 0);
+ Configure->BytesPerPixel = (UINTN) ((HighBitSet32 (MergedMasks) + 7) / 8);
+
+ DEBUG ((EFI_D_VERBOSE, "Bytes per pixel: %d\n", Configure->BytesPerPixel));
+
+ CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask));
+}
+
+/**
+ Create the configuration for a video frame buffer.
+
+ The configuration is returned in the caller provided buffer.
+
+ @param[in] FrameBuffer Pointer to the start of the frame buffer.
+ @param[in] FrameBufferInfo Describes the frame buffer characteristics.
+ @param[in,out] Configure The created configuration information.
+ @param[in,out] ConfigureSize Size of the configuration information.
+
+ @retval RETURN_SUCCESS The configuration was successful created.
+ @retval RETURN_BUFFER_TOO_SMALL The Configure is to too small. The required
+ size is returned in ConfigureSize.
+ @retval RETURN_UNSUPPORTED The requested mode is not supported by
+ this implementaion.
+
+**/
+RETURN_STATUS
+EFIAPI
+FrameBufferBltConfigure (
+ IN VOID *FrameBuffer,
+ IN EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *FrameBufferInfo,
+ IN OUT FRAME_BUFFER_CONFIGURE *Configure,
+ IN OUT UINTN *ConfigureSize
+ )
+{
+ if (ConfigureSize == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE)) {
+ *ConfigureSize = sizeof (FRAME_BUFFER_CONFIGURE);
+ return RETURN_BUFFER_TOO_SMALL;
+ }
+
+ if (Configure == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ switch (FrameBufferInfo->PixelFormat) {
+ case PixelRedGreenBlueReserved8BitPerColor:
+ ConfigurePixelBitMaskFormat (Configure, &mRgbPixelMasks);
+ break;
+
+ case PixelBlueGreenRedReserved8BitPerColor:
+ ConfigurePixelBitMaskFormat (Configure, &mBgrPixelMasks);
+ break;
+
+ case PixelBitMask:
+ ConfigurePixelBitMaskFormat (Configure, &(FrameBufferInfo->PixelInformation));
+ break;
+
+ case PixelBltOnly:
+ ASSERT (FrameBufferInfo->PixelFormat != PixelBltOnly);
+ return RETURN_UNSUPPORTED;
+
+ default:
+ ASSERT (FALSE);
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ Configure->PixelFormat = FrameBufferInfo->PixelFormat;
+ Configure->FrameBuffer = (UINT8*) FrameBuffer;
+ Configure->WidthInPixels = (UINTN) FrameBufferInfo->HorizontalResolution;
+ Configure->Height = (UINTN) FrameBufferInfo->VerticalResolution;
+ Configure->WidthInBytes = Configure->WidthInPixels * Configure->BytesPerPixel;
+
+ ASSERT (Configure->WidthInBytes < sizeof (Configure->LineBuffer));
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Performs a UEFI Graphics Output Protocol Blt Video Fill.
+
+ @param[in] Configure Pointer to a configuration which was successfully
+ created by FrameBufferBltConfigure ().
+ @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 RETURN_INVALID_PARAMETER Invalid parameter was passed in.
+ @retval RETURN_SUCCESS The video was filled successfully.
+
+**/
+EFI_STATUS
+FrameBufferBltLibVideoFill (
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height
+ )
+{
+ UINTN IndexX;
+ UINTN IndexY;
+ UINT8 *Destination;
+ UINT8 Uint8;
+ UINT32 Uint32;
+ UINT64 WideFill;
+ BOOLEAN UseWideFill;
+ BOOLEAN LineBufferReady;
+ UINTN Offset;
+ UINTN WidthInBytes;
+ UINTN SizeInBytes;
+
+ //
+ // BltBuffer to Video: Source is BltBuffer, destination is Video
+ //
+ if (DestinationY + Height > Configure->Height) {
+ DEBUG ((EFI_D_VERBOSE, "VideoFill: Past screen (Y)\n"));
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (DestinationX + Width > Configure->WidthInPixels) {
+ DEBUG ((EFI_D_VERBOSE, "VideoFill: Past screen (X)\n"));
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (Width == 0 || Height == 0) {
+ DEBUG ((EFI_D_VERBOSE, "VideoFill: Width or Height is 0\n"));
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ WidthInBytes = Width * Configure->BytesPerPixel;
+
+ Uint32 = *(UINT32*) Color;
+ WideFill =
+ (UINT32) (
+ (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
+ Configure->PixelMasks.RedMask) |
+ (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
+ Configure->PixelMasks.GreenMask) |
+ (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
+ Configure->PixelMasks.BlueMask)
+ );
+ DEBUG ((EFI_D_VERBOSE, "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) % Configure->BytesPerPixel) == 0) {
+ for (IndexX = Configure->BytesPerPixel; IndexX < sizeof (WideFill); IndexX++) {
+ ((UINT8*) &WideFill)[IndexX] = ((UINT8*) &WideFill)[IndexX % Configure->BytesPerPixel];
+ }
+ } else {
+ //
+ // If all the bytes in the pixel are the same value, then use
+ // a wide fill operation.
+ //
+ for (
+ IndexX = 1, Uint8 = ((UINT8*) &WideFill)[0];
+ IndexX < Configure->BytesPerPixel;
+ IndexX++) {
+ if (Uint8 != ((UINT8*) &WideFill)[IndexX]) {
+ UseWideFill = FALSE;
+ break;
+ }
+ }
+ if (UseWideFill) {
+ SetMem (&WideFill, sizeof (WideFill), Uint8);
+ }
+ }
+
+ if (UseWideFill && (DestinationX == 0) && (Width == Configure->WidthInPixels)) {
+ DEBUG ((EFI_D_VERBOSE, "VideoFill (wide, one-shot)\n"));
+ Offset = DestinationY * Configure->WidthInPixels;
+ Offset = Configure->BytesPerPixel * Offset;
+ Destination = Configure->FrameBuffer + Offset;
+ SizeInBytes = WidthInBytes * Height;
+ if (SizeInBytes >= 8) {
+ SetMem32 (Destination, SizeInBytes & ~3, (UINT32) WideFill);
+ SizeInBytes &= 3;
+ }
+ if (SizeInBytes > 0) {
+ SetMem (Destination, SizeInBytes, (UINT8) (UINTN) WideFill);
+ }
+ } else {
+ LineBufferReady = FALSE;
+ for (IndexY = DestinationY; IndexY < (Height + DestinationY); IndexY++) {
+ Offset = (IndexY * Configure->WidthInPixels) + DestinationX;
+ Offset = Configure->BytesPerPixel * Offset;
+ Destination = Configure->FrameBuffer + Offset;
+
+ if (UseWideFill && (((UINTN) Destination & 7) == 0)) {
+ DEBUG ((EFI_D_VERBOSE, "VideoFill (wide)\n"));
+ SizeInBytes = WidthInBytes;
+ if (SizeInBytes >= 8) {
+ SetMem64 (Destination, SizeInBytes & ~7, WideFill);
+ SizeInBytes &= 7;
+ }
+ if (SizeInBytes > 0) {
+ CopyMem (Destination, &WideFill, SizeInBytes);
+ }
+ } else {
+ DEBUG ((EFI_D_VERBOSE, "VideoFill (not wide)\n"));
+ if (!LineBufferReady) {
+ CopyMem (Configure->LineBuffer, &WideFill, Configure->BytesPerPixel);
+ for (IndexX = 1; IndexX < Width; ) {
+ CopyMem (
+ (Configure->LineBuffer + (IndexX * Configure->BytesPerPixel)),
+ Configure->LineBuffer,
+ MIN (IndexX, Width - IndexX) * Configure->BytesPerPixel
+ );
+ IndexX += MIN (IndexX, Width - IndexX);
+ }
+ LineBufferReady = TRUE;
+ }
+ CopyMem (Destination, Configure->LineBuffer, WidthInBytes);
+ }
+ }
+ }
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Performs a UEFI Graphics Output Protocol Blt Video to Buffer operation
+ with extended parameters.
+
+ @param[in] Configure Pointer to a configuration which was successfully
+ created by FrameBufferBltConfigure ().
+ @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 RETURN_INVALID_PARAMETER Invalid parameter were passed in.
+ @retval RETURN_SUCCESS The Blt operation was performed successfully.
+**/
+RETURN_STATUS
+FrameBufferBltLibVideoToBltBuffer (
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ 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
+ )
+{
+ UINTN DstY;
+ UINTN SrcY;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ UINT8 *Source;
+ UINT8 *Destination;
+ UINTN IndexX;
+ UINT32 Uint32;
+ UINTN Offset;
+ UINTN WidthInBytes;
+
+ //
+ // Video to BltBuffer: Source is Video, destination is BltBuffer
+ //
+ if (SourceY + Height > Configure->Height) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (SourceX + Width > Configure->WidthInPixels) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (Width == 0 || Height == 0) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ //
+ // 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 * Configure->BytesPerPixel;
+
+ //
+ // Video to BltBuffer: Source is Video, destination is BltBuffer
+ //
+ for (SrcY = SourceY, DstY = DestinationY;
+ DstY < (Height + DestinationY);
+ SrcY++, DstY++) {
+
+ Offset = (SrcY * Configure->WidthInPixels) + SourceX;
+ Offset = Configure->BytesPerPixel * Offset;
+ Source = Configure->FrameBuffer + Offset;
+
+ if (Configure->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+ Destination = (UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ } else {
+ Destination = Configure->LineBuffer;
+ }
+
+ CopyMem (Destination, Source, WidthInBytes);
+
+ if (Configure->PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
+ for (IndexX = 0; IndexX < Width; IndexX++) {
+ Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)
+ ((UINT8 *) BltBuffer + (DstY * Delta) +
+ (DestinationX + IndexX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ Uint32 = *(UINT32*) (Configure->LineBuffer + (IndexX * Configure->BytesPerPixel));
+ *(UINT32*) Blt =
+ (UINT32) (
+ (((Uint32 & Configure->PixelMasks.RedMask) >>
+ Configure->PixelShl[0]) << Configure->PixelShr[0]) |
+ (((Uint32 & Configure->PixelMasks.GreenMask) >>
+ Configure->PixelShl[1]) << Configure->PixelShr[1]) |
+ (((Uint32 & Configure->PixelMasks.BlueMask) >>
+ Configure->PixelShl[2]) << Configure->PixelShr[2])
+ );
+ }
+ }
+ }
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Performs a UEFI Graphics Output Protocol Blt Buffer to Video operation
+ with extended parameters.
+
+ @param[in] Configure Pointer to a configuration which was successfully
+ created by FrameBufferBltConfigure ().
+ @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 RETURN_INVALID_PARAMETER Invalid parameter were passed in.
+ @retval RETURN_SUCCESS The Blt operation was performed successfully.
+**/
+RETURN_STATUS
+FrameBufferBltLibBufferToVideo (
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ 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
+ )
+{
+ UINTN DstY;
+ UINTN SrcY;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ UINT8 *Source;
+ UINT8 *Destination;
+ UINTN IndexX;
+ UINT32 Uint32;
+ UINTN Offset;
+ UINTN WidthInBytes;
+
+ //
+ // BltBuffer to Video: Source is BltBuffer, destination is Video
+ //
+ if (DestinationY + Height > Configure->Height) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (DestinationX + Width > Configure->WidthInPixels) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (Width == 0 || Height == 0) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ //
+ // 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 * Configure->BytesPerPixel;
+
+ for (SrcY = SourceY, DstY = DestinationY;
+ SrcY < (Height + SourceY);
+ SrcY++, DstY++) {
+
+ Offset = (DstY * Configure->WidthInPixels) + DestinationX;
+ Offset = Configure->BytesPerPixel * Offset;
+ Destination = Configure->FrameBuffer + Offset;
+
+ if (Configure->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+ Source = (UINT8 *) BltBuffer + (SrcY * Delta);
+ } else {
+ for (IndexX = 0; IndexX < Width; IndexX++) {
+ Blt =
+ (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (
+ (UINT8 *) BltBuffer +
+ (SrcY * Delta) +
+ ((SourceX + IndexX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))
+ );
+ Uint32 = *(UINT32*) Blt;
+ *(UINT32*) (Configure->LineBuffer + (IndexX * Configure->BytesPerPixel)) =
+ (UINT32) (
+ (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
+ Configure->PixelMasks.RedMask) |
+ (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
+ Configure->PixelMasks.GreenMask) |
+ (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
+ Configure->PixelMasks.BlueMask)
+ );
+ }
+ Source = Configure->LineBuffer;
+ }
+
+ CopyMem (Destination, Source, WidthInBytes);
+ }
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Performs a UEFI Graphics Output Protocol Blt Video to Video operation
+
+ @param[in] Configure Pointer to a configuration which was successfully
+ created by FrameBufferBltConfigure ().
+ @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 RETURN_INVALID_PARAMETER Invalid parameter were passed in.
+ @retval RETURN_SUCCESS The Blt operation was performed successfully.
+**/
+RETURN_STATUS
+FrameBufferBltLibVideoToVideo (
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height
+ )
+{
+ UINT8 *Source;
+ UINT8 *Destination;
+ UINTN Offset;
+ UINTN WidthInBytes;
+ INTN LineStride;
+
+ //
+ // Video to Video: Source is Video, destination is Video
+ //
+ if (SourceY + Height > Configure->Height) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (SourceX + Width > Configure->WidthInPixels) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (DestinationY + Height > Configure->Height) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (DestinationX + Width > Configure->WidthInPixels) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (Width == 0 || Height == 0) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ WidthInBytes = Width * Configure->BytesPerPixel;
+
+ Offset = (SourceY * Configure->WidthInPixels) + SourceX;
+ Offset = Configure->BytesPerPixel * Offset;
+ Source = Configure->FrameBuffer + Offset;
+
+ Offset = (DestinationY * Configure->WidthInPixels) + DestinationX;
+ Offset = Configure->BytesPerPixel * Offset;
+ Destination = Configure->FrameBuffer + Offset;
+
+ LineStride = Configure->WidthInBytes;
+ 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 RETURN_SUCCESS;
+}
+
+/**
+ Performs a UEFI Graphics Output Protocol Blt operation.
+
+ @param[in] Configure Pointer to a configuration which was successfully
+ created by FrameBufferBltConfigure ().
+ @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 RETURN_INVALID_PARAMETER Invalid parameter were passed in.
+ @retval RETURN_SUCCESS The Blt operation was performed successfully.
+**/
+RETURN_STATUS
+EFIAPI
+FrameBufferBlt (
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN OUT 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
+ )
+{
+ if (Configure == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ switch (BltOperation) {
+ case EfiBltVideoToBltBuffer:
+ return FrameBufferBltLibVideoToBltBuffer (
+ Configure,
+ BltBuffer,
+ SourceX,
+ SourceY,
+ DestinationX,
+ DestinationY,
+ Width,
+ Height,
+ Delta
+ );
+
+ case EfiBltVideoToVideo:
+ return FrameBufferBltLibVideoToVideo (
+ Configure,
+ SourceX,
+ SourceY,
+ DestinationX,
+ DestinationY,
+ Width,
+ Height
+ );
+
+ case EfiBltVideoFill:
+ return FrameBufferBltLibVideoFill (
+ Configure,
+ BltBuffer,
+ DestinationX,
+ DestinationY,
+ Width,
+ Height
+ );
+
+ case EfiBltBufferToVideo:
+ return FrameBufferBltLibBufferToVideo (
+ Configure,
+ BltBuffer,
+ SourceX,
+ SourceY,
+ DestinationX,
+ DestinationY,
+ Width,
+ Height,
+ Delta
+ );
+
+ default:
+ return RETURN_INVALID_PARAMETER;
+ }
+}
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
new file mode 100644
index 0000000..57e4adb
--- /dev/null
+++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
@@ -0,0 +1,34 @@
+## @file
+# FrameBufferBltLib - Library to perform blt operations on a frame buffer.
+#
+# Copyright (c) 2006 - 2016, 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 = 243D3E8C-2780-4A25-9693-A410475BFCEC
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = FrameBufferBltLib
+
+[Sources.common]
+ FrameBufferBltLib.c
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 214cb6c..6efd2c2 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -306,6 +306,7 @@ [Components]
MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.inf
MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.inf
MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.inf
+ MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 4/5] MdeModulePkg: Add GraphicsOutputDxe driver.
2016-10-09 8:49 [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe Ruiyu Ni
` (2 preceding siblings ...)
2016-10-09 8:49 ` [PATCH v2 3/5] MdeModulePkg: Add FrameBufferBltLib library instance Ruiyu Ni
@ 2016-10-09 8:49 ` Ruiyu Ni
2016-10-09 8:49 ` [PATCH v2 5/5] OvmfPkg: QemuVideoDxe uses MdeModulePkg/FrameBufferLib Ruiyu Ni
2016-10-10 6:38 ` [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe Tian, Feng
5 siblings, 0 replies; 12+ messages in thread
From: Ruiyu Ni @ 2016-10-09 8:49 UTC (permalink / raw)
To: edk2-devel; +Cc: Feng Tian
The driver uses the GraphicsInfo HOB and GraphicsDeviceInfo HOB
passed from PEI to find the graphics controller to manage and
produce the GraphicsOutput protocol.
GraphicsInfo HOB and GraphicsDeviceInfo HOB are created by
a PEIM which initializes the graphics controller hardware in
PEI phase.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
---
MdeModulePkg/MdeModulePkg.dsc | 2 +
.../Console/GraphicsOutputDxe/ComponentName.c | 190 ++++++
.../Console/GraphicsOutputDxe/GraphicsOutput.c | 735 +++++++++++++++++++++
.../Console/GraphicsOutputDxe/GraphicsOutput.h | 59 ++
.../GraphicsOutputDxe/GraphicsOutputDxe.inf | 58 ++
5 files changed, 1044 insertions(+)
create mode 100644 MdeModulePkg/Universal/Console/GraphicsOutputDxe/ComponentName.c
create mode 100644 MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c
create mode 100644 MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.h
create mode 100644 MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 6efd2c2..71505d3 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -81,6 +81,7 @@ [LibraryClasses]
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
PalLib|MdePkg/Library/BasePalLibNull/BasePalLibNull.inf
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
+ FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
#
# Misc
#
@@ -323,6 +324,7 @@ [Components]
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+ MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
MdeModulePkg/Universal/DebugPortDxe/DebugPortDxe.inf
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/MdeModulePkg/Universal/Console/GraphicsOutputDxe/ComponentName.c b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/ComponentName.c
new file mode 100644
index 0000000..aa19263
--- /dev/null
+++ b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/ComponentName.c
@@ -0,0 +1,190 @@
+/** @file
+ UEFI Component Name(2) protocol implementation for the generic GOP driver.
+
+Copyright (c) 2016, 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 <PiDxe.h>
+#include <Library/UefiLib.h>
+
+extern EFI_COMPONENT_NAME_PROTOCOL mGraphicsOutputComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL mGraphicsOutputComponentName2;
+
+//
+// Driver name table for GraphicsOutput module.
+// It is shared by the implementation of ComponentName & ComponentName2 Protocol.
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mGraphicsOutputDriverNameTable[] = {
+ {
+ "eng;en",
+ L"Generic Graphics Output Driver"
+ },
+ {
+ NULL,
+ NULL
+ }
+};
+
+/**
+ Retrieves a Unicode string that is the user readable name of the driver.
+
+ This function retrieves the user readable name of a driver in the form of a
+ Unicode string. If the driver specified by This has a user readable name in
+ the language specified by Language, then a pointer to the driver name is
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
+ by This does not support the language specified by Language,
+ then EFI_UNSUPPORTED is returned.
+
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+
+ @param Language[in] A pointer to a Null-terminated ASCII string
+ array indicating the language. This is the
+ language of the driver name that the caller is
+ requesting, and it must match one of the
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified
+ in RFC 4646 or ISO 639-2 language code format.
+
+ @param DriverName[out] A pointer to the Unicode string to return.
+ This Unicode string is the name of the
+ driver specified by This in the language
+ specified by Language.
+
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by
+ This and the language specified by Language was
+ returned in DriverName.
+
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.
+
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+GraphicsOutputComponentNameGetDriverName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ )
+{
+ return LookupUnicodeString2 (
+ Language,
+ This->SupportedLanguages,
+ mGraphicsOutputDriverNameTable,
+ DriverName,
+ (BOOLEAN) (This == &mGraphicsOutputComponentName)
+ );
+}
+
+/**
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by a driver.
+
+ This function retrieves the user readable name of the controller specified by
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the
+ driver specified by This has a user readable name in the language specified by
+ Language, then a pointer to the controller name is returned in ControllerName,
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently
+ managing the controller specified by ControllerHandle and ChildHandle,
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.
+
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
+ EFI_COMPONENT_NAME_PROTOCOL instance.
+
+ @param ControllerHandle[in] The handle of a controller that the driver
+ specified by This is managing. This handle
+ specifies the controller whose name is to be
+ returned.
+
+ @param ChildHandle[in] The handle of the child controller to retrieve
+ the name of. This is an optional parameter that
+ may be NULL. It will be NULL for device
+ drivers. It will also be NULL for a bus drivers
+ that wish to retrieve the name of the bus
+ controller. It will not be NULL for a bus
+ driver that wishes to retrieve the name of a
+ child controller.
+
+ @param Language[in] A pointer to a Null-terminated ASCII string
+ array indicating the language. This is the
+ language of the driver name that the caller is
+ requesting, and it must match one of the
+ languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up
+ to the driver writer. Language is specified in
+ RFC 4646 or ISO 639-2 language code format.
+
+ @param ControllerName[out] A pointer to the Unicode string to return.
+ This Unicode string is the name of the
+ controller specified by ControllerHandle and
+ ChildHandle in the language specified by
+ Language from the point of view of the driver
+ specified by This.
+
+ @retval EFI_SUCCESS The Unicode string for the user readable name in
+ the language specified by Language for the
+ driver specified by This was returned in
+ DriverName.
+
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
+
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.
+
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently
+ managing the controller specified by
+ ControllerHandle and ChildHandle.
+
+ @retval EFI_UNSUPPORTED The driver specified by This does not support
+ the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+GraphicsOutputComponentNameGetControllerName (
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+//
+// EFI Component Name Protocol
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL mGraphicsOutputComponentName = {
+ GraphicsOutputComponentNameGetDriverName,
+ GraphicsOutputComponentNameGetControllerName,
+ "eng"
+};
+
+//
+// EFI Component Name 2 Protocol
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL mGraphicsOutputComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) GraphicsOutputComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) GraphicsOutputComponentNameGetControllerName,
+ "en"
+};
diff --git a/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c
new file mode 100644
index 0000000..c6ccfe2
--- /dev/null
+++ b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c
@@ -0,0 +1,735 @@
+/** @file
+ Implementation for a generic GOP driver.
+
+Copyright (c) 2016, 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 "GraphicsOutput.h"
+CONST ACPI_ADR_DEVICE_PATH mGraphicsOutputAdrNode = {
+ {
+ ACPI_DEVICE_PATH,
+ ACPI_ADR_DP,
+ { sizeof (ACPI_ADR_DEVICE_PATH), 0 },
+ },
+ ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0)
+};
+
+EFI_PEI_GRAPHICS_DEVICE_INFO_HOB mDefaultGraphicsDeviceInfo = {
+ MAX_UINT16, MAX_UINT16, MAX_UINT16, MAX_UINT16, MAX_UINT8, MAX_UINT8
+};
+
+//
+// The driver should only start on one graphics controller.
+// So a global flag is used to remember that the driver is already started.
+//
+BOOLEAN mDriverStarted = FALSE;
+
+/**
+ Returns information for an available graphics mode that the graphics device
+ and the set of active video output devices supports.
+
+ @param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
+ @param ModeNumber The mode number to return information on.
+ @param SizeOfInfo A pointer to the size, in bytes, of the Info buffer.
+ @param Info A pointer to callee allocated buffer that returns information about ModeNumber.
+
+ @retval EFI_SUCCESS Valid mode information was returned.
+ @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the video mode.
+ @retval EFI_INVALID_PARAMETER ModeNumber is not valid.
+
+**/
+EFI_STATUS
+EFIAPI
+GraphicsOutputQueryMode (
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN UINT32 ModeNumber,
+ OUT UINTN *SizeOfInfo,
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
+ )
+{
+ if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *SizeOfInfo = This->Mode->SizeOfInfo;
+ *Info = AllocateCopyPool (*SizeOfInfo, This->Mode->Info);
+ return EFI_SUCCESS;
+}
+
+/**
+ Set the video device into the specified mode and clears the visible portions of
+ the output display to black.
+
+ @param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
+ @param ModeNumber Abstraction that defines the current video mode.
+
+ @retval EFI_SUCCESS The graphics mode specified by ModeNumber was selected.
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
+ @retval EFI_UNSUPPORTED ModeNumber is not supported by this device.
+
+**/
+EFI_STATUS
+EFIAPI
+GraphicsOutputSetMode (
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN UINT32 ModeNumber
+)
+{
+ RETURN_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
+ GRAPHICS_OUTPUT_PRIVATE_DATA *Private;
+
+ if (ModeNumber >= This->Mode->MaxMode) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Private = GRAPHICS_OUTPUT_PRIVATE_FROM_THIS (This);
+
+ Black.Blue = 0;
+ Black.Green = 0;
+ Black.Red = 0;
+ Black.Reserved = 0;
+
+ Status = FrameBufferBlt (
+ Private->FrameBufferBltLibConfigure,
+ &Black,
+ EfiBltVideoFill,
+ 0, 0,
+ 0, 0,
+ This->Mode->Info->HorizontalResolution,
+ This->Mode->Info->VerticalResolution,
+ 0
+ );
+ return RETURN_ERROR (Status) ? EFI_DEVICE_ERROR : EFI_SUCCESS;
+}
+
+/**
+ Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
+
+ @param This Protocol instance pointer.
+ @param BltBuffer The data to transfer to the graphics screen.
+ Size is at least Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL).
+ @param BltOperation The operation to perform when copying BltBuffer on to the graphics screen.
+ @param SourceX The X coordinate of source for the BltOperation.
+ @param SourceY The Y coordinate of source for the BltOperation.
+ @param DestinationX The X coordinate of destination for the BltOperation.
+ @param DestinationY The Y coordinate of destination for the BltOperation.
+ @param Width The width of a rectangle in the blt rectangle in pixels.
+ @param Height The height of a rectangle in the blt rectangle in pixels.
+ @param Delta Not used for EfiBltVideoFill or the EfiBltVideoToVideo operation.
+ If a Delta of zero is used, the entire BltBuffer is being operated on.
+ If a subrectangle of the BltBuffer is being used then Delta
+ represents the number of bytes in a row of the BltBuffer.
+
+ @retval EFI_SUCCESS BltBuffer was drawn to the graphics screen.
+ @retval EFI_INVALID_PARAMETER BltOperation is not valid.
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
+
+**/
+EFI_STATUS
+EFIAPI
+GraphicsOutputBlt (
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ 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 OPTIONAL
+ )
+{
+ RETURN_STATUS Status;
+ EFI_TPL Tpl;
+ GRAPHICS_OUTPUT_PRIVATE_DATA *Private;
+
+ Private = GRAPHICS_OUTPUT_PRIVATE_FROM_THIS (This);
+ //
+ // We have to raise to TPL_NOTIFY, so we make an atomic write to the frame buffer.
+ // We would not want a timer based event (Cursor, ...) to come in while we are
+ // doing this operation.
+ //
+ Tpl = gBS->RaiseTPL (TPL_NOTIFY);
+ Status = FrameBufferBlt (
+ Private->FrameBufferBltLibConfigure,
+ BltBuffer,
+ BltOperation,
+ SourceX, SourceY,
+ DestinationX, DestinationY, Width, Height,
+ Delta
+ );
+ gBS->RestoreTPL (Tpl);
+
+ return RETURN_ERROR (Status) ? EFI_INVALID_PARAMETER : EFI_SUCCESS;
+}
+
+CONST GRAPHICS_OUTPUT_PRIVATE_DATA mGraphicsOutputInstanceTemplate = {
+ GRAPHICS_OUTPUT_PRIVATE_DATA_SIGNATURE, // Signature
+ NULL, // GraphicsOutputHandle
+ {
+ GraphicsOutputQueryMode,
+ GraphicsOutputSetMode,
+ GraphicsOutputBlt,
+ NULL // Mode
+ },
+ {
+ 1, // MaxMode
+ 0, // Mode
+ NULL, // Info
+ sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION), // SizeOfInfo
+ 0, // FrameBufferBase
+ 0 // FrameBufferSize
+ },
+ NULL, // DevicePath
+ NULL, // PciIo
+ 0, // PciAttributes
+ NULL, // FrameBufferBltLibConfigure
+ 0 // FrameBufferBltLibConfigureSize
+};
+
+/**
+ Test whether the Controller can be managed by the driver.
+
+ @param This Driver Binding protocol instance pointer.
+ @param Controller The PCI controller.
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCESS The driver can manage the video device.
+ @retval other The driver cannot manage the video device.
+**/
+EFI_STATUS
+EFIAPI
+GraphicsOutputDriverBindingSupported (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ EFI_STATUS Status;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ //
+ // Since there is only one GraphicsInfo HOB, the driver only manages one video device.
+ //
+ if (mDriverStarted) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ //
+ // Test the PCI I/O Protocol
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ (VOID **) &PciIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (Status == EFI_ALREADY_STARTED) {
+ Status = EFI_SUCCESS;
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ //
+ // Test the DevicePath protocol
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &DevicePath,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (Status == EFI_ALREADY_STARTED) {
+ Status = EFI_SUCCESS;
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ if ((RemainingDevicePath == NULL) ||
+ IsDevicePathEnd (RemainingDevicePath) ||
+ CompareMem (RemainingDevicePath, &mGraphicsOutputAdrNode, sizeof (mGraphicsOutputAdrNode)) == 0) {
+ return EFI_SUCCESS;
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
+}
+
+/**
+ Start the video controller.
+
+ @param This Driver Binding protocol instance pointer.
+ @param ControllerHandle The PCI controller.
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCESS The driver starts to manage the video device.
+ @retval other The driver cannot manage the video device.
+**/
+EFI_STATUS
+EFIAPI
+GraphicsOutputDriverBindingStart (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ )
+{
+ EFI_STATUS Status;
+ RETURN_STATUS ReturnStatus;
+ GRAPHICS_OUTPUT_PRIVATE_DATA *Private;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_DEVICE_PATH *PciDevicePath;
+ PCI_TYPE00 Pci;
+ UINT8 Index;
+ EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Resources;
+ VOID *HobStart;
+ EFI_PEI_GRAPHICS_INFO_HOB *GraphicsInfo;
+ EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *DeviceInfo;
+ EFI_PHYSICAL_ADDRESS FrameBufferBase;
+
+ FrameBufferBase = 0;
+
+ HobStart = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);
+ ASSERT ((HobStart != NULL) && (GET_GUID_HOB_DATA_SIZE (HobStart) == sizeof (EFI_PEI_GRAPHICS_INFO_HOB)));
+ GraphicsInfo = (EFI_PEI_GRAPHICS_INFO_HOB *) (GET_GUID_HOB_DATA (HobStart));
+
+ HobStart = GetFirstGuidHob (&gEfiGraphicsDeviceInfoHobGuid);
+ if ((HobStart == NULL) || (GET_GUID_HOB_DATA_SIZE (HobStart) < sizeof (*DeviceInfo))) {
+ //
+ // Use default device infomation when the device info HOB doesn't exist
+ //
+ DeviceInfo = &mDefaultGraphicsDeviceInfo;
+ DEBUG ((EFI_D_INFO, "[%a]: GraphicsDeviceInfo HOB doesn't exist!\n", gEfiCallerBaseName));
+ } else {
+ DeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *) (GET_GUID_HOB_DATA (HobStart));
+ DEBUG ((EFI_D_INFO, "[%a]: GraphicsDeviceInfo HOB:\n"
+ " VendorId = %04x, DeviceId = %04x,\n"
+ " RevisionId = %02x, BarIndex = %x,\n"
+ " SubsystemVendorId = %04x, SubsystemId = %04x\n",
+ gEfiCallerBaseName,
+ DeviceInfo->VendorId, DeviceInfo->DeviceId,
+ DeviceInfo->RevisionId, DeviceInfo->BarIndex,
+ DeviceInfo->SubsystemVendorId, DeviceInfo->SubsystemId));
+ }
+
+ //
+ // Open the PCI I/O Protocol
+ //
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ (VOID **) &PciIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (Status == EFI_ALREADY_STARTED) {
+ Status = EFI_SUCCESS;
+ }
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &PciDevicePath,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (Status == EFI_ALREADY_STARTED) {
+ Status = EFI_SUCCESS;
+ }
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Read the PCI Class Code from the PCI Device
+ //
+ Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0, sizeof (Pci), &Pci);
+ if (!EFI_ERROR (Status)) {
+ if (!IS_PCI_DISPLAY (&Pci) || (
+ ((DeviceInfo->VendorId != MAX_UINT16) && (DeviceInfo->VendorId != Pci.Hdr.VendorId)) ||
+ ((DeviceInfo->DeviceId != MAX_UINT16) && (DeviceInfo->DeviceId != Pci.Hdr.DeviceId)) ||
+ ((DeviceInfo->RevisionId != MAX_UINT8) && (DeviceInfo->RevisionId != Pci.Hdr.RevisionID)) ||
+ ((DeviceInfo->SubsystemVendorId != MAX_UINT16) && (DeviceInfo->SubsystemVendorId != Pci.Device.SubsystemVendorID)) ||
+ ((DeviceInfo->SubsystemId != MAX_UINT16) && (DeviceInfo->SubsystemId != Pci.Device.SubsystemID))
+ )
+ ) {
+ //
+ // It's not a video device, or device infomation doesn't match.
+ //
+ Status = EFI_UNSUPPORTED;
+ } else {
+ //
+ // If it's a video device and device information matches, use the BarIndex
+ // from device information, or any BAR if BarIndex is not specified
+ // whose size >= the frame buffer size from GraphicsInfo HOB.
+ // Store the new frame buffer base.
+ //
+ for (Index = 0; Index < MAX_PCI_BAR; Index++) {
+ if ((DeviceInfo->BarIndex != MAX_UINT8) && (DeviceInfo->BarIndex != Index)) {
+ continue;
+ }
+ Status = PciIo->GetBarAttributes (PciIo, Index, NULL, (VOID**) &Resources);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_INFO, "[%a]: BAR[%d]: Base = %lx, Length = %lx\n",
+ gEfiCallerBaseName, Index, Resources->AddrRangeMin, Resources->AddrLen));
+ if ((Resources->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) &&
+ (Resources->Len == (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3)) &&
+ (Resources->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) &&
+ (Resources->AddrLen >= GraphicsInfo->FrameBufferSize)
+ ) {
+ FrameBufferBase = Resources->AddrRangeMin;
+ DEBUG ((EFI_D_INFO, "[%a]: ... matched!\n", gEfiCallerBaseName));
+ break;
+ }
+ }
+ }
+ if (Index == MAX_PCI_BAR) {
+ Status = EFI_UNSUPPORTED;
+ }
+ }
+ }
+
+ if (EFI_ERROR (Status)) {
+ goto CloseProtocols;
+ }
+
+ if ((RemainingDevicePath != NULL) && IsDevicePathEnd (RemainingDevicePath)) {
+ return EFI_SUCCESS;
+ }
+
+ Private = AllocateCopyPool (sizeof (mGraphicsOutputInstanceTemplate), &mGraphicsOutputInstanceTemplate);
+ if (Private == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto CloseProtocols;
+ }
+
+ Private->GraphicsOutputMode.FrameBufferBase = FrameBufferBase;
+ Private->GraphicsOutputMode.FrameBufferSize = GraphicsInfo->FrameBufferSize;
+ Private->GraphicsOutputMode.Info = &GraphicsInfo->GraphicsMode;
+
+ //
+ // Fix up Mode pointer in GraphicsOutput
+ //
+ Private->GraphicsOutput.Mode = &Private->GraphicsOutputMode;
+
+ //
+ // Set attributes
+ //
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationGet,
+ 0,
+ &Private->PciAttributes
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ EFI_PCI_DEVICE_ENABLE,
+ NULL
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ goto FreeMemory;
+ }
+
+ //
+ // Create the FrameBufferBltLib configuration.
+ //
+ ReturnStatus = FrameBufferBltConfigure (
+ (VOID *) (UINTN) Private->GraphicsOutput.Mode->FrameBufferBase,
+ Private->GraphicsOutput.Mode->Info,
+ Private->FrameBufferBltLibConfigure,
+ &Private->FrameBufferBltLibConfigureSize
+ );
+ if (ReturnStatus == RETURN_BUFFER_TOO_SMALL) {
+ Private->FrameBufferBltLibConfigure = AllocatePool (Private->FrameBufferBltLibConfigureSize);
+ if (Private->FrameBufferBltLibConfigure != NULL) {
+ ReturnStatus = FrameBufferBltConfigure (
+ (VOID *) (UINTN) Private->GraphicsOutput.Mode->FrameBufferBase,
+ Private->GraphicsOutput.Mode->Info,
+ Private->FrameBufferBltLibConfigure,
+ &Private->FrameBufferBltLibConfigureSize
+ );
+ }
+ }
+ if (RETURN_ERROR (ReturnStatus)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto RestorePciAttributes;
+ }
+
+ Private->DevicePath = AppendDevicePathNode (PciDevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &mGraphicsOutputAdrNode);
+ if (Private->DevicePath == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto RestorePciAttributes;
+ }
+
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Private->GraphicsOutputHandle,
+ &gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
+ &gEfiDevicePathProtocolGuid, Private->DevicePath,
+ NULL
+ );
+
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ (VOID **) &Private->PciIo,
+ This->DriverBindingHandle,
+ Private->GraphicsOutputHandle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
+ if (!EFI_ERROR (Status)) {
+ mDriverStarted = TRUE;
+ } else {
+ gBS->UninstallMultipleProtocolInterfaces (
+ Private->GraphicsOutputHandle,
+ &gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
+ &gEfiDevicePathProtocolGuid, Private->DevicePath,
+ NULL
+ );
+ }
+ }
+
+RestorePciAttributes:
+ if (EFI_ERROR (Status)) {
+ //
+ // Restore original PCI attributes
+ //
+ PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationSet,
+ Private->PciAttributes,
+ NULL
+ );
+ }
+
+FreeMemory:
+ if (EFI_ERROR (Status)) {
+ if (Private != NULL) {
+ if (Private->DevicePath != NULL) {
+ FreePool (Private->DevicePath);
+ }
+ if (Private->FrameBufferBltLibConfigure != NULL) {
+ FreePool (Private->FrameBufferBltLibConfigure);
+ }
+ FreePool (Private);
+ }
+ }
+
+CloseProtocols:
+ if (EFI_ERROR (Status)) {
+ //
+ // Close the PCI I/O Protocol
+ //
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+
+ //
+ // Close the PCI I/O Protocol
+ //
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ }
+ return Status;
+}
+
+/**
+ Stop the video controller.
+
+ @param This Driver Binding protocol instance pointer.
+ @param Controller The PCI controller.
+ @param NumberOfChildren The number of child device handles in ChildHandleBuffer.
+ @param ChildHandleBuffer An array of child handles to be freed. May be NULL
+ if NumberOfChildren is 0.
+
+ @retval EFI_SUCCESS The device was stopped.
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
+**/
+EFI_STATUS
+EFIAPI
+GraphicsOutputDriverBindingStop (
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
+ )
+{
+ EFI_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
+ GRAPHICS_OUTPUT_PRIVATE_DATA *Private;
+
+ if (NumberOfChildren == 0) {
+
+ //
+ // Close the PCI I/O Protocol
+ //
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ ASSERT_EFI_ERROR (Status);
+ return EFI_SUCCESS;
+ }
+
+ ASSERT (NumberOfChildren == 1);
+ Status = gBS->OpenProtocol (
+ ChildHandleBuffer[0],
+ &gEfiGraphicsOutputProtocolGuid,
+ (VOID **) &Gop,
+ This->DriverBindingHandle,
+ ChildHandleBuffer[0],
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Private = GRAPHICS_OUTPUT_PRIVATE_FROM_THIS (Gop);
+
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Private->GraphicsOutputHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Remove the GOP protocol interface from the system
+ //
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ Private->GraphicsOutputHandle,
+ &gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
+ &gEfiDevicePathProtocolGuid, Private->DevicePath,
+ NULL
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Restore original PCI attributes
+ //
+ Status = Private->PciIo->Attributes (
+ Private->PciIo,
+ EfiPciIoAttributeOperationSet,
+ Private->PciAttributes,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ FreePool (Private->DevicePath);
+ FreePool (Private->FrameBufferBltLibConfigure);
+ mDriverStarted = FALSE;
+ } else {
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ (VOID **) &Private->PciIo,
+ This->DriverBindingHandle,
+ Private->GraphicsOutputHandle,
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+ return Status;
+}
+
+EFI_DRIVER_BINDING_PROTOCOL mGraphicsOutputDriverBinding = {
+ GraphicsOutputDriverBindingSupported,
+ GraphicsOutputDriverBindingStart,
+ GraphicsOutputDriverBindingStop,
+ 0x10,
+ NULL,
+ NULL
+};
+
+/**
+ The Entry Point for GraphicsOutput driver.
+
+ It installs DriverBinding, ComponentName and ComponentName2 protocol if there is
+ GraphicsInfo HOB passed from Graphics PEIM.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The entry point is executed successfully.
+ @retval other Some error occurs when executing this entry point.
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeGraphicsOutput (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ VOID *HobStart;
+
+ HobStart = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);
+
+ if ((HobStart == NULL) || (GET_GUID_HOB_DATA_SIZE (HobStart) < sizeof (EFI_PEI_GRAPHICS_INFO_HOB))) {
+ return EFI_NOT_FOUND;
+ }
+
+ Status = EfiLibInstallDriverBindingComponentName2 (
+ ImageHandle,
+ SystemTable,
+ &mGraphicsOutputDriverBinding,
+ ImageHandle,
+ &mGraphicsOutputComponentName,
+ &mGraphicsOutputComponentName2
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
diff --git a/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.h b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.h
new file mode 100644
index 0000000..fb1ab7e
--- /dev/null
+++ b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.h
@@ -0,0 +1,59 @@
+/** @file
+ Header file for a generic GOP driver.
+
+Copyright (c) 2016, 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 _GRAPHICS_OUTPUT_DXE_H_
+#define _GRAPHICS_OUTPUT_DXE_H_
+#include <PiDxe.h>
+
+#include <IndustryStandard/Pci.h>
+#include <IndustryStandard/Acpi.h>
+#include <Guid/GraphicsInfoHob.h>
+#include <Protocol/DriverBinding.h>
+#include <Protocol/PciIo.h>
+#include <Protocol/DevicePath.h>
+#include <Protocol/GraphicsOutput.h>
+#include <Protocol/ComponentName.h>
+#include <Protocol/ComponentName2.h>
+
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/HobLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/FrameBufferBltLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiLib.h>
+
+#define MAX_PCI_BAR 6
+
+typedef struct {
+ UINT32 Signature;
+ EFI_HANDLE GraphicsOutputHandle;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE GraphicsOutputMode;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT64 PciAttributes;
+ FRAME_BUFFER_CONFIGURE *FrameBufferBltLibConfigure;
+ UINTN FrameBufferBltLibConfigureSize;
+} GRAPHICS_OUTPUT_PRIVATE_DATA;
+
+#define GRAPHICS_OUTPUT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('g', 'g', 'o', 'p')
+#define GRAPHICS_OUTPUT_PRIVATE_FROM_THIS(a) \
+ CR(a, GRAPHICS_OUTPUT_PRIVATE_DATA, GraphicsOutput, GRAPHICS_OUTPUT_PRIVATE_DATA_SIGNATURE)
+
+extern EFI_COMPONENT_NAME_PROTOCOL mGraphicsOutputComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL mGraphicsOutputComponentName2;
+#endif
diff --git a/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
new file mode 100644
index 0000000..0f7106d
--- /dev/null
+++ b/MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf
@@ -0,0 +1,58 @@
+## @file
+# This driver produces GraphicsOutput protocol based on the GraphicsInfo HOB information.
+#
+# Copyright (c) 2016, 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 = GraphicsOutputDxe
+ FILE_GUID = 20830080-CC28-4169-9836-7F42B8D0C8C9
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeGraphicsOutput
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ GraphicsOutput.h
+ GraphicsOutput.c
+ ComponentName.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ DxeServicesTableLib
+ DebugLib
+ MemoryAllocationLib
+ BaseMemoryLib
+ DevicePathLib
+ FrameBufferBltLib
+ UefiLib
+ HobLib
+
+[Guids]
+ gEfiGraphicsInfoHobGuid # HOB TO_START
+ gEfiGraphicsDeviceInfoHobGuid # HOB TO_START
+
+[Protocols]
+ gEfiGraphicsOutputProtocolGuid # PROTOCOL BY_START
+ gEfiDevicePathProtocolGuid # PROTOCOL BY_START
+ gEfiPciIoProtocolGuid # PROTOCOL TO_START
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 5/5] OvmfPkg: QemuVideoDxe uses MdeModulePkg/FrameBufferLib
2016-10-09 8:49 [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe Ruiyu Ni
` (3 preceding siblings ...)
2016-10-09 8:49 ` [PATCH v2 4/5] MdeModulePkg: Add GraphicsOutputDxe driver Ruiyu Ni
@ 2016-10-09 8:49 ` Ruiyu Ni
2016-10-10 14:56 ` Laszlo Ersek
2016-10-10 6:38 ` [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe Tian, Feng
5 siblings, 1 reply; 12+ messages in thread
From: Ruiyu Ni @ 2016-10-09 8:49 UTC (permalink / raw)
To: edk2-devel; +Cc: Laszlo Ersek, Jordan Justen
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
---
OvmfPkg/OvmfPkgIa32.dsc | 6 ++---
OvmfPkg/OvmfPkgIa32X64.dsc | 6 ++---
OvmfPkg/OvmfPkgX64.dsc | 5 +---
OvmfPkg/QemuVideoDxe/Gop.c | 47 ++++++++++++++++++++++++++++-------
OvmfPkg/QemuVideoDxe/Qemu.h | 17 ++++++++-----
OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 5 ++--
6 files changed, 57 insertions(+), 29 deletions(-)
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 7213197..13c996f 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -115,6 +115,7 @@ [LibraryClasses]
LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
!endif
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
+ FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
!ifdef $(SOURCE_DEBUG_ENABLE)
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
@@ -633,10 +634,7 @@ [Components]
MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
- OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {
- <LibraryClasses>
- BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
- }
+ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
#
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index c27024a..3a90f6f 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -120,6 +120,7 @@ [LibraryClasses]
LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
!endif
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
+ FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
!ifdef $(SOURCE_DEBUG_ENABLE)
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
@@ -642,10 +643,7 @@ [Components.X64]
MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
- OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {
- <LibraryClasses>
- BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
- }
+ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
#
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index c34b266..ea8ed7f 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -640,10 +640,7 @@ [Components]
MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
- OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {
- <LibraryClasses>
- BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
- }
+ OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
#
diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
index 18d0779..532f20e 100644
--- a/OvmfPkg/QemuVideoDxe/Gop.c
+++ b/OvmfPkg/QemuVideoDxe/Gop.c
@@ -1,7 +1,7 @@
/** @file
Graphics Output Protocol functions for the QEMU video controller.
- Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2007 - 2016, 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
@@ -14,8 +14,6 @@
**/
#include "Qemu.h"
-#include <IndustryStandard/Acpi.h>
-#include <Library/BltLib.h>
STATIC
VOID
@@ -159,7 +157,7 @@ Routine Description:
{
QEMU_VIDEO_PRIVATE_DATA *Private;
QEMU_VIDEO_MODE_DATA *ModeData;
-// UINTN Count;
+ RETURN_STATUS Status;
Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);
@@ -201,10 +199,32 @@ Routine Description:
QemuVideoCompleteModeData (Private, This->Mode);
- BltLibConfigure (
- (VOID*)(UINTN) This->Mode->FrameBufferBase,
- This->Mode->Info
- );
+ //
+ // Allocate when using first time.
+ //
+ if (Private->FrameBufferBltConfigure == NULL) {
+ Status = FrameBufferBltConfigure (
+ (VOID*) (UINTN) This->Mode->FrameBufferBase,
+ This->Mode->Info,
+ Private->FrameBufferBltConfigure,
+ &Private->FrameBufferBltConfigureSize
+ );
+ ASSERT (Status == RETURN_BUFFER_TOO_SMALL);
+ Private->FrameBufferBltConfigure =
+ AllocatePool (Private->FrameBufferBltConfigureSize);
+ }
+
+ //
+ // Create the configuration for FrameBufferBltLib
+ //
+ ASSERT (Private->FrameBufferBltConfigure != NULL);
+ Status = FrameBufferBltConfigure (
+ (VOID*) (UINTN) This->Mode->FrameBufferBase,
+ This->Mode->Info,
+ Private->FrameBufferBltConfigure,
+ &Private->FrameBufferBltConfigureSize
+ );
+ ASSERT (Status == RETURN_SUCCESS);
return EFI_SUCCESS;
}
@@ -254,7 +274,9 @@ Returns:
{
EFI_STATUS Status;
EFI_TPL OriginalTPL;
+ QEMU_VIDEO_PRIVATE_DATA *Private;
+ Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);
//
// We have to raise to TPL Notify, so we make an atomic write the frame buffer.
// We would not want a timer based event (Cursor, ...) to come in while we are
@@ -267,7 +289,8 @@ Returns:
case EfiBltBufferToVideo:
case EfiBltVideoFill:
case EfiBltVideoToVideo:
- Status = BltLibGopBlt (
+ Status = FrameBufferBlt (
+ Private->FrameBufferBltConfigure,
BltBuffer,
BltOperation,
SourceX,
@@ -327,6 +350,8 @@ QemuVideoGraphicsOutputConstructor (
Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;
Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
Private->LineBuffer = NULL;
+ Private->FrameBufferBltConfigure = NULL;
+ Private->FrameBufferBltConfigureSize = 0;
//
// Initialize the hardware
@@ -374,6 +399,10 @@ Returns:
FreePool (Private->LineBuffer);
}
+ if (Private->FrameBufferBltConfigure != NULL) {
+ FreePool (Private->FrameBufferBltConfigure);
+ }
+
if (Private->GraphicsOutput.Mode != NULL) {
if (Private->GraphicsOutput.Mode->Info != NULL) {
gBS->FreePool (Private->GraphicsOutput.Mode->Info);
diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
index 52ee20d..8d92ebc 100644
--- a/OvmfPkg/QemuVideoDxe/Qemu.h
+++ b/OvmfPkg/QemuVideoDxe/Qemu.h
@@ -1,7 +1,7 @@
/** @file
QEMU Video Controller Driver
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2016, 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
@@ -35,8 +35,10 @@
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/TimerLib.h>
+#include <Library/FrameBufferBltLib.h>
#include <IndustryStandard/Pci.h>
+#include <IndustryStandard/Acpi.h>
//
// QEMU Video PCI Configuration Header values
@@ -50,11 +52,12 @@
// QEMU Vide Graphical Mode Data
//
typedef struct {
- UINT32 InternalModeIndex; // points into card-specific mode table
- UINT32 HorizontalResolution;
- UINT32 VerticalResolution;
- UINT32 ColorDepth;
- UINT32 RefreshRate;
+ UINT32 InternalModeIndex; // points into card-specific mode table
+ UINT32 HorizontalResolution;
+ UINT32 VerticalResolution;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+ FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
} QEMU_VIDEO_MODE_DATA;
#define PIXEL_RED_SHIFT 0
@@ -119,6 +122,8 @@ typedef struct {
UINT8 *LineBuffer;
QEMU_VIDEO_VARIANT Variant;
+ FRAME_BUFFER_CONFIGURE *FrameBufferBltConfigure;
+ UINTN FrameBufferBltConfigureSize;
} QEMU_VIDEO_PRIVATE_DATA;
///
diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
index ce1ff93..affb6ff 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 - 2016, 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,12 +44,13 @@ [Sources.Ia32, Sources.X64]
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
OptionRomPkg/OptionRomPkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
BaseMemoryLib
- BltLib
+ FrameBufferBltLib
DebugLib
DevicePathLib
MemoryAllocationLib
--
2.9.0.windows.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 5/5] OvmfPkg: QemuVideoDxe uses MdeModulePkg/FrameBufferLib
2016-10-09 8:49 ` [PATCH v2 5/5] OvmfPkg: QemuVideoDxe uses MdeModulePkg/FrameBufferLib Ruiyu Ni
@ 2016-10-10 14:56 ` Laszlo Ersek
0 siblings, 0 replies; 12+ messages in thread
From: Laszlo Ersek @ 2016-10-10 14:56 UTC (permalink / raw)
To: Ruiyu Ni, edk2-devel; +Cc: Jordan Justen, Ard Biesheuvel
On 10/09/16 10:49, Ruiyu Ni wrote:
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> ---
> OvmfPkg/OvmfPkgIa32.dsc | 6 ++---
> OvmfPkg/OvmfPkgIa32X64.dsc | 6 ++---
> OvmfPkg/OvmfPkgX64.dsc | 5 +---
> OvmfPkg/QemuVideoDxe/Gop.c | 47 ++++++++++++++++++++++++++++-------
> OvmfPkg/QemuVideoDxe/Qemu.h | 17 ++++++++-----
> OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 5 ++--
> 6 files changed, 57 insertions(+), 29 deletions(-)
(1) This patch will break ArmVirtPkg, because the following two
additional DSC files include QemuVideoDxe.inf:
ArmVirtPkg/ArmVirtQemu.dsc
ArmVirtPkg/ArmVirtQemuKernel.dsc
So please split up this patch as follows:
- patch 5 -- FrameBufferBltLib class resolution for ArmVirtPkg (2 DSCs),
- patch 6 -- FrameBufferBltLib class resolution for OvmfPkg (3 DSCs),
- patch 7 -- QemuVideoDxe changes.
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 7213197..13c996f 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -115,6 +115,7 @@ [LibraryClasses]
> LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
> !endif
> CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
> + FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
>
> !ifdef $(SOURCE_DEBUG_ENABLE)
> PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
> @@ -633,10 +634,7 @@ [Components]
> MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
> MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
>
> - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {
> - <LibraryClasses>
> - BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
> - }
> + OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
> OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
>
> #
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index c27024a..3a90f6f 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -120,6 +120,7 @@ [LibraryClasses]
> LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
> !endif
> CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
> + FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
>
> !ifdef $(SOURCE_DEBUG_ENABLE)
> PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
> @@ -642,10 +643,7 @@ [Components.X64]
> MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
> MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
>
> - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {
> - <LibraryClasses>
> - BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
> - }
> + OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
> OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
>
> #
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index c34b266..ea8ed7f 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -640,10 +640,7 @@ [Components]
> MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
> MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
>
> - OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {
> - <LibraryClasses>
> - BltLib|OptionRomPkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
> - }
> + OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
> OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
>
> #
(2) I think you missed the FrameBufferBltLib resolution in "OvmfPkgX64.dsc".
> diff --git a/OvmfPkg/QemuVideoDxe/Gop.c b/OvmfPkg/QemuVideoDxe/Gop.c
> index 18d0779..532f20e 100644
> --- a/OvmfPkg/QemuVideoDxe/Gop.c
> +++ b/OvmfPkg/QemuVideoDxe/Gop.c
> @@ -1,7 +1,7 @@
> /** @file
> Graphics Output Protocol functions for the QEMU video controller.
>
> - Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2007 - 2016, 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
> @@ -14,8 +14,6 @@
> **/
>
> #include "Qemu.h"
> -#include <IndustryStandard/Acpi.h>
> -#include <Library/BltLib.h>
>
> STATIC
> VOID
> @@ -159,7 +157,7 @@ Routine Description:
> {
> QEMU_VIDEO_PRIVATE_DATA *Private;
> QEMU_VIDEO_MODE_DATA *ModeData;
> -// UINTN Count;
> + RETURN_STATUS Status;
>
> Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);
>
> @@ -201,10 +199,32 @@ Routine Description:
>
> QemuVideoCompleteModeData (Private, This->Mode);
>
> - BltLibConfigure (
> - (VOID*)(UINTN) This->Mode->FrameBufferBase,
> - This->Mode->Info
> - );
> + //
> + // Allocate when using first time.
> + //
> + if (Private->FrameBufferBltConfigure == NULL) {
> + Status = FrameBufferBltConfigure (
> + (VOID*) (UINTN) This->Mode->FrameBufferBase,
> + This->Mode->Info,
> + Private->FrameBufferBltConfigure,
> + &Private->FrameBufferBltConfigureSize
> + );
> + ASSERT (Status == RETURN_BUFFER_TOO_SMALL);
> + Private->FrameBufferBltConfigure =
> + AllocatePool (Private->FrameBufferBltConfigureSize);
> + }
> +
> + //
> + // Create the configuration for FrameBufferBltLib
> + //
> + ASSERT (Private->FrameBufferBltConfigure != NULL);
> + Status = FrameBufferBltConfigure (
> + (VOID*) (UINTN) This->Mode->FrameBufferBase,
> + This->Mode->Info,
> + Private->FrameBufferBltConfigure,
> + &Private->FrameBufferBltConfigureSize
> + );
> + ASSERT (Status == RETURN_SUCCESS);
>
> return EFI_SUCCESS;
> }
> @@ -254,7 +274,9 @@ Returns:
> {
> EFI_STATUS Status;
> EFI_TPL OriginalTPL;
> + QEMU_VIDEO_PRIVATE_DATA *Private;
>
> + Private = QEMU_VIDEO_PRIVATE_DATA_FROM_GRAPHICS_OUTPUT_THIS (This);
> //
> // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
> // We would not want a timer based event (Cursor, ...) to come in while we are
> @@ -267,7 +289,8 @@ Returns:
> case EfiBltBufferToVideo:
> case EfiBltVideoFill:
> case EfiBltVideoToVideo:
> - Status = BltLibGopBlt (
> + Status = FrameBufferBlt (
> + Private->FrameBufferBltConfigure,
> BltBuffer,
> BltOperation,
> SourceX,
> @@ -327,6 +350,8 @@ QemuVideoGraphicsOutputConstructor (
> Private->GraphicsOutput.Mode->MaxMode = (UINT32) Private->MaxMode;
> Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
> Private->LineBuffer = NULL;
> + Private->FrameBufferBltConfigure = NULL;
> + Private->FrameBufferBltConfigureSize = 0;
>
> //
> // Initialize the hardware
> @@ -374,6 +399,10 @@ Returns:
> FreePool (Private->LineBuffer);
> }
>
> + if (Private->FrameBufferBltConfigure != NULL) {
> + FreePool (Private->FrameBufferBltConfigure);
> + }
> +
> if (Private->GraphicsOutput.Mode != NULL) {
> if (Private->GraphicsOutput.Mode->Info != NULL) {
> gBS->FreePool (Private->GraphicsOutput.Mode->Info);
> diff --git a/OvmfPkg/QemuVideoDxe/Qemu.h b/OvmfPkg/QemuVideoDxe/Qemu.h
> index 52ee20d..8d92ebc 100644
> --- a/OvmfPkg/QemuVideoDxe/Qemu.h
> +++ b/OvmfPkg/QemuVideoDxe/Qemu.h
> @@ -1,7 +1,7 @@
> /** @file
> QEMU Video Controller Driver
>
> - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2006 - 2016, 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
> @@ -35,8 +35,10 @@
> #include <Library/BaseMemoryLib.h>
> #include <Library/DevicePathLib.h>
> #include <Library/TimerLib.h>
> +#include <Library/FrameBufferBltLib.h>
>
> #include <IndustryStandard/Pci.h>
> +#include <IndustryStandard/Acpi.h>
>
> //
> // QEMU Video PCI Configuration Header values
> @@ -50,11 +52,12 @@
> // QEMU Vide Graphical Mode Data
> //
> typedef struct {
> - UINT32 InternalModeIndex; // points into card-specific mode table
> - UINT32 HorizontalResolution;
> - UINT32 VerticalResolution;
> - UINT32 ColorDepth;
> - UINT32 RefreshRate;
> + UINT32 InternalModeIndex; // points into card-specific mode table
> + UINT32 HorizontalResolution;
> + UINT32 VerticalResolution;
> + UINT32 ColorDepth;
> + UINT32 RefreshRate;
> + FRAME_BUFFER_CONFIGURE *FrameBufferConfigure;
> } QEMU_VIDEO_MODE_DATA;
>
> #define PIXEL_RED_SHIFT 0
(3) This hunk is unnecessary; you never reference the new field
QEMU_VIDEO_MODE_DATA.FrameBufferConfigure.
The rest of this patch looks okay to me.
Thanks
Laszlo
> @@ -119,6 +122,8 @@ typedef struct {
>
> UINT8 *LineBuffer;
> QEMU_VIDEO_VARIANT Variant;
> + FRAME_BUFFER_CONFIGURE *FrameBufferBltConfigure;
> + UINTN FrameBufferBltConfigureSize;
> } QEMU_VIDEO_PRIVATE_DATA;
>
> ///
> diff --git a/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf b/OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
> index ce1ff93..affb6ff 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 - 2016, 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,12 +44,13 @@ [Sources.Ia32, Sources.X64]
>
> [Packages]
> MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> OptionRomPkg/OptionRomPkg.dec
> OvmfPkg/OvmfPkg.dec
>
> [LibraryClasses]
> BaseMemoryLib
> - BltLib
> + FrameBufferBltLib
> DebugLib
> DevicePathLib
> MemoryAllocationLib
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe
2016-10-09 8:49 [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe Ruiyu Ni
` (4 preceding siblings ...)
2016-10-09 8:49 ` [PATCH v2 5/5] OvmfPkg: QemuVideoDxe uses MdeModulePkg/FrameBufferLib Ruiyu Ni
@ 2016-10-10 6:38 ` Tian, Feng
5 siblings, 0 replies; 12+ messages in thread
From: Tian, Feng @ 2016-10-10 6:38 UTC (permalink / raw)
To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Tian, Feng
Reviewed-by: Feng Tian <feng.tian@intel.com>
Thanks
Feng
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Sunday, October 9, 2016 4:50 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH v2 0/5] Add FrameBufferBltLib and GraphicsOutputDxe
The patch serials add the FrameBufferBltLib to MdePkg.
Based on the library, a generic GOP driver GraphicsOutputDxe is developed and added to MdeModulePkg.
OvmfPkg/QemuVideoDxe driver is updated to use this new library.
Ruiyu Ni (5):
MdePkg/GraphicsInfoHob: Add GraphicsDeviceInfo HOB GUID and structure
MdeModulePkg: Add FrameBufferBltLib library class
MdeModulePkg: Add FrameBufferBltLib library instance
MdeModulePkg: Add GraphicsOutputDxe driver.
OvmfPkg: QemuVideoDxe uses MdeModulePkg/FrameBufferLib
MdeModulePkg/Include/Library/FrameBufferBltLib.h | 94 +++
.../Library/FrameBufferBltLib/FrameBufferBltLib.c | 704 ++++++++++++++++++++
.../FrameBufferBltLib/FrameBufferBltLib.inf | 34 +
MdeModulePkg/MdeModulePkg.dec | 4 +
MdeModulePkg/MdeModulePkg.dsc | 3 +
.../Console/GraphicsOutputDxe/ComponentName.c | 190 ++++++
.../Console/GraphicsOutputDxe/GraphicsOutput.c | 735 +++++++++++++++++++++
.../Console/GraphicsOutputDxe/GraphicsOutput.h | 59 ++
.../GraphicsOutputDxe/GraphicsOutputDxe.inf | 55 +-
MdePkg/Include/Guid/GraphicsInfoHob.h | 17 +-
MdePkg/MdePkg.dec | 1 +
OvmfPkg/OvmfPkgIa32.dsc | 6 +-
OvmfPkg/OvmfPkgIa32X64.dsc | 6 +-
OvmfPkg/OvmfPkgX64.dsc | 5 +-
OvmfPkg/QemuVideoDxe/Gop.c | 47 +-
OvmfPkg/QemuVideoDxe/Qemu.h | 17 +-
OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf | 5 +-
17 files changed, 1918 insertions(+), 64 deletions(-) create mode 100644 MdeModulePkg/Include/Library/FrameBufferBltLib.h
create mode 100644 MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c
create mode 100644 MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
create mode 100644 MdeModulePkg/Universal/Console/GraphicsOutputDxe/ComponentName.c
create mode 100644 MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.c
create mode 100644 MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutput.h
copy OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf => MdeModulePkg/Universal/Console/GraphicsOutputDxe/GraphicsOutputDxe.inf (53%)
--
2.9.0.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 12+ messages in thread