diff options
author | czhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-02-14 05:56:07 +0000 |
---|---|---|
committer | czhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-02-14 05:56:07 +0000 |
commit | cbafa15e29200af525acbdb5929c8d55b774a8a3 (patch) | |
tree | e4d25eb70c36237814ff2dcc8dc987f3560660ed /MdeModulePkg/Universal | |
parent | 8e1253d59b2458848ccee634a41a5e30e13e5680 (diff) | |
download | edk2-cbafa15e29200af525acbdb5929c8d55b774a8a3.zip edk2-cbafa15e29200af525acbdb5929c8d55b774a8a3.tar.gz edk2-cbafa15e29200af525acbdb5929c8d55b774a8a3.tar.bz2 |
Enhance BGRT driver to install BGRT table upon every ReadyToBoot event
Signed-off: czhang46
Reviewed-by: jjin9, qianouyang
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13010 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r-- | MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c | 119 |
1 files changed, 79 insertions, 40 deletions
diff --git a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c index cde4f06..d365985 100644 --- a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c +++ b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c @@ -1,7 +1,7 @@ /** @file
This module install ACPI Boot Graphics Resource Table (BGRT).
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2011 - 2012, 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
@@ -71,6 +71,8 @@ BMP_IMAGE_HEADER mBmpImageHeaderTemplate = { };
BOOLEAN mAcpiBgrtInstalled = FALSE;
+BOOLEAN mAcpiBgrtStatusChanged = FALSE;
+BOOLEAN mAcpiBgrtBufferChanged = FALSE;
EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphicsResourceTableTemplate = {
{
@@ -157,15 +159,18 @@ SetBootLogo ( {
if (BltBuffer == NULL) {
mIsLogoValid = FALSE;
+ mAcpiBgrtStatusChanged = TRUE;
return EFI_SUCCESS;
}
if (Width == 0 || Height == 0) {
return EFI_INVALID_PARAMETER;
}
-
+
+ mAcpiBgrtBufferChanged = TRUE;
if (mLogoBltBuffer != NULL) {
FreePool (mLogoBltBuffer);
+ mLogoBltBuffer = NULL;
}
mLogoBltBuffer = AllocateCopyPool (
@@ -265,19 +270,13 @@ InstallBootGraphicsResourceTable ( UINT8 *ImageBuffer;
UINTN PaddingSize;
UINTN BmpSize;
+ UINTN OrigBmpSize;
UINT8 *Image;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltPixel;
UINTN Col;
UINTN Row;
//
- // Check whether Boot Graphics Resource Table is already installed.
- //
- if (mAcpiBgrtInstalled) {
- return EFI_SUCCESS;
- }
-
- //
// Get ACPI Table protocol.
//
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
@@ -286,33 +285,68 @@ InstallBootGraphicsResourceTable ( }
//
- // Check whether Logo exist.
+ // Check whether Boot Graphics Resource Table is already installed.
//
- if (mLogoBltBuffer == NULL) {
- return EFI_NOT_FOUND;
+ 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;
+ }
}
- //
- // Allocate memory for BMP file.
- //
- PaddingSize = mLogoWidth & 0x3;
- BmpSize = (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP_IMAGE_HEADER);
- ImageBuffer = BgrtAllocateReservedMemoryBelow4G (BmpSize);
- if (ImageBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
+ 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));
+ }
- 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));
+ //
+ // Allocate memory for BMP file.
+ //
+ PaddingSize = mLogoWidth & 0x3;
+ BmpSize = (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP_IMAGE_HEADER);
+ ImageBuffer = BgrtAllocateReservedMemoryBelow4G (BmpSize);
+ if (ImageBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
- //
- // Convert BLT buffer to BMP file.
- //
- Image = ImageBuffer + sizeof (BMP_IMAGE_HEADER);
- for (Row = 0; Row < mLogoHeight; Row++) {
+ 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++) {
@@ -322,18 +356,20 @@ InstallBootGraphicsResourceTable ( BltPixel++;
}
- //
- // Padding for 4 byte alignment.
- //
- Image += PaddingSize;
+ //
+ // Padding for 4 byte alignment.
+ //
+ Image += PaddingSize;
+ }
+ FreePool (mLogoBltBuffer);
+ mLogoBltBuffer = NULL;
+
+ mBootGraphicsResourceTableTemplate.ImageAddress = (UINT64) (UINTN) ImageBuffer;
+ mBootGraphicsResourceTableTemplate.ImageOffsetX = (UINT32) mLogoDestX;
+ mBootGraphicsResourceTableTemplate.ImageOffsetY = (UINT32) mLogoDestY;
}
- FreePool (mLogoBltBuffer);
- mLogoBltBuffer = NULL;
mBootGraphicsResourceTableTemplate.Status = (UINT8) (mIsLogoValid ? EFI_ACPI_5_0_BGRT_STATUS_VALID : EFI_ACPI_5_0_BGRT_STATUS_INVALID);
- mBootGraphicsResourceTableTemplate.ImageAddress = (UINT64) (UINTN) ImageBuffer;
- mBootGraphicsResourceTableTemplate.ImageOffsetX = (UINT32) mLogoDestX;
- mBootGraphicsResourceTableTemplate.ImageOffsetY = (UINT32) mLogoDestY;
//
// Update Checksum.
@@ -354,6 +390,9 @@ InstallBootGraphicsResourceTable ( }
mAcpiBgrtInstalled = TRUE;
+ mAcpiBgrtStatusChanged = FALSE;
+ mAcpiBgrtBufferChanged = FALSE;
+
return Status;
}
|