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