Add Acpi50 FPDT and BGRT module into MdeModulePkg.
Signed-off-by: lgao4 Reviewed-by: hhtian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12804 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
9381365cf1
commit
0284e90cc1
98
MdeModulePkg/Include/Guid/FirmwarePerformance.h
Normal file
98
MdeModulePkg/Include/Guid/FirmwarePerformance.h
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/** @file
|
||||||
|
ACPI Firmware Performance Data Table (FPDT) implementation specific definitions.
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _FIRMWARE_PERFORMANCE_GUID_H_
|
||||||
|
#define _FIRMWARE_PERFORMANCE_GUID_H_
|
||||||
|
|
||||||
|
#include <IndustryStandard/Acpi50.h>
|
||||||
|
#include <PiPei.h>
|
||||||
|
#include <Ppi/SecPerformance.h>
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This GUID is used for FPDT implementation specific EFI Variable, LockBox and Hob.
|
||||||
|
///
|
||||||
|
/// EFI Variable:
|
||||||
|
/// GUID - gEfiFirmwarePerformanceGuid
|
||||||
|
/// Name - EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
|
||||||
|
/// Data - FIRMWARE_PERFORMANCE_VARIABLE
|
||||||
|
///
|
||||||
|
/// LockBox:
|
||||||
|
/// GUID - gEfiFirmwarePerformanceGuid
|
||||||
|
/// Data - EFI_ACPI_BASIC_S3_SUSPEND_PERFORMANCE_RECORD
|
||||||
|
///
|
||||||
|
/// Hob:
|
||||||
|
/// GUID - gEfiFirmwarePerformanceGuid
|
||||||
|
/// Data - FIRMWARE_SEC_PERFORMANCE (defined in <Ppi/SecPerformance.h>)
|
||||||
|
///
|
||||||
|
#define EFI_FIRMWARE_PERFORMANCE_GUID \
|
||||||
|
{ \
|
||||||
|
0xc095791a, 0x3001, 0x47b2, {0x80, 0xc9, 0xea, 0xc7, 0x31, 0x9f, 0x2f, 0xa4 } \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME L"FirmwarePerformance"
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Firmware Performance Data Table.
|
||||||
|
/// This structure will be installed into ACPI table as FPDT in normal boot path.
|
||||||
|
///
|
||||||
|
typedef struct {
|
||||||
|
EFI_ACPI_DESCRIPTION_HEADER Header; ///< Common ACPI description table header.
|
||||||
|
EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD BootPointerRecord; ///< Basic Boot Performance Table Pointer record.
|
||||||
|
EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD S3PointerRecord; ///< S3 Performance Table Pointer record.
|
||||||
|
} FIRMWARE_PERFORMANCE_TABLE;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// S3 Performance Data Table.
|
||||||
|
/// This structure contains S3 performance records which will be updated in S3
|
||||||
|
/// suspend and S3 resume boot path.
|
||||||
|
///
|
||||||
|
typedef struct {
|
||||||
|
EFI_ACPI_5_0_FPDT_PERFORMANCE_TABLE_HEADER Header; ///< Common ACPI table header.
|
||||||
|
EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD S3Resume; ///< Basic S3 Resume performance record.
|
||||||
|
EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3Suspend; ///< Basic S3 Suspend performance record.
|
||||||
|
} S3_PERFORMANCE_TABLE;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Basic Boot Performance Data Table.
|
||||||
|
/// This structure contains BasicBoot performance record.
|
||||||
|
///
|
||||||
|
typedef struct {
|
||||||
|
EFI_ACPI_5_0_FPDT_PERFORMANCE_TABLE_HEADER Header; ///< Common ACPI table header.
|
||||||
|
EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD BasicBoot; ///< Basic Boot Resume performance record.
|
||||||
|
} BOOT_PERFORMANCE_TABLE;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Performance data pointed by Performance Pointer Record.
|
||||||
|
///
|
||||||
|
typedef struct {
|
||||||
|
BOOT_PERFORMANCE_TABLE BootPerformance; ///< Basic Boot Performance.
|
||||||
|
S3_PERFORMANCE_TABLE S3Performance; ///< S3 performance.
|
||||||
|
} FIRMWARE_PERFORMANCE_RUNTIME_DATA;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Variable defined for FPDT implementation.
|
||||||
|
/// This Variable is produced by FPDT DXE module and consumed by FPDT PEIM.
|
||||||
|
///
|
||||||
|
typedef struct {
|
||||||
|
EFI_PHYSICAL_ADDRESS BootPerformanceTablePointer; ///< Pointer to Boot Performance Table.
|
||||||
|
EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer; ///< Pointer to S3 Performance Table.
|
||||||
|
} FIRMWARE_PERFORMANCE_VARIABLE;
|
||||||
|
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
extern EFI_GUID gEfiFirmwarePerformanceGuid;
|
||||||
|
|
||||||
|
#endif
|
@ -237,6 +237,10 @@
|
|||||||
## Include/Guid/MtcVendor.h
|
## Include/Guid/MtcVendor.h
|
||||||
gMtcVendorGuid = { 0xeb704011, 0x1402, 0x11d3, { 0x8e, 0x77, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }}
|
gMtcVendorGuid = { 0xeb704011, 0x1402, 0x11d3, { 0x8e, 0x77, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }}
|
||||||
|
|
||||||
|
## Guid for Firmware Performance Data Table (FPDT) implementation.
|
||||||
|
# Include/Guid/FirmwarePerformance.h
|
||||||
|
gEfiFirmwarePerformanceGuid = { 0xc095791a, 0x3001, 0x47b2, { 0x80, 0xc9, 0xea, 0xc7, 0x31, 0x9f, 0x2f, 0xa4 }}
|
||||||
|
|
||||||
[Ppis]
|
[Ppis]
|
||||||
## Include/Ppi/AtaController.h
|
## Include/Ppi/AtaController.h
|
||||||
gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
|
gPeiAtaControllerPpiGuid = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
|
||||||
@ -449,6 +453,9 @@
|
|||||||
## If TRUE, recovery from FAT USB disk will be supported.
|
## If TRUE, recovery from FAT USB disk will be supported.
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdRecoveryOnFatUsbDisk|TRUE|BOOLEAN|0x00010063
|
gEfiMdeModulePkgTokenSpaceGuid.PcdRecoveryOnFatUsbDisk|TRUE|BOOLEAN|0x00010063
|
||||||
|
|
||||||
|
## If TRUE, S3 performance data will be supported in ACPI FPDT table.
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support|TRUE|BOOLEAN|0x00010064
|
||||||
|
|
||||||
[PcdsFeatureFlag.IA32, PcdsFeatureFlag.X64]
|
[PcdsFeatureFlag.IA32, PcdsFeatureFlag.X64]
|
||||||
##
|
##
|
||||||
# This feature flag specifies whether DxeIpl switches to long mode to enter DXE phase.
|
# This feature flag specifies whether DxeIpl switches to long mode to enter DXE phase.
|
||||||
|
@ -305,6 +305,13 @@
|
|||||||
MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
|
MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
|
||||||
MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf
|
MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf
|
||||||
|
|
||||||
|
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf {
|
||||||
|
<LibraryClasses>
|
||||||
|
LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
|
||||||
|
}
|
||||||
|
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
|
||||||
|
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
|
||||||
|
|
||||||
[Components.IA32, Components.X64, Components.IPF]
|
[Components.IA32, Components.X64, Components.IPF]
|
||||||
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
|
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
|
||||||
MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
|
MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
|
||||||
@ -331,4 +338,5 @@
|
|||||||
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
|
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
|
||||||
MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
|
MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
|
||||||
MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.inf
|
MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.inf
|
||||||
|
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf
|
||||||
|
|
||||||
|
@ -0,0 +1,422 @@
|
|||||||
|
/** @file
|
||||||
|
This module install ACPI Boot Graphics Resource Table (BGRT).
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <Uefi.h>
|
||||||
|
|
||||||
|
#include <IndustryStandard/Acpi50.h>
|
||||||
|
#include <IndustryStandard/Bmp.h>
|
||||||
|
|
||||||
|
#include <Protocol/AcpiTable.h>
|
||||||
|
#include <Protocol/GraphicsOutput.h>
|
||||||
|
#include <Protocol/BootLogo.h>
|
||||||
|
|
||||||
|
#include <Guid/EventGroup.h>
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// ACPI table information used to initialize tables.
|
||||||
|
//
|
||||||
|
#define EFI_ACPI_OEM_ID "INTEL"
|
||||||
|
#define EFI_ACPI_OEM_TABLE_ID 0x2020204F4E414954ULL // "TIANO "
|
||||||
|
#define EFI_ACPI_OEM_REVISION 0x00000001
|
||||||
|
#define EFI_ACPI_CREATOR_ID 0x5446534D // TBD "MSFT"
|
||||||
|
#define EFI_ACPI_CREATOR_REVISION 0x01000013 // TBD
|
||||||
|
|
||||||
|
//
|
||||||
|
// Module globals.
|
||||||
|
//
|
||||||
|
EFI_EVENT mBootGraphicsReadyToBootEvent;
|
||||||
|
UINTN mBootGraphicsResourceTableKey = 0;
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOLEAN mAcpiBgrtInstalled = FALSE;
|
||||||
|
|
||||||
|
EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE mBootGraphicsResourceTableTemplate = {
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_SIGNATURE,
|
||||||
|
sizeof (EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE),
|
||||||
|
EFI_ACPI_5_0_BOOT_GRAPHICS_RESOURCE_TABLE_REVISION, // Revision
|
||||||
|
0x00, // Checksum will be updated at runtime
|
||||||
|
//
|
||||||
|
// It is expected that these values will be updated at runtime.
|
||||||
|
//
|
||||||
|
EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long field
|
||||||
|
EFI_ACPI_OEM_TABLE_ID, // OEM table identification(8 bytes long)
|
||||||
|
EFI_ACPI_OEM_REVISION, // OEM revision number
|
||||||
|
EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID
|
||||||
|
EFI_ACPI_CREATOR_REVISION, // ASL compiler revision number
|
||||||
|
},
|
||||||
|
EFI_ACPI_5_0_BGRT_VERSION, // Version
|
||||||
|
EFI_ACPI_5_0_BGRT_STATUS_VALID, // Status
|
||||||
|
EFI_ACPI_5_0_BGRT_IMAGE_TYPE_BMP, // Image Type
|
||||||
|
0, // Image Address
|
||||||
|
0, // Image Offset X
|
||||||
|
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.
|
||||||
|
|
||||||
|
@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
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (BltBuffer == NULL) {
|
||||||
|
mIsLogoValid = FALSE;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Width == 0 || Height == 0) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mLogoBltBuffer != NULL) {
|
||||||
|
FreePool (mLogoBltBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
mLogoBltBuffer = AllocateCopyPool (
|
||||||
|
Width * Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),
|
||||||
|
BltBuffer
|
||||||
|
);
|
||||||
|
if (mLogoBltBuffer == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allocate EfiReservedMemoryType below 4G memory address.
|
||||||
|
|
||||||
|
This function allocates EfiReservedMemoryType below 4G memory address.
|
||||||
|
|
||||||
|
@param[in] Size Size of memory to allocate.
|
||||||
|
|
||||||
|
@return Allocated address for output.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID *
|
||||||
|
BgrtAllocateReservedMemoryBelow4G (
|
||||||
|
IN UINTN Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Pages;
|
||||||
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
VOID *Buffer;
|
||||||
|
|
||||||
|
Pages = EFI_SIZE_TO_PAGES (Size);
|
||||||
|
Address = 0xffffffff;
|
||||||
|
|
||||||
|
Status = gBS->AllocatePages (
|
||||||
|
AllocateMaxAddress,
|
||||||
|
EfiReservedMemoryType,
|
||||||
|
Pages,
|
||||||
|
&Address
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
Buffer = (VOID *) (UINTN) Address;
|
||||||
|
ZeroMem (Buffer, Size);
|
||||||
|
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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;
|
||||||
|
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);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.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.
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to
|
||||||
|
install the Boot Graphics Resource Table.
|
||||||
|
|
||||||
|
@param[in] Event The Event that is being processed.
|
||||||
|
@param[in] Context The Event Context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
BgrtReadyToBootEventNotify (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
InstallBootGraphicsResourceTable ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
The module Entry Point of the Boot Graphics Resource Table DXE driver.
|
||||||
|
|
||||||
|
@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
|
||||||
|
BootGraphicsDxeEntryPoint (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Install Boot Logo protocol.
|
||||||
|
//
|
||||||
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
|
&mBootLogoHandle,
|
||||||
|
&gEfiBootLogoProtocolGuid,
|
||||||
|
&mBootLogoProtocolTemplate,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register notify function to install BGRT on ReadyToBoot Event.
|
||||||
|
//
|
||||||
|
Status = gBS->CreateEventEx (
|
||||||
|
EVT_NOTIFY_SIGNAL,
|
||||||
|
TPL_CALLBACK,
|
||||||
|
BgrtReadyToBootEventNotify,
|
||||||
|
NULL,
|
||||||
|
&gEfiEventReadyToBootGuid,
|
||||||
|
&mBootGraphicsReadyToBootEvent
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
## @file
|
||||||
|
# This module install ACPI Boot Graphics Resource Table (BGRT).
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
# This program and the accompanying materials
|
||||||
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
# which accompanies this distribution. The full text of the license may be found at
|
||||||
|
# http://opensource.org/licenses/bsd-license.php
|
||||||
|
#
|
||||||
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = BootGraphicsResourceTableDxe
|
||||||
|
FILE_GUID = B8E62775-BB0A-43f0-A843-5BE8B14F8CCD
|
||||||
|
MODULE_TYPE = UEFI_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = BootGraphicsDxeEntryPoint
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
BootGraphicsResourceTableDxe.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
BaseLib
|
||||||
|
BaseMemoryLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
UefiLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
DebugLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiBootLogoProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiEventReadyToBootGuid ## CONSUMES
|
@ -0,0 +1,638 @@
|
|||||||
|
/** @file
|
||||||
|
This module install ACPI Firmware Performance Data Table (FPDT).
|
||||||
|
|
||||||
|
This module register report status code listener to collect performance data
|
||||||
|
for Firmware Basic Boot Performance Record and install FPDT to ACPI table.
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiDxe.h>
|
||||||
|
|
||||||
|
#include <IndustryStandard/Acpi50.h>
|
||||||
|
|
||||||
|
#include <Protocol/ReportStatusCodeHandler.h>
|
||||||
|
#include <Protocol/AcpiTable.h>
|
||||||
|
|
||||||
|
#include <Guid/Acpi.h>
|
||||||
|
#include <Guid/FirmwarePerformance.h>
|
||||||
|
#include <Guid/EventGroup.h>
|
||||||
|
#include <Guid/EventLegacyBios.h>
|
||||||
|
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/TimerLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// ACPI table information used to initialize tables.
|
||||||
|
//
|
||||||
|
#define EFI_ACPI_OEM_ID "INTEL"
|
||||||
|
#define EFI_ACPI_OEM_TABLE_ID 0x2020204F4E414954ULL // "TIANO "
|
||||||
|
#define EFI_ACPI_OEM_REVISION 0x00000001
|
||||||
|
#define EFI_ACPI_CREATOR_ID 0x5446534D // TBD "MSFT"
|
||||||
|
#define EFI_ACPI_CREATOR_REVISION 0x01000013 // TBD
|
||||||
|
|
||||||
|
EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
|
||||||
|
|
||||||
|
EFI_EVENT mReadyToBootEvent;
|
||||||
|
EFI_EVENT mLegacyBootEvent;
|
||||||
|
EFI_EVENT mExitBootServicesEvent;
|
||||||
|
UINTN mFirmwarePerformanceTableTemplateKey = 0;
|
||||||
|
|
||||||
|
FIRMWARE_PERFORMANCE_RUNTIME_DATA *mPerformanceRuntimeData = NULL;
|
||||||
|
BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL;
|
||||||
|
S3_PERFORMANCE_TABLE *mAcpiS3PerformanceTable = NULL;
|
||||||
|
|
||||||
|
FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate = {
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE,
|
||||||
|
sizeof (FIRMWARE_PERFORMANCE_TABLE),
|
||||||
|
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION, // Revision
|
||||||
|
0x00, // Checksum will be updated at runtime
|
||||||
|
//
|
||||||
|
// It is expected that these values will be updated at runtime.
|
||||||
|
//
|
||||||
|
EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long field
|
||||||
|
EFI_ACPI_OEM_TABLE_ID, // OEM table identification(8 bytes long)
|
||||||
|
EFI_ACPI_OEM_REVISION, // OEM revision number
|
||||||
|
EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID
|
||||||
|
EFI_ACPI_CREATOR_REVISION, // ASL compiler revision number
|
||||||
|
},
|
||||||
|
//
|
||||||
|
// Firmware Basic Boot Performance Table Pointer Record.
|
||||||
|
//
|
||||||
|
{
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_FPDT_RECORD_TYPE_FIRMWARE_BASIC_BOOT_POINTER , // Type
|
||||||
|
sizeof (EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD), // Length
|
||||||
|
EFI_ACPI_5_0_FPDT_RECORD_REVISION_FIRMWARE_BASIC_BOOT_POINTER // Revision
|
||||||
|
},
|
||||||
|
0, // Reserved
|
||||||
|
0 // BootPerformanceTablePointer will be updated at runtime.
|
||||||
|
},
|
||||||
|
//
|
||||||
|
// S3 Performance Table Pointer Record.
|
||||||
|
//
|
||||||
|
{
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_FPDT_RECORD_TYPE_S3_PERFORMANCE_TABLE_POINTER, // Type
|
||||||
|
sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD), // Length
|
||||||
|
EFI_ACPI_5_0_FPDT_RECORD_REVISION_S3_PERFORMANCE_TABLE_POINTER // Revision
|
||||||
|
},
|
||||||
|
0, // Reserved
|
||||||
|
0 // S3PerformanceTablePointer will be updated at runtime.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = {
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE,
|
||||||
|
sizeof (BOOT_PERFORMANCE_TABLE)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT, // Type
|
||||||
|
sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD), // Length
|
||||||
|
EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT // Revision
|
||||||
|
},
|
||||||
|
0, // Reserved
|
||||||
|
//
|
||||||
|
// These values will be updated at runtime.
|
||||||
|
//
|
||||||
|
0, // ResetEnd
|
||||||
|
0, // OsLoaderLoadImageStart
|
||||||
|
0, // OsLoaderStartImageStart
|
||||||
|
0, // ExitBootServicesEntry
|
||||||
|
0 // ExitBootServicesExit
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
S3_PERFORMANCE_TABLE mS3PerformanceTableTemplate = {
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE,
|
||||||
|
sizeof (S3_PERFORMANCE_TABLE)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_RESUME, // Type
|
||||||
|
sizeof (EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD), // Length
|
||||||
|
EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_RESUME // Revision
|
||||||
|
},
|
||||||
|
//
|
||||||
|
// These values will be updated by Firmware Performance PEIM.
|
||||||
|
//
|
||||||
|
0, // ResumeCount
|
||||||
|
0, // FullResume
|
||||||
|
0 // AverageResume
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{
|
||||||
|
EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_SUSPEND, // Type
|
||||||
|
sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD), // Length
|
||||||
|
EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_SUSPEND // Revision
|
||||||
|
},
|
||||||
|
//
|
||||||
|
// These values will be updated bye Firmware Performance SMM driver.
|
||||||
|
//
|
||||||
|
0, // SuspendStart
|
||||||
|
0 // SuspendEnd
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
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
|
||||||
|
FpdtAcpiTableChecksum (
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allocate EfiReservedMemoryType below 4G memory address.
|
||||||
|
|
||||||
|
This function allocates EfiReservedMemoryType below 4G memory address.
|
||||||
|
|
||||||
|
@param[in] Size Size of memory to allocate.
|
||||||
|
|
||||||
|
@return Allocated address for output.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID *
|
||||||
|
FpdtAllocateReservedMemoryBelow4G (
|
||||||
|
IN UINTN Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Pages;
|
||||||
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
VOID *Buffer;
|
||||||
|
|
||||||
|
Pages = EFI_SIZE_TO_PAGES (Size);
|
||||||
|
Address = 0xffffffff;
|
||||||
|
|
||||||
|
Status = gBS->AllocatePages (
|
||||||
|
AllocateMaxAddress,
|
||||||
|
EfiReservedMemoryType,
|
||||||
|
Pages,
|
||||||
|
&Address
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
Buffer = (VOID *) (UINTN) Address;
|
||||||
|
ZeroMem (Buffer, Size);
|
||||||
|
|
||||||
|
return Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Install ACPI Firmware Performance Data Table (FPDT).
|
||||||
|
|
||||||
|
@return Status code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
InstallFirmwarePerformanceDataTable (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
|
||||||
|
FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
|
||||||
|
EFI_PHYSICAL_ADDRESS Address;
|
||||||
|
UINTN Size;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get AcpiTable Protocol.
|
||||||
|
//
|
||||||
|
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare memory for runtime Performance Record.
|
||||||
|
//
|
||||||
|
mPerformanceRuntimeData = NULL;
|
||||||
|
ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable));
|
||||||
|
//
|
||||||
|
// Try to allocate the same runtime buffer as last time boot.
|
||||||
|
//
|
||||||
|
Size = sizeof (FIRMWARE_PERFORMANCE_VARIABLE);
|
||||||
|
Status = gRT->GetVariable (
|
||||||
|
EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
|
||||||
|
&gEfiFirmwarePerformanceGuid,
|
||||||
|
NULL,
|
||||||
|
&Size,
|
||||||
|
&PerformanceVariable
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Address = PerformanceVariable.BootPerformanceTablePointer;
|
||||||
|
Status = gBS->AllocatePages (
|
||||||
|
AllocateAddress,
|
||||||
|
EfiReservedMemoryType,
|
||||||
|
EFI_SIZE_TO_PAGES (sizeof (FIRMWARE_PERFORMANCE_RUNTIME_DATA)),
|
||||||
|
&Address
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
mPerformanceRuntimeData = (FIRMWARE_PERFORMANCE_RUNTIME_DATA *) (UINTN) Address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mPerformanceRuntimeData == NULL) {
|
||||||
|
//
|
||||||
|
// Fail to allocate at specified address, continue to allocate at any address.
|
||||||
|
//
|
||||||
|
mPerformanceRuntimeData = FpdtAllocateReservedMemoryBelow4G (sizeof (FIRMWARE_PERFORMANCE_RUNTIME_DATA));
|
||||||
|
}
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Performance Runtime Data address = 0x%x\n", mPerformanceRuntimeData));
|
||||||
|
|
||||||
|
if (mPerformanceRuntimeData == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Boot Performance Table.
|
||||||
|
//
|
||||||
|
mAcpiBootPerformanceTable = &mPerformanceRuntimeData->BootPerformance;
|
||||||
|
CopyMem (mAcpiBootPerformanceTable, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
|
||||||
|
//
|
||||||
|
// Save Boot Performance Table address to Variable for use in S4 resume.
|
||||||
|
//
|
||||||
|
PerformanceVariable.BootPerformanceTablePointer = (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiBootPerformanceTable;
|
||||||
|
//
|
||||||
|
// Update Boot Performance Table Pointer in template.
|
||||||
|
//
|
||||||
|
mFirmwarePerformanceTableTemplate.BootPointerRecord.BootPerformanceTablePointer = (UINT64) (UINTN) mAcpiBootPerformanceTable;
|
||||||
|
|
||||||
|
if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {
|
||||||
|
//
|
||||||
|
// Prepare S3 Performance Table.
|
||||||
|
//
|
||||||
|
mAcpiS3PerformanceTable = &mPerformanceRuntimeData->S3Performance;
|
||||||
|
CopyMem (mAcpiS3PerformanceTable, &mS3PerformanceTableTemplate, sizeof (mS3PerformanceTableTemplate));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save S3 Performance Table address to Variable for use in Firmware Performance PEIM.
|
||||||
|
//
|
||||||
|
PerformanceVariable.S3PerformanceTablePointer = (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiS3PerformanceTable;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update S3 Performance Table Pointer in template.
|
||||||
|
//
|
||||||
|
mFirmwarePerformanceTableTemplate.S3PointerRecord.S3PerformanceTablePointer = (UINT64) PerformanceVariable.S3PerformanceTablePointer;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Exclude S3 Performance Table Pointer from FPDT table template.
|
||||||
|
//
|
||||||
|
mFirmwarePerformanceTableTemplate.Header.Length -= sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save Runtime Performance Table pointers to Variable.
|
||||||
|
//
|
||||||
|
Status = gRT->SetVariable (
|
||||||
|
EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
|
||||||
|
&gEfiFirmwarePerformanceGuid,
|
||||||
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||||
|
sizeof (FIRMWARE_PERFORMANCE_VARIABLE),
|
||||||
|
&PerformanceVariable
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Publish Firmware Performance Data Table.
|
||||||
|
//
|
||||||
|
FpdtAcpiTableChecksum ((UINT8 *) &mFirmwarePerformanceTableTemplate, mFirmwarePerformanceTableTemplate.Header.Length);
|
||||||
|
Status = AcpiTableProtocol->InstallAcpiTable (
|
||||||
|
AcpiTableProtocol,
|
||||||
|
&mFirmwarePerformanceTableTemplate,
|
||||||
|
mFirmwarePerformanceTableTemplate.Header.Length,
|
||||||
|
&mFirmwarePerformanceTableTemplateKey
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
FreePool (mPerformanceRuntimeData);
|
||||||
|
mAcpiBootPerformanceTable = NULL;
|
||||||
|
mAcpiS3PerformanceTable = NULL;
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to
|
||||||
|
install the Firmware Performance Data Table.
|
||||||
|
|
||||||
|
@param[in] Event The Event that is being processed.
|
||||||
|
@param[in] Context The Event Context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
FpdtReadyToBootEventNotify (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (mAcpiBootPerformanceTable == NULL) {
|
||||||
|
//
|
||||||
|
// ACPI Firmware Performance Data Table not installed yet, install it now.
|
||||||
|
//
|
||||||
|
InstallFirmwarePerformanceDataTable ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notify function for event group EFI_EVENT_LEGACY_BOOT_GUID. This is used to
|
||||||
|
record performance data for OsLoaderLoadImageStart in FPDT for legacy boot.
|
||||||
|
|
||||||
|
@param[in] Event The Event that is being processed.
|
||||||
|
@param[in] Context The Event Context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
FpdtLegacyBootEventNotify (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (mAcpiBootPerformanceTable == NULL) {
|
||||||
|
//
|
||||||
|
// Firmware Performance Data Table not installed, do nothing.
|
||||||
|
//
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update Firmware Basic Boot Performance Record for legacy boot.
|
||||||
|
//
|
||||||
|
mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart = 0;
|
||||||
|
mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart = GetTimeInNanoSecond (GetPerformanceCounter ());
|
||||||
|
mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry = 0;
|
||||||
|
mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesExit = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Dump FPDT Boot Performance record.
|
||||||
|
//
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n"));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n"));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesExit = 0\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record
|
||||||
|
performance data for ExitBootServicesEntry in FPDT.
|
||||||
|
|
||||||
|
@param[in] Event The Event that is being processed.
|
||||||
|
@param[in] Context The Event Context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
FpdtExitBootServicesEventNotify (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (mAcpiBootPerformanceTable == NULL) {
|
||||||
|
//
|
||||||
|
// Firmware Performance Data Table not installed, do nothing.
|
||||||
|
//
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update Firmware Basic Boot Performance Record for UEFI boot.
|
||||||
|
//
|
||||||
|
mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry = GetTimeInNanoSecond (GetPerformanceCounter ());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Dump FPDT Boot Performance record.
|
||||||
|
//
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry));
|
||||||
|
//
|
||||||
|
// ExitBootServicesExit will be updated later, so don't dump it here.
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Report status code listener of FPDT. This is used to collect performance data
|
||||||
|
for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.
|
||||||
|
|
||||||
|
@param[in] CodeType Indicates the type of status code being reported.
|
||||||
|
@param[in] Value Describes the current status of a hardware or software entity.
|
||||||
|
This included information about the class and subclass that is used to
|
||||||
|
classify the entity as well as an operation.
|
||||||
|
@param[in] Instance The enumeration of a hardware or software entity within
|
||||||
|
the system. Valid instance numbers start with 1.
|
||||||
|
@param[in] CallerId This optional parameter may be used to identify the caller.
|
||||||
|
This parameter allows the status code driver to apply different rules to
|
||||||
|
different callers.
|
||||||
|
@param[in] Data This optional parameter may be used to pass additional data.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Status code is what we expected.
|
||||||
|
@retval EFI_UNSUPPORTED Status code not supported.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FpdtStatusCodeListenerDxe (
|
||||||
|
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||||
|
IN EFI_STATUS_CODE_VALUE Value,
|
||||||
|
IN UINT32 Instance,
|
||||||
|
IN EFI_GUID *CallerId,
|
||||||
|
IN EFI_STATUS_CODE_DATA *Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check whether status code is what we are interested in.
|
||||||
|
//
|
||||||
|
if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
if (Value == PcdGet32 (PcdProgressCodeOsLoaderLoad)) {
|
||||||
|
//
|
||||||
|
// Progress code for OS Loader LoadImage.
|
||||||
|
//
|
||||||
|
if (mAcpiBootPerformanceTable == NULL) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update OS Loader LoadImage Start for UEFI boot.
|
||||||
|
//
|
||||||
|
mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart = GetTimeInNanoSecond (GetPerformanceCounter ());
|
||||||
|
} else if (Value == PcdGet32 (PcdProgressCodeOsLoaderStart)) {
|
||||||
|
//
|
||||||
|
// Progress code for OS Loader StartImage.
|
||||||
|
//
|
||||||
|
if (mAcpiBootPerformanceTable == NULL) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update OS Loader StartImage Start for UEFI boot.
|
||||||
|
//
|
||||||
|
mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart = GetTimeInNanoSecond (GetPerformanceCounter ());
|
||||||
|
} else if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) {
|
||||||
|
//
|
||||||
|
// Progress code for ExitBootServices.
|
||||||
|
//
|
||||||
|
if (mAcpiBootPerformanceTable == NULL) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update ExitBootServicesExit for UEFI boot.
|
||||||
|
//
|
||||||
|
mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesExit = GetTimeInNanoSecond (GetPerformanceCounter ());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Unregister boot time report status code listener.
|
||||||
|
//
|
||||||
|
mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe);
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Ignore else progress code.
|
||||||
|
//
|
||||||
|
Status = EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
The module Entry Point of the Firmware Performance Data Table DXE driver.
|
||||||
|
|
||||||
|
@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
|
||||||
|
FirmwarePerformanceDxeEntryPoint (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_HOB_GUID_TYPE *GuidHob;
|
||||||
|
FIRMWARE_SEC_PERFORMANCE *Performance;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get Report Status Code Handler Protocol.
|
||||||
|
//
|
||||||
|
Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid, NULL, (VOID **) &mRscHandlerProtocol);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register report status code listener for OS Loader load and start.
|
||||||
|
//
|
||||||
|
Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerDxe, TPL_HIGH_LEVEL);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register the notify function to update FPDT on ExitBootServices Event.
|
||||||
|
//
|
||||||
|
Status = gBS->CreateEventEx (
|
||||||
|
EVT_NOTIFY_SIGNAL,
|
||||||
|
TPL_NOTIFY,
|
||||||
|
FpdtExitBootServicesEventNotify,
|
||||||
|
NULL,
|
||||||
|
&gEfiEventExitBootServicesGuid,
|
||||||
|
&mExitBootServicesEvent
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create ready to boot event to install ACPI FPDT table.
|
||||||
|
//
|
||||||
|
Status = gBS->CreateEventEx (
|
||||||
|
EVT_NOTIFY_SIGNAL,
|
||||||
|
TPL_NOTIFY,
|
||||||
|
FpdtReadyToBootEventNotify,
|
||||||
|
NULL,
|
||||||
|
&gEfiEventReadyToBootGuid,
|
||||||
|
&mReadyToBootEvent
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create legacy boot event to log OsLoaderStartImageStart for legacy boot.
|
||||||
|
//
|
||||||
|
Status = gBS->CreateEventEx (
|
||||||
|
EVT_NOTIFY_SIGNAL,
|
||||||
|
TPL_NOTIFY,
|
||||||
|
FpdtLegacyBootEventNotify,
|
||||||
|
NULL,
|
||||||
|
&gEfiEventLegacyBootGuid,
|
||||||
|
&mLegacyBootEvent
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve GUID HOB data that contains the ResetEnd.
|
||||||
|
//
|
||||||
|
GuidHob = GetFirstGuidHob (&gEfiFirmwarePerformanceGuid);
|
||||||
|
if (GuidHob != NULL) {
|
||||||
|
Performance = (FIRMWARE_SEC_PERFORMANCE *) GET_GUID_HOB_DATA (GuidHob);
|
||||||
|
mBootPerformanceTableTemplate.BasicBoot.ResetEnd = Performance->ResetEnd;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
|
||||||
|
//
|
||||||
|
DEBUG ((EFI_D_ERROR, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
## @file
|
||||||
|
# This module install ACPI Firmware Performance Data Table (FPDT).
|
||||||
|
#
|
||||||
|
# This module register report status code listener to collect performance data
|
||||||
|
# for Firmware Basic Boot Performance Record and install FPDT to ACPI table.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
# This program and the accompanying materials
|
||||||
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
# which accompanies this distribution. The full text of the license may be found at
|
||||||
|
# http://opensource.org/licenses/bsd-license.php
|
||||||
|
#
|
||||||
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = FirmwarePerformanceDxe
|
||||||
|
FILE_GUID = 00160F8D-2B35-4df2-BBE0-B272A8D631F0
|
||||||
|
MODULE_TYPE = DXE_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = FirmwarePerformanceDxeEntryPoint
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
FirmwarePerformanceDxe.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiRuntimeServicesTableLib
|
||||||
|
BaseLib
|
||||||
|
DebugLib
|
||||||
|
TimerLib
|
||||||
|
BaseMemoryLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
PcdLib
|
||||||
|
HobLib
|
||||||
|
PcdLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiAcpiTableProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiRscHandlerProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiEventExitBootServicesGuid ## CONSUMES
|
||||||
|
gEfiEventReadyToBootGuid ## CONSUMES
|
||||||
|
gEfiEventLegacyBootGuid ## CONSUMES
|
||||||
|
gEfiAcpiTableGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiAcpi10TableGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiAcpi20TableGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiFirmwarePerformanceGuid ## CONSUMES
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderStart
|
||||||
|
|
||||||
|
[FeaturePcd]
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
gEfiRscHandlerProtocolGuid
|
@ -0,0 +1,230 @@
|
|||||||
|
/** @file
|
||||||
|
This module updates S3 Resume Performance Record in ACPI Firmware Performance
|
||||||
|
Data Table in S3 resume boot mode. In normal boot mode, this module consumes
|
||||||
|
SecPerformance PPI produced by SEC phase and build Hob to convey the SEC
|
||||||
|
performance data to DXE phase.
|
||||||
|
|
||||||
|
This module register report status code listener to collect performance data
|
||||||
|
for S3 Resume Performance Record on S3 resume boot path.
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiPei.h>
|
||||||
|
|
||||||
|
#include <IndustryStandard/Acpi50.h>
|
||||||
|
|
||||||
|
#include <Ppi/ReadOnlyVariable2.h>
|
||||||
|
#include <Ppi/ReportStatusCodeHandler.h>
|
||||||
|
#include <Ppi/SecPerformance.h>
|
||||||
|
|
||||||
|
#include <Guid/FirmwarePerformance.h>
|
||||||
|
|
||||||
|
#include <Library/PeiServicesLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/TimerLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/LockBoxLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Report status code listener for PEI. This is used to record the performance
|
||||||
|
data for S3 FullResume in FPDT.
|
||||||
|
|
||||||
|
@param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
|
||||||
|
@param[in] CodeType Indicates the type of status code being reported.
|
||||||
|
@param[in] Value Describes the current status of a hardware or software entity.
|
||||||
|
This included information about the class and subclass that is used to
|
||||||
|
classify the entity as well as an operation.
|
||||||
|
@param[in] Instance The enumeration of a hardware or software entity within
|
||||||
|
the system. Valid instance numbers start with 1.
|
||||||
|
@param[in] CallerId This optional parameter may be used to identify the caller.
|
||||||
|
This parameter allows the status code driver to apply different rules to
|
||||||
|
different callers.
|
||||||
|
@param[in] Data This optional parameter may be used to pass additional data.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Status code is what we expected.
|
||||||
|
@retval EFI_UNSUPPORTED Status code not supported.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FpdtStatusCodeListenerPei (
|
||||||
|
IN CONST EFI_PEI_SERVICES **PeiServices,
|
||||||
|
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||||
|
IN EFI_STATUS_CODE_VALUE Value,
|
||||||
|
IN UINT32 Instance,
|
||||||
|
IN CONST EFI_GUID *CallerId,
|
||||||
|
IN CONST EFI_STATUS_CODE_DATA *Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINT64 CurrentTime;
|
||||||
|
EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices;
|
||||||
|
UINTN VarSize;
|
||||||
|
FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
|
||||||
|
S3_PERFORMANCE_TABLE *AcpiS3PerformanceTable;
|
||||||
|
EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD *AcpiS3ResumeRecord;
|
||||||
|
UINT64 S3ResumeTotal;
|
||||||
|
EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord;
|
||||||
|
EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD *AcpiS3SuspendRecord;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check whether status code is what we are interested in.
|
||||||
|
//
|
||||||
|
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) ||
|
||||||
|
(Value != (EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE))) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve current time as early as possible.
|
||||||
|
//
|
||||||
|
CurrentTime = GetTimeInNanoSecond (GetPerformanceCounter ());
|
||||||
|
|
||||||
|
Status = PeiServicesLocatePpi (
|
||||||
|
&gEfiPeiReadOnlyVariable2PpiGuid,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
(VOID **) &VariableServices
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update S3 Resume Performance Record.
|
||||||
|
//
|
||||||
|
VarSize = sizeof (FIRMWARE_PERFORMANCE_VARIABLE);
|
||||||
|
Status = VariableServices->GetVariable (
|
||||||
|
VariableServices,
|
||||||
|
EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
|
||||||
|
&gEfiFirmwarePerformanceGuid,
|
||||||
|
NULL,
|
||||||
|
&VarSize,
|
||||||
|
&PerformanceVariable
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
AcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.S3PerformanceTablePointer;
|
||||||
|
ASSERT (AcpiS3PerformanceTable != NULL);
|
||||||
|
ASSERT (AcpiS3PerformanceTable->Header.Signature == EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE);
|
||||||
|
AcpiS3ResumeRecord = &AcpiS3PerformanceTable->S3Resume;
|
||||||
|
AcpiS3ResumeRecord->FullResume = CurrentTime;
|
||||||
|
//
|
||||||
|
// Calculate average S3 resume time.
|
||||||
|
//
|
||||||
|
S3ResumeTotal = MultU64x32 (AcpiS3ResumeRecord->AverageResume, AcpiS3ResumeRecord->ResumeCount);
|
||||||
|
AcpiS3ResumeRecord->ResumeCount++;
|
||||||
|
AcpiS3ResumeRecord->AverageResume = DivU64x32 (S3ResumeTotal + AcpiS3ResumeRecord->FullResume, AcpiS3ResumeRecord->ResumeCount);
|
||||||
|
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: S3 Resume Performance - ResumeCount = %d\n", AcpiS3ResumeRecord->ResumeCount));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: S3 Resume Performance - FullResume = %ld\n", AcpiS3ResumeRecord->FullResume));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: S3 Resume Performance - AverageResume = %ld\n", AcpiS3ResumeRecord->AverageResume));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update S3 Suspend Performance Record.
|
||||||
|
//
|
||||||
|
AcpiS3SuspendRecord = &AcpiS3PerformanceTable->S3Suspend;
|
||||||
|
VarSize = sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD);
|
||||||
|
ZeroMem (&S3SuspendRecord, sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD));
|
||||||
|
Status = RestoreLockBox (
|
||||||
|
&gEfiFirmwarePerformanceGuid,
|
||||||
|
&S3SuspendRecord,
|
||||||
|
&VarSize
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
AcpiS3SuspendRecord->SuspendStart = S3SuspendRecord.SuspendStart;
|
||||||
|
AcpiS3SuspendRecord->SuspendEnd = S3SuspendRecord.SuspendEnd;
|
||||||
|
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart));
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd = %ld\n", AcpiS3SuspendRecord->SuspendEnd));
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Main entry for Firmware Performance Data Table PEIM.
|
||||||
|
|
||||||
|
This routine is to register report status code listener for FPDT.
|
||||||
|
|
||||||
|
@param[in] FileHandle Handle of the file being invoked.
|
||||||
|
@param[in] PeiServices Pointer to PEI Services table.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Report status code listener is registered successfully.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FirmwarePerformancePeiEntryPoint (
|
||||||
|
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||||
|
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EFI_BOOT_MODE BootMode;
|
||||||
|
EFI_PEI_RSC_HANDLER_PPI *RscHandler;
|
||||||
|
PEI_SEC_PERFORMANCE_PPI *SecPerf;
|
||||||
|
FIRMWARE_SEC_PERFORMANCE Performance;
|
||||||
|
|
||||||
|
Status = PeiServicesGetBootMode(&BootMode);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
if (BootMode == BOOT_ON_S3_RESUME) {
|
||||||
|
if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {
|
||||||
|
//
|
||||||
|
// S3 resume - register status code listener for OS wake vector.
|
||||||
|
//
|
||||||
|
Status = PeiServicesLocatePpi (
|
||||||
|
&gEfiPeiRscHandlerPpiGuid,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
(VOID **) &RscHandler
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
Status = RscHandler->Register (FpdtStatusCodeListenerPei);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Normal boot - build Hob for SEC performance data.
|
||||||
|
//
|
||||||
|
Status = PeiServicesLocatePpi (
|
||||||
|
&gPeiSecPerformancePpiGuid,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
(VOID **) &SecPerf
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = SecPerf->GetPerformance (PeiServices, SecPerf, &Performance);
|
||||||
|
}
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
BuildGuidDataHob (
|
||||||
|
&gEfiFirmwarePerformanceGuid,
|
||||||
|
&Performance,
|
||||||
|
sizeof (FIRMWARE_SEC_PERFORMANCE)
|
||||||
|
);
|
||||||
|
DEBUG ((EFI_D_INFO, "FPDT: SEC Performance Hob ResetEnd = %ld\n", Performance.ResetEnd));
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// SEC performance PPI is not installed or fail to get performance data
|
||||||
|
// from SEC Performance PPI.
|
||||||
|
//
|
||||||
|
DEBUG ((EFI_D_ERROR, "FPDT: WARNING: SEC Performance PPI not installed or failed!\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
## @file
|
||||||
|
# This module updates S3 Resume Performance Record in ACPI Firmware Performance
|
||||||
|
# Data Table in S3 resume boot mode. In normal boot mode, this module consumes
|
||||||
|
# SecPerformance PPI produced by SEC phase and build Hob to convey the SEC
|
||||||
|
# performance data to DXE phase.
|
||||||
|
#
|
||||||
|
# This module register report status code listener to collect performance data
|
||||||
|
# for S3 Resume Performance Record on S3 resume boot path.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
# This program and the accompanying materials
|
||||||
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
# which accompanies this distribution. The full text of the license may be found at
|
||||||
|
# http://opensource.org/licenses/bsd-license.php
|
||||||
|
#
|
||||||
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = FirmwarePerformancePei
|
||||||
|
FILE_GUID = ADF01BF6-47D6-495d-B95B-687777807214
|
||||||
|
MODULE_TYPE = PEIM
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = FirmwarePerformancePeiEntryPoint
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
FirmwarePerformancePei.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
PeimEntryPoint
|
||||||
|
PeiServicesLib
|
||||||
|
BaseLib
|
||||||
|
DebugLib
|
||||||
|
HobLib
|
||||||
|
TimerLib
|
||||||
|
BaseMemoryLib
|
||||||
|
LockBoxLib
|
||||||
|
PcdLib
|
||||||
|
|
||||||
|
[Ppis]
|
||||||
|
gEfiPeiRscHandlerPpiGuid ## CONSUMES
|
||||||
|
gEfiPeiReadOnlyVariable2PpiGuid ## SOMETIMES_CONSUMES
|
||||||
|
gPeiSecPerformancePpiGuid ## CONSUMES
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiFirmwarePerformanceGuid ## CONSUMES
|
||||||
|
|
||||||
|
[FeaturePcd]
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
gEfiPeiMasterBootModePpiGuid AND gEfiPeiRscHandlerPpiGuid
|
@ -0,0 +1,165 @@
|
|||||||
|
/** @file
|
||||||
|
This module update S3 Suspend Performance Record in ACPI Firmware Performance Data Table.
|
||||||
|
|
||||||
|
This module register report status code listener to collect performance data
|
||||||
|
for S3 Suspend Performance Record.
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiSmm.h>
|
||||||
|
|
||||||
|
#include <IndustryStandard/Acpi50.h>
|
||||||
|
|
||||||
|
#include <Protocol/SmmReportStatusCodeHandler.h>
|
||||||
|
|
||||||
|
#include <Guid/FirmwarePerformance.h>
|
||||||
|
|
||||||
|
#include <Library/SmmServicesTableLib.h>
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/TimerLib.h>
|
||||||
|
#include <Library/LockBoxLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
|
||||||
|
EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
|
||||||
|
UINT64 mSuspendStartTime = 0;
|
||||||
|
BOOLEAN mS3SuspendLockBoxSaved = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Report status code listener for SMM. This is used to record the performance
|
||||||
|
data for S3 Suspend Start and S3 Suspend End in FPDT.
|
||||||
|
|
||||||
|
@param[in] CodeType Indicates the type of status code being reported.
|
||||||
|
@param[in] Value Describes the current status of a hardware or software entity.
|
||||||
|
This included information about the class and subclass that is used to
|
||||||
|
classify the entity as well as an operation.
|
||||||
|
@param[in] Instance The enumeration of a hardware or software entity within
|
||||||
|
the system. Valid instance numbers start with 1.
|
||||||
|
@param[in] CallerId This optional parameter may be used to identify the caller.
|
||||||
|
This parameter allows the status code driver to apply different rules to
|
||||||
|
different callers.
|
||||||
|
@param[in] Data This optional parameter may be used to pass additional data.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Status code is what we expected.
|
||||||
|
@retval EFI_UNSUPPORTED Status code not supported.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FpdtStatusCodeListenerSmm (
|
||||||
|
IN EFI_STATUS_CODE_TYPE CodeType,
|
||||||
|
IN EFI_STATUS_CODE_VALUE Value,
|
||||||
|
IN UINT32 Instance,
|
||||||
|
IN EFI_GUID *CallerId,
|
||||||
|
IN EFI_STATUS_CODE_DATA *Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINT64 CurrentTime;
|
||||||
|
EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check whether status code is what we are interested in.
|
||||||
|
//
|
||||||
|
if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
if ((Value != PcdGet32 (PcdProgressCodeS3SuspendStart)) &&
|
||||||
|
(Value != PcdGet32 (PcdProgressCodeS3SuspendEnd))) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve current time.
|
||||||
|
//
|
||||||
|
CurrentTime = GetTimeInNanoSecond (GetPerformanceCounter ());
|
||||||
|
|
||||||
|
if (Value == PcdGet32 (PcdProgressCodeS3SuspendStart)) {
|
||||||
|
//
|
||||||
|
// S3 Suspend started, record the performance data and return.
|
||||||
|
//
|
||||||
|
mSuspendStartTime = CurrentTime;
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// We are going to S3 sleep, record S3 Suspend End performance data.
|
||||||
|
//
|
||||||
|
S3SuspendRecord.SuspendStart = mSuspendStartTime;
|
||||||
|
S3SuspendRecord.SuspendEnd = CurrentTime;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save S3 suspend performance data to lock box, it will be used by Firmware Performance PEIM.
|
||||||
|
//
|
||||||
|
if (!mS3SuspendLockBoxSaved) {
|
||||||
|
Status = SaveLockBox (
|
||||||
|
&gEfiFirmwarePerformanceGuid,
|
||||||
|
&S3SuspendRecord,
|
||||||
|
sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD)
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
mS3SuspendLockBoxSaved = TRUE;
|
||||||
|
} else {
|
||||||
|
Status = UpdateLockBox (
|
||||||
|
&gEfiFirmwarePerformanceGuid,
|
||||||
|
0,
|
||||||
|
&S3SuspendRecord,
|
||||||
|
sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD)
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
The module Entry Point of the Firmware Performance Data Table SMM driver.
|
||||||
|
|
||||||
|
@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
|
||||||
|
FirmwarePerformanceSmmEntryPoint (
|
||||||
|
IN EFI_HANDLE ImageHandle,
|
||||||
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get SMM Report Status Code Handler Protocol.
|
||||||
|
//
|
||||||
|
Status = gSmst->SmmLocateProtocol (
|
||||||
|
&gEfiSmmRscHandlerProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
(VOID **) &mRscHandlerProtocol
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register report status code listener for S3 Suspend Start and End.
|
||||||
|
//
|
||||||
|
Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerSmm);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
} else {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
## @file
|
||||||
|
# This module update S3 Suspend Performance Record in ACPI Firmware Performance Data Table.
|
||||||
|
#
|
||||||
|
# This module register report status code listener to collect performance data
|
||||||
|
# for S3 Suspend Performance Record.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
|
# This program and the accompanying materials
|
||||||
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
# which accompanies this distribution. The full text of the license may be found at
|
||||||
|
# http://opensource.org/licenses/bsd-license.php
|
||||||
|
#
|
||||||
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = FirmwarePerformanceSmm
|
||||||
|
FILE_GUID = 044310AB-77FD-402a-AF1A-87D4120E7329
|
||||||
|
MODULE_TYPE = DXE_SMM_DRIVER
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
PI_SPECIFICATION_VERSION = 0x0001000A
|
||||||
|
ENTRY_POINT = FirmwarePerformanceSmmEntryPoint
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
FirmwarePerformanceSmm.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
UefiDriverEntryPoint
|
||||||
|
SmmServicesTableLib
|
||||||
|
BaseLib
|
||||||
|
DebugLib
|
||||||
|
TimerLib
|
||||||
|
LockBoxLib
|
||||||
|
PcdLib
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiSmmRscHandlerProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiFirmwarePerformanceGuid ## CONSUMES
|
||||||
|
|
||||||
|
[FeaturePcd]
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendStart
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendEnd
|
||||||
|
|
||||||
|
[Depex]
|
||||||
|
gEfiSmmRscHandlerProtocolGuid
|
Loading…
x
Reference in New Issue
Block a user