mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/BootGraphicsResourceTableDxe: Use BmpSupportLib
https://bugzilla.tianocore.org/show_bug.cgi?id=800 Based on content from the following branch/commits: https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport33bab4031a
ca516b1a61
2b9f111f2e
Use BmpSupportLib to convert a GOP BLT Buffer to the BMP graphics image that is published in an ACPI BGRT table. * Remove use of IndustryStandard/Bmp.h include file * Remove mBmpImageHeaderTemplate. This is handled by BmpSupportLib * Clean up code style with function prototypes at top and all module global variables together * Update SetBootLogo() to use SafeIntLib to check input parameters for overflows. * Remove internal function BgrtAcpiTableChecksum(). Use CalculateCheckSum8() directly from BgrtReadyToBootEventNotify() * Remove InstallBootGraphicsResourceTable(). Move all the code into BgrtReadyToBootEventNotify() that is signaled at ready to boot. * Remove all logic that converts a GOP BLT buffer to a BMP graphics image and use BmpSupportLib function TranslateGopBltToBmp() instead. * Use AllocatePool() instead of AllocatePages() to allocate copy of BMP image that is provided by BGRT. This is required to be compatible with BmpSupportLib function TranslateGopBltToBmp() that uses AllocatePool(). * Zero OemId in BGRT header before filling in value from PCD. * Get size of PcdAcpiDefaultOemId and only copy the the size of the PCD if it is smaller than the size of the OemId field in the BGRT header. * Use WriteUnaligned24() instead of CopyMem() for the OemTableId field of the BGRT header. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
This commit is contained in:
parent
1ec2e7d0e8
commit
53be772103
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
This module install ACPI Boot Graphics Resource Table (BGRT).
|
||||
|
||||
Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -14,7 +14,6 @@
|
|||
#include <Uefi.h>
|
||||
|
||||
#include <IndustryStandard/Acpi.h>
|
||||
#include <IndustryStandard/Bmp.h>
|
||||
|
||||
#include <Protocol/AcpiTable.h>
|
||||
#include <Protocol/GraphicsOutput.h>
|
||||
|
@ -28,44 +27,65 @@
|
|||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/SafeIntLib.h>
|
||||
#include <Library/BmpSupportLib.h>
|
||||
|
||||
/**
|
||||
Update information of logo image drawn on screen.
|
||||
|
||||
@param This The pointer to the Boot Logo protocol instance.
|
||||
@param BltBuffer The BLT buffer for logo drawn on screen. If BltBuffer
|
||||
is set to NULL, it indicates that logo image is no
|
||||
longer on the screen.
|
||||
@param DestinationX X coordinate of destination for the BltBuffer.
|
||||
@param DestinationY Y coordinate of destination for the BltBuffer.
|
||||
@param Width Width of rectangle in BltBuffer in pixels.
|
||||
@param Height Hight of rectangle in BltBuffer in pixels.
|
||||
|
||||
@retval EFI_SUCCESS The boot logo information was updated.
|
||||
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
|
||||
@retval EFI_OUT_OF_RESOURCES The logo information was not updated due to
|
||||
insufficient memory resources.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SetBootLogo (
|
||||
IN EFI_BOOT_LOGO_PROTOCOL *This,
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
|
||||
IN UINTN DestinationX,
|
||||
IN UINTN DestinationY,
|
||||
IN UINTN Width,
|
||||
IN UINTN Height
|
||||
);
|
||||
|
||||
//
|
||||
// Module globals.
|
||||
// Boot Logo Protocol Handle
|
||||
//
|
||||
EFI_EVENT mBootGraphicsReadyToBootEvent;
|
||||
UINTN mBootGraphicsResourceTableKey = 0;
|
||||
EFI_HANDLE mBootLogoHandle = NULL;
|
||||
|
||||
EFI_HANDLE mBootLogoHandle = NULL;
|
||||
BOOLEAN mIsLogoValid = FALSE;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *mLogoBltBuffer = NULL;
|
||||
UINTN mLogoDestX = 0;
|
||||
UINTN mLogoDestY = 0;
|
||||
UINTN mLogoWidth = 0;
|
||||
UINTN mLogoHeight = 0;
|
||||
|
||||
BMP_IMAGE_HEADER mBmpImageHeaderTemplate = {
|
||||
'B', // CharB
|
||||
'M', // CharM
|
||||
0, // Size will be updated at runtime
|
||||
{0, 0}, // Reserved
|
||||
sizeof (BMP_IMAGE_HEADER), // ImageOffset
|
||||
sizeof (BMP_IMAGE_HEADER) - OFFSET_OF (BMP_IMAGE_HEADER, HeaderSize), // HeaderSize
|
||||
0, // PixelWidth will be updated at runtime
|
||||
0, // PixelHeight will be updated at runtime
|
||||
1, // Planes
|
||||
24, // BitPerPixel
|
||||
0, // CompressionType
|
||||
0, // ImageSize will be updated at runtime
|
||||
0, // XPixelsPerMeter
|
||||
0, // YPixelsPerMeter
|
||||
0, // NumberOfColors
|
||||
0 // ImportantColors
|
||||
//
|
||||
// Boot Logo Protocol Instance
|
||||
//
|
||||
EFI_BOOT_LOGO_PROTOCOL mBootLogoProtocolTemplate = {
|
||||
SetBootLogo
|
||||
};
|
||||
|
||||
BOOLEAN mAcpiBgrtInstalled = FALSE;
|
||||
BOOLEAN mAcpiBgrtStatusChanged = FALSE;
|
||||
BOOLEAN mAcpiBgrtBufferChanged = FALSE;
|
||||
EFI_EVENT mBootGraphicsReadyToBootEvent;
|
||||
UINTN mBootGraphicsResourceTableKey = 0;
|
||||
BOOLEAN mIsLogoValid = FALSE;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *mLogoBltBuffer = NULL;
|
||||
UINTN mLogoDestX = 0;
|
||||
UINTN mLogoDestY = 0;
|
||||
UINTN mLogoWidth = 0;
|
||||
UINTN mLogoHeight = 0;
|
||||
BOOLEAN mAcpiBgrtInstalled = FALSE;
|
||||
BOOLEAN mAcpiBgrtStatusChanged = FALSE;
|
||||
BOOLEAN mAcpiBgrtBufferChanged = FALSE;
|
||||
|
||||
//
|
||||
// ACPI Boot Graphics Resource Table template
|
||||
//
|
||||
EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphicsResourceTableTemplate = {
|
||||
{
|
||||
EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE,
|
||||
|
@ -89,37 +109,6 @@ EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphicsResourceTableTemplate = {
|
|||
0 // Image Offset Y
|
||||
};
|
||||
|
||||
/**
|
||||
Update information of logo image drawn on screen.
|
||||
|
||||
@param This The pointer to the Boot Logo protocol instance.
|
||||
@param BltBuffer The BLT buffer for logo drawn on screen. If BltBuffer
|
||||
is set to NULL, it indicates that logo image is no
|
||||
longer on the screen.
|
||||
@param DestinationX X coordinate of destination for the BltBuffer.
|
||||
@param DestinationY Y coordinate of destination for the BltBuffer.
|
||||
@param Width Width of rectangle in BltBuffer in pixels.
|
||||
@param Height Hight of rectangle in BltBuffer in pixels.
|
||||
|
||||
@retval EFI_SUCCESS The boot logo information was updated.
|
||||
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
|
||||
@retval EFI_OUT_OF_RESOURCES The logo information was not updated due to
|
||||
insufficient memory resources.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SetBootLogo (
|
||||
IN EFI_BOOT_LOGO_PROTOCOL *This,
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
|
||||
IN UINTN DestinationX,
|
||||
IN UINTN DestinationY,
|
||||
IN UINTN Width,
|
||||
IN UINTN Height
|
||||
);
|
||||
|
||||
EFI_BOOT_LOGO_PROTOCOL mBootLogoProtocolTemplate = { SetBootLogo };
|
||||
|
||||
/**
|
||||
Update information of logo image drawn on screen.
|
||||
|
||||
|
@ -149,7 +138,9 @@ SetBootLogo (
|
|||
IN UINTN Height
|
||||
)
|
||||
{
|
||||
UINT64 BufferSize;
|
||||
EFI_STATUS Status;
|
||||
UINTN BufferSize;
|
||||
UINT32 Result32;
|
||||
|
||||
if (BltBuffer == NULL) {
|
||||
mIsLogoValid = FALSE;
|
||||
|
@ -157,237 +148,85 @@ SetBootLogo (
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Width and height are not allowed to be zero.
|
||||
//
|
||||
if (Width == 0 || Height == 0) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Verify destination, width, and height do not overflow 32-bit values.
|
||||
// The Boot Graphics Resource Table only has 32-bit fields for these values.
|
||||
//
|
||||
Status = SafeUintnToUint32 (DestinationX, &Result32);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
Status = SafeUintnToUint32 (DestinationY, &Result32);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
Status = SafeUintnToUint32 (Width, &Result32);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
Status = SafeUintnToUint32 (Height, &Result32);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Ensure the Height * Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) does
|
||||
// not overflow UINTN
|
||||
//
|
||||
Status = SafeUintnMult (
|
||||
Width,
|
||||
Height,
|
||||
&BufferSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
Status = SafeUintnMult (
|
||||
BufferSize,
|
||||
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),
|
||||
&BufferSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Update state
|
||||
//
|
||||
mAcpiBgrtBufferChanged = TRUE;
|
||||
|
||||
//
|
||||
// Free old logo buffer
|
||||
//
|
||||
if (mLogoBltBuffer != NULL) {
|
||||
FreePool (mLogoBltBuffer);
|
||||
mLogoBltBuffer = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Ensure the Height * Width doesn't overflow
|
||||
//
|
||||
if (Height > DivU64x64Remainder ((UINTN) ~0, Width, NULL)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
BufferSize = MultU64x64 (Width, Height);
|
||||
|
||||
//
|
||||
// Ensure the BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow
|
||||
//
|
||||
if (BufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
mLogoBltBuffer = AllocateCopyPool (
|
||||
(UINTN)BufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),
|
||||
BltBuffer
|
||||
);
|
||||
//
|
||||
// Allocate new logo buffer
|
||||
//
|
||||
mLogoBltBuffer = AllocateCopyPool (BufferSize, BltBuffer);
|
||||
if (mLogoBltBuffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
mLogoDestX = DestinationX;
|
||||
mLogoDestY = DestinationY;
|
||||
mLogoWidth = Width;
|
||||
mLogoHeight = Height;
|
||||
|
||||
mLogoDestX = DestinationX;
|
||||
mLogoDestY = DestinationY;
|
||||
mLogoWidth = Width;
|
||||
mLogoHeight = Height;
|
||||
mIsLogoValid = TRUE;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function calculates and updates an UINT8 checksum.
|
||||
|
||||
@param[in] Buffer Pointer to buffer to checksum.
|
||||
@param[in] Size Number of bytes to checksum.
|
||||
|
||||
**/
|
||||
VOID
|
||||
BgrtAcpiTableChecksum (
|
||||
IN UINT8 *Buffer,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
UINTN ChecksumOffset;
|
||||
|
||||
ChecksumOffset = OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum);
|
||||
|
||||
//
|
||||
// Set checksum to 0 first.
|
||||
//
|
||||
Buffer[ChecksumOffset] = 0;
|
||||
|
||||
//
|
||||
// Update checksum value.
|
||||
//
|
||||
Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Size);
|
||||
}
|
||||
|
||||
/**
|
||||
Install Boot Graphics Resource Table to ACPI table.
|
||||
|
||||
@return Status code.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
InstallBootGraphicsResourceTable (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
|
||||
UINT8 *ImageBuffer;
|
||||
UINTN PaddingSize;
|
||||
UINTN BmpSize;
|
||||
UINTN OrigBmpSize;
|
||||
UINT8 *Image;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltPixel;
|
||||
UINTN Col;
|
||||
UINTN Row;
|
||||
|
||||
//
|
||||
// Get ACPI Table protocol.
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether Boot Graphics Resource Table is already installed.
|
||||
//
|
||||
if (mAcpiBgrtInstalled) {
|
||||
if (!mAcpiBgrtStatusChanged && !mAcpiBgrtBufferChanged) {
|
||||
//
|
||||
// Nothing has changed
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
//
|
||||
// If BGRT data change happens. Uninstall Orignal AcpiTable first
|
||||
//
|
||||
Status = AcpiTableProtocol->UninstallAcpiTable (
|
||||
AcpiTableProtocol,
|
||||
mBootGraphicsResourceTableKey
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Check whether Logo exist.
|
||||
//
|
||||
if ( mLogoBltBuffer == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (mAcpiBgrtBufferChanged) {
|
||||
//
|
||||
// reserve original BGRT buffer size
|
||||
//
|
||||
OrigBmpSize = mBmpImageHeaderTemplate.ImageSize + sizeof (BMP_IMAGE_HEADER);
|
||||
//
|
||||
// Free orignal BMP memory
|
||||
//
|
||||
if (mBootGraphicsResourceTableTemplate.ImageAddress) {
|
||||
gBS->FreePages(mBootGraphicsResourceTableTemplate.ImageAddress, EFI_SIZE_TO_PAGES(OrigBmpSize));
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate memory for BMP file.
|
||||
//
|
||||
PaddingSize = mLogoWidth & 0x3;
|
||||
|
||||
//
|
||||
// First check mLogoWidth * 3 + PaddingSize doesn't overflow
|
||||
//
|
||||
if (mLogoWidth > (((UINT32) ~0) - PaddingSize) / 3 ) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Second check (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP_IMAGE_HEADER) doesn't overflow
|
||||
//
|
||||
if (mLogoHeight > (((UINT32) ~0) - sizeof (BMP_IMAGE_HEADER)) / (mLogoWidth * 3 + PaddingSize)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// The image should be stored in EfiBootServicesData, allowing the system to reclaim the memory
|
||||
//
|
||||
BmpSize = (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP_IMAGE_HEADER);
|
||||
ImageBuffer = AllocatePages (EFI_SIZE_TO_PAGES (BmpSize));
|
||||
if (ImageBuffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
ZeroMem (ImageBuffer, BmpSize);
|
||||
|
||||
mBmpImageHeaderTemplate.Size = (UINT32) BmpSize;
|
||||
mBmpImageHeaderTemplate.ImageSize = (UINT32) BmpSize - sizeof (BMP_IMAGE_HEADER);
|
||||
mBmpImageHeaderTemplate.PixelWidth = (UINT32) mLogoWidth;
|
||||
mBmpImageHeaderTemplate.PixelHeight = (UINT32) mLogoHeight;
|
||||
CopyMem (ImageBuffer, &mBmpImageHeaderTemplate, sizeof (BMP_IMAGE_HEADER));
|
||||
|
||||
//
|
||||
// Convert BLT buffer to BMP file.
|
||||
//
|
||||
Image = ImageBuffer + sizeof (BMP_IMAGE_HEADER);
|
||||
for (Row = 0; Row < mLogoHeight; Row++) {
|
||||
BltPixel = &mLogoBltBuffer[(mLogoHeight - Row - 1) * mLogoWidth];
|
||||
|
||||
for (Col = 0; Col < mLogoWidth; Col++) {
|
||||
*Image++ = BltPixel->Blue;
|
||||
*Image++ = BltPixel->Green;
|
||||
*Image++ = BltPixel->Red;
|
||||
BltPixel++;
|
||||
}
|
||||
|
||||
//
|
||||
// Padding for 4 byte alignment.
|
||||
//
|
||||
Image += PaddingSize;
|
||||
}
|
||||
FreePool (mLogoBltBuffer);
|
||||
mLogoBltBuffer = NULL;
|
||||
|
||||
mBootGraphicsResourceTableTemplate.ImageAddress = (UINT64) (UINTN) ImageBuffer;
|
||||
mBootGraphicsResourceTableTemplate.ImageOffsetX = (UINT32) mLogoDestX;
|
||||
mBootGraphicsResourceTableTemplate.ImageOffsetY = (UINT32) mLogoDestY;
|
||||
}
|
||||
|
||||
mBootGraphicsResourceTableTemplate.Status = (UINT8) (mIsLogoValid ? EFI_ACPI_5_0_BGRT_STATUS_VALID : EFI_ACPI_5_0_BGRT_STATUS_INVALID);
|
||||
|
||||
//
|
||||
// Update Checksum.
|
||||
//
|
||||
BgrtAcpiTableChecksum ((UINT8 *) &mBootGraphicsResourceTableTemplate, sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE));
|
||||
|
||||
//
|
||||
// Publish Boot Graphics Resource Table.
|
||||
//
|
||||
Status = AcpiTableProtocol->InstallAcpiTable (
|
||||
AcpiTableProtocol,
|
||||
&mBootGraphicsResourceTableTemplate,
|
||||
sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE),
|
||||
&mBootGraphicsResourceTableKey
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
mAcpiBgrtInstalled = TRUE;
|
||||
mAcpiBgrtStatusChanged = FALSE;
|
||||
mAcpiBgrtBufferChanged = FALSE;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to
|
||||
install the Boot Graphics Resource Table.
|
||||
|
@ -399,11 +238,131 @@ InstallBootGraphicsResourceTable (
|
|||
VOID
|
||||
EFIAPI
|
||||
BgrtReadyToBootEventNotify (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
InstallBootGraphicsResourceTable ();
|
||||
EFI_STATUS Status;
|
||||
EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
|
||||
VOID *ImageBuffer;
|
||||
UINT32 BmpSize;
|
||||
|
||||
//
|
||||
// Get ACPI Table protocol.
|
||||
//
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiAcpiTableProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &AcpiTableProtocol
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether Boot Graphics Resource Table is already installed.
|
||||
//
|
||||
if (mAcpiBgrtInstalled) {
|
||||
if (!mAcpiBgrtStatusChanged && !mAcpiBgrtBufferChanged) {
|
||||
//
|
||||
// Nothing has changed
|
||||
//
|
||||
return;
|
||||
} else {
|
||||
//
|
||||
// If BGRT data change happens, then uninstall orignal AcpiTable first
|
||||
//
|
||||
Status = AcpiTableProtocol->UninstallAcpiTable (
|
||||
AcpiTableProtocol,
|
||||
mBootGraphicsResourceTableKey
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Check whether Logo exists
|
||||
//
|
||||
if (mLogoBltBuffer == NULL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mAcpiBgrtBufferChanged) {
|
||||
//
|
||||
// Free the old BMP image buffer
|
||||
//
|
||||
ImageBuffer = (UINT8 *)(UINTN)mBootGraphicsResourceTableTemplate.ImageAddress;
|
||||
if (ImageBuffer != NULL) {
|
||||
FreePool (ImageBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert GOP Blt buffer to BMP image. Pass in ImageBuffer set to NULL
|
||||
// so the BMP image is allocated by TranslateGopBltToBmp().
|
||||
//
|
||||
ImageBuffer = NULL;
|
||||
Status = TranslateGopBltToBmp (
|
||||
mLogoBltBuffer,
|
||||
(UINT32)mLogoHeight,
|
||||
(UINT32)mLogoWidth,
|
||||
&ImageBuffer,
|
||||
&BmpSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Free the logo buffer
|
||||
//
|
||||
FreePool (mLogoBltBuffer);
|
||||
mLogoBltBuffer = NULL;
|
||||
|
||||
//
|
||||
// Update BMP image fields of the Boot Graphics Resource Table
|
||||
//
|
||||
mBootGraphicsResourceTableTemplate.ImageAddress = (UINT64)(UINTN)ImageBuffer;
|
||||
mBootGraphicsResourceTableTemplate.ImageOffsetX = (UINT32)mLogoDestX;
|
||||
mBootGraphicsResourceTableTemplate.ImageOffsetY = (UINT32)mLogoDestY;
|
||||
}
|
||||
|
||||
//
|
||||
// Update Status field of Boot Graphics Resource Table
|
||||
//
|
||||
if (mIsLogoValid) {
|
||||
mBootGraphicsResourceTableTemplate.Status = EFI_ACPI_5_0_BGRT_STATUS_VALID;
|
||||
} else {
|
||||
mBootGraphicsResourceTableTemplate.Status = EFI_ACPI_5_0_BGRT_STATUS_INVALID;
|
||||
}
|
||||
|
||||
//
|
||||
// Update Checksum of Boot Graphics Resource Table
|
||||
//
|
||||
mBootGraphicsResourceTableTemplate.Header.Checksum = 0;
|
||||
mBootGraphicsResourceTableTemplate.Header.Checksum =
|
||||
CalculateCheckSum8 (
|
||||
(UINT8 *)&mBootGraphicsResourceTableTemplate,
|
||||
sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE)
|
||||
);
|
||||
|
||||
//
|
||||
// Publish Boot Graphics Resource Table.
|
||||
//
|
||||
Status = AcpiTableProtocol->InstallAcpiTable (
|
||||
AcpiTableProtocol,
|
||||
&mBootGraphicsResourceTableTemplate,
|
||||
sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE),
|
||||
&mBootGraphicsResourceTableKey
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAcpiBgrtInstalled = TRUE;
|
||||
mAcpiBgrtStatusChanged = FALSE;
|
||||
mAcpiBgrtBufferChanged = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -419,23 +378,27 @@ BgrtReadyToBootEventNotify (
|
|||
EFI_STATUS
|
||||
EFIAPI
|
||||
BootGraphicsDxeEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT64 OemTableId;
|
||||
EFI_STATUS Status;
|
||||
EFI_ACPI_DESCRIPTION_HEADER *Header;
|
||||
|
||||
//
|
||||
// Update Header fields of Boot Graphics Resource Table from PCDs
|
||||
//
|
||||
Header = &mBootGraphicsResourceTableTemplate.Header;
|
||||
ZeroMem (Header->OemId, sizeof (Header->OemId));
|
||||
CopyMem (
|
||||
mBootGraphicsResourceTableTemplate.Header.OemId,
|
||||
Header->OemId,
|
||||
PcdGetPtr (PcdAcpiDefaultOemId),
|
||||
sizeof (mBootGraphicsResourceTableTemplate.Header.OemId)
|
||||
MIN (PcdGetSize (PcdAcpiDefaultOemId), sizeof (Header->OemId))
|
||||
);
|
||||
OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
|
||||
CopyMem (&mBootGraphicsResourceTableTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
|
||||
mBootGraphicsResourceTableTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
|
||||
mBootGraphicsResourceTableTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
|
||||
mBootGraphicsResourceTableTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
|
||||
WriteUnaligned64 (&Header->OemTableId, PcdGet64 (PcdAcpiDefaultOemTableId));
|
||||
Header->OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
|
||||
Header->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
|
||||
Header->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
|
||||
|
||||
//
|
||||
// Install Boot Logo protocol.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## @file
|
||||
# This module install ACPI Boot Graphics Resource Table (BGRT).
|
||||
#
|
||||
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -43,6 +43,8 @@
|
|||
UefiBootServicesTableLib
|
||||
DebugLib
|
||||
PcdLib
|
||||
SafeIntLib
|
||||
BmpSupportLib
|
||||
|
||||
[Protocols]
|
||||
gEfiAcpiTableProtocolGuid ## CONSUMES
|
||||
|
|
Loading…
Reference in New Issue