]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Separate memory allocation for FPDT S3 performance table and boot performance table...
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 May 2013 07:35:30 +0000 (07:35 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 May 2013 07:35:30 +0000 (07:35 +0000)
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14369 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Include/Guid/FirmwarePerformance.h
MdeModulePkg/MdeModulePkg.dec
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.inf

index 7da07f9ea736a6abb93e853cc337c879ee5bb639..a4aeda275986c7e28bf5ad9956a9b74f4753b49e 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   ACPI Firmware Performance Data Table (FPDT) implementation specific definitions.\r
 \r
-  Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2013, 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
 \r
 #define EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME  L"FirmwarePerformance"\r
 \r
+/// LockBox:\r
+///   GUID - gFirmwarePerformanceS3PointerGuid\r
+///   Data - S3 performance table pointer\r
+///\r
+#define FIRMWARE_PERFORMANCE_S3_POINTER_GUID \\r
+  { \\r
+    0xdc65adc, 0xa973, 0x4130, { 0x8d, 0xf0, 0x2a, 0xdb, 0xeb, 0x9e, 0x4a, 0x31 } \\r
+  }\r
+\r
 #pragma pack(1)\r
 \r
 ///\r
@@ -95,7 +104,7 @@ typedef struct {
 \r
 ///\r
 /// Variable defined for FPDT implementation.\r
-/// This Variable is produced by FPDT DXE module and consumed by FPDT PEIM.\r
+/// This Variable is produced by FPDT DXE module.\r
 ///\r
 typedef struct {\r
   EFI_PHYSICAL_ADDRESS  BootPerformanceTablePointer; ///< Pointer to Boot Performance Table.\r
@@ -118,5 +127,6 @@ typedef struct {
 } SMM_BOOT_RECORD_COMMUNICATE;\r
 \r
 extern EFI_GUID gEfiFirmwarePerformanceGuid;\r
+extern EFI_GUID gFirmwarePerformanceS3PointerGuid;\r
 \r
 #endif\r
index ba80b809dc003397364262bd0ef62dcdd85086ea..309450792a8bee9e3c3430085c28e304d10be5b9 100644 (file)
   ## 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
+  gFirmwarePerformanceS3PointerGuid  = { 0xdc65adc,  0xa973, 0x4130, { 0x8d, 0xf0, 0x2a, 0xdb, 0xeb, 0x9e, 0x4a, 0x31 }}\r
 \r
   ## Include/Guid/ExitBootServiceFailed.h\r
   gEventExitBootServicesFailedGuid   = { 0x4f6c5507, 0x232f, 0x4787, { 0xb9, 0x5e, 0x72, 0xf8, 0x62, 0x49, 0xc, 0xb1 } }\r
index dae12a4869004a63e2f55f5159fc850a5bc1ea56..8996fe2b6ba6028522909d883c1d657bb9196d85 100644 (file)
@@ -21,6 +21,8 @@
 #include <Protocol/ReportStatusCodeHandler.h>\r
 #include <Protocol/AcpiTable.h>\r
 #include <Protocol/SmmCommunication.h>\r
+#include <Protocol/LockBox.h>\r
+#include <Protocol/Variable.h>\r
 \r
 #include <Guid/Acpi.h>\r
 #include <Guid/FirmwarePerformance.h>\r
@@ -36,7 +38,8 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/HobLib.h>\r
-#include <Library/PcdLib.h>\r
+#include <Library/LockBoxLib.h>\r
+#include <Library/UefiLib.h>\r
 \r
 //\r
 // ACPI table information used to initialize tables.\r
@@ -51,6 +54,7 @@
 \r
 EFI_RSC_HANDLER_PROTOCOL    *mRscHandlerProtocol = NULL;\r
 \r
+BOOLEAN                     mLockBoxReady = FALSE;\r
 EFI_EVENT                   mReadyToBootEvent;\r
 EFI_EVENT                   mLegacyBootEvent;\r
 EFI_EVENT                   mExitBootServicesEvent;\r
@@ -206,6 +210,7 @@ FpdtAllocateReservedMemoryBelow4G (
   EFI_STATUS            Status;\r
   VOID                  *Buffer;\r
 \r
+  Buffer  = NULL;\r
   Pages   = EFI_SIZE_TO_PAGES (Size);\r
   Address = 0xffffffff;\r
 \r
@@ -217,12 +222,106 @@ FpdtAllocateReservedMemoryBelow4G (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Buffer = (VOID *) (UINTN) Address;\r
-  ZeroMem (Buffer, Size);\r
+  if (!EFI_ERROR (Status)) {\r
+    Buffer = (VOID *) (UINTN) Address;\r
+    ZeroMem (Buffer, Size);\r
+  }\r
 \r
   return Buffer;\r
 }\r
 \r
+/**\r
+  Callback function upon VariableArchProtocol and LockBoxProtocol\r
+  to allocate S3 performance table memory and save the pointer to LockBox.\r
+\r
+  @param[in] Event    Event whose notification function is being invoked.\r
+  @param[in] Context  Pointer to the notification function's context.\r
+**/\r
+VOID\r
+EFIAPI\r
+FpdtAllocateS3PerformanceTableMemory (\r
+  IN  EFI_EVENT                             Event,\r
+  IN  VOID                                  *Context\r
+  )\r
+{\r
+  EFI_STATUS                    Status;\r
+  VOID                          *Interface;\r
+  FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;\r
+  UINTN                         Size;\r
+  EFI_PHYSICAL_ADDRESS          S3PerformanceTablePointer;\r
+\r
+  if (mLockBoxReady && (mAcpiS3PerformanceTable != NULL)) {\r
+    //\r
+    // The memory for S3 performance table should have been ready,\r
+    // and the pointer should have been saved to LockBox, just return.\r
+    //\r
+    return;\r
+  }\r
+\r
+  if (!mLockBoxReady) {\r
+    Status = gBS->LocateProtocol (&gEfiLockBoxProtocolGuid, NULL, &Interface);\r
+    if (!EFI_ERROR (Status)) {\r
+      //\r
+      // LockBox services has been ready.\r
+      //\r
+      mLockBoxReady = TRUE;\r
+    }\r
+  }\r
+\r
+  if (mAcpiS3PerformanceTable == NULL) {\r
+    Status = gBS->LocateProtocol (&gEfiVariableArchProtocolGuid, NULL, &Interface);\r
+    if (!EFI_ERROR (Status)) {\r
+      //\r
+      // Try to allocate the same runtime buffer as last time boot.\r
+      //\r
+      ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable));\r
+      Size = sizeof (PerformanceVariable);\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
+        Status = gBS->AllocatePages (\r
+                        AllocateAddress,\r
+                        EfiReservedMemoryType,\r
+                        EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)),\r
+                        &PerformanceVariable.S3PerformanceTablePointer\r
+                        );\r
+        if (!EFI_ERROR (Status)) {\r
+          mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.S3PerformanceTablePointer;\r
+        }\r
+      }\r
+      if (mAcpiS3PerformanceTable == NULL) {\r
+        //\r
+        // Fail to allocate at specified address, continue to allocate at any address.\r
+        //\r
+        mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (sizeof (S3_PERFORMANCE_TABLE));\r
+      }\r
+      DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable));\r
+      if (mAcpiS3PerformanceTable != NULL) {\r
+        CopyMem (mAcpiS3PerformanceTable, &mS3PerformanceTableTemplate, sizeof (mS3PerformanceTableTemplate));\r
+      }\r
+    }\r
+  }\r
+\r
+  if (mLockBoxReady && (mAcpiS3PerformanceTable != NULL)) {\r
+    //\r
+    // If LockBox services has been ready and memory for FPDT S3 performance table has been allocated,\r
+    // save the pointer to LockBox for use in S3 resume.\r
+    //\r
+    S3PerformanceTablePointer = (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiS3PerformanceTable;\r
+    Status = SaveLockBox (\r
+               &gFirmwarePerformanceS3PointerGuid,\r
+               &S3PerformanceTablePointer,\r
+               sizeof (EFI_PHYSICAL_ADDRESS)\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+}\r
+\r
 /**\r
   Install ACPI Firmware Performance Data Table (FPDT).\r
 \r
@@ -236,15 +335,13 @@ InstallFirmwarePerformanceDataTable (
 {\r
   EFI_STATUS                    Status;\r
   EFI_ACPI_TABLE_PROTOCOL       *AcpiTableProtocol;\r
-  EFI_PHYSICAL_ADDRESS          Address;\r
   UINTN                         Size;\r
   UINT8                         *SmmBootRecordCommBuffer;\r
   EFI_SMM_COMMUNICATE_HEADER    *SmmCommBufferHeader;\r
   SMM_BOOT_RECORD_COMMUNICATE   *SmmCommData;\r
   UINTN                         CommSize;\r
-  UINTN                         PerformanceRuntimeDataSize;\r
-  UINT8                         *PerformanceRuntimeData; \r
-  UINT8                         *PerformanceRuntimeDataHead; \r
+  UINTN                         BootPerformanceDataSize;\r
+  UINT8                         *BootPerformanceData; \r
   EFI_SMM_COMMUNICATION_PROTOCOL  *Communication;\r
   FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;\r
 \r
@@ -299,15 +396,12 @@ InstallFirmwarePerformanceDataTable (
   FreePool (SmmBootRecordCommBuffer);\r
 \r
   //\r
-  // Prepare memory for runtime Performance Record. \r
-  // Runtime performance records includes two tables S3 performance table and Boot performance table. \r
-  // S3 Performance table includes S3Resume and S3Suspend records. \r
+  // Prepare memory for Boot Performance table.\r
   // Boot Performance table includes BasicBoot record, and one or more appended Boot Records. \r
   //\r
-  PerformanceRuntimeData = NULL;\r
-  PerformanceRuntimeDataSize = sizeof (S3_PERFORMANCE_TABLE) + sizeof (BOOT_PERFORMANCE_TABLE) + mBootRecordSize + PcdGet32 (PcdExtFpdtBootRecordPadSize);\r
+  BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE) + mBootRecordSize + PcdGet32 (PcdExtFpdtBootRecordPadSize);\r
   if (SmmCommData != NULL) {\r
-    PerformanceRuntimeDataSize += SmmCommData->BootRecordSize;\r
+    BootPerformanceDataSize += SmmCommData->BootRecordSize;\r
   }\r
 \r
   //\r
@@ -323,88 +417,60 @@ InstallFirmwarePerformanceDataTable (
                   &PerformanceVariable\r
                   );\r
   if (!EFI_ERROR (Status)) {\r
-    Address = PerformanceVariable.S3PerformanceTablePointer;\r
     Status = gBS->AllocatePages (\r
                     AllocateAddress,\r
                     EfiReservedMemoryType,\r
-                    EFI_SIZE_TO_PAGES (PerformanceRuntimeDataSize),\r
-                    &Address\r
+                    EFI_SIZE_TO_PAGES (BootPerformanceDataSize),\r
+                    &PerformanceVariable.BootPerformanceTablePointer\r
                     );\r
     if (!EFI_ERROR (Status)) {\r
-      PerformanceRuntimeData = (UINT8 *) (UINTN) Address;\r
+      mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.BootPerformanceTablePointer;\r
     }\r
   }\r
 \r
-  if (PerformanceRuntimeData == NULL) {\r
+  if (mAcpiBootPerformanceTable == NULL) {\r
     //\r
     // Fail to allocate at specified address, continue to allocate at any address.\r
     //\r
-    PerformanceRuntimeData = FpdtAllocateReservedMemoryBelow4G (PerformanceRuntimeDataSize);\r
+    mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (BootPerformanceDataSize);\r
   }\r
-  DEBUG ((EFI_D_INFO, "FPDT: Performance Runtime Data address = 0x%x\n", PerformanceRuntimeData));\r
+  DEBUG ((EFI_D_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));\r
 \r
-  if (PerformanceRuntimeData == NULL) {\r
+  if (mAcpiBootPerformanceTable == NULL) {\r
     if (SmmCommData != NULL && SmmCommData->BootRecordData != NULL) {\r
       FreePool (SmmCommData->BootRecordData);\r
     }\r
+    if (mAcpiS3PerformanceTable != NULL) {\r
+      FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)));\r
+    }\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  \r
-  PerformanceRuntimeDataHead = PerformanceRuntimeData;\r
-\r
-  if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {\r
-    //\r
-    // Prepare S3 Performance Table.\r
-    //\r
-    mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) PerformanceRuntimeData;\r
-    CopyMem (mAcpiS3PerformanceTable, &mS3PerformanceTableTemplate, sizeof (mS3PerformanceTableTemplate));\r
-    PerformanceRuntimeData  = PerformanceRuntimeData + mAcpiS3PerformanceTable->Header.Length;\r
-    DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable));\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
-    // 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_PERFORMANCE_TABLE_POINTER_RECORD);\r
-  }\r
 \r
   //\r
   // Prepare Boot Performance Table.\r
   //\r
-  mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) PerformanceRuntimeData;\r
+  BootPerformanceData = (UINT8 *) mAcpiBootPerformanceTable;\r
   //\r
   // Fill Basic Boot record to Boot Performance Table.\r
   //\r
-  CopyMem (PerformanceRuntimeData, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate));\r
-  PerformanceRuntimeData = PerformanceRuntimeData + mAcpiBootPerformanceTable->Header.Length;\r
+  CopyMem (mAcpiBootPerformanceTable, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate));\r
+  BootPerformanceData = BootPerformanceData + mAcpiBootPerformanceTable->Header.Length;\r
   //\r
   // Fill Boot records from boot drivers.\r
   //\r
-  CopyMem (PerformanceRuntimeData, mBootRecordBuffer, mBootRecordSize);\r
+  CopyMem (BootPerformanceData, mBootRecordBuffer, mBootRecordSize);\r
   mAcpiBootPerformanceTable->Header.Length += mBootRecordSize;\r
-  PerformanceRuntimeData = PerformanceRuntimeData + mBootRecordSize;\r
+  BootPerformanceData = BootPerformanceData + mBootRecordSize;\r
   if (SmmCommData != NULL && SmmCommData->BootRecordData != NULL) {\r
     //\r
     // Fill Boot records from SMM drivers.\r
     //\r
-    CopyMem (PerformanceRuntimeData, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);\r
+    CopyMem (BootPerformanceData, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);\r
     FreePool (SmmCommData->BootRecordData);\r
     mAcpiBootPerformanceTable->Header.Length = (UINT32) (mAcpiBootPerformanceTable->Header.Length + SmmCommData->BootRecordSize);\r
-    PerformanceRuntimeData = PerformanceRuntimeData + SmmCommData->BootRecordSize;\r
+    BootPerformanceData = BootPerformanceData + SmmCommData->BootRecordSize;\r
   }\r
   //\r
-  // Reserve space for boot records after ReadyToBoot.\r
-  //\r
-  PerformanceRuntimeData = PerformanceRuntimeData + PcdGet32 (PcdExtFpdtBootRecordPadSize);\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
@@ -413,13 +479,21 @@ InstallFirmwarePerformanceDataTable (
   //\r
   mFirmwarePerformanceTableTemplate.BootPointerRecord.BootPerformanceTablePointer = (UINT64) (UINTN) mAcpiBootPerformanceTable;\r
 \r
+  //\r
+  // Save S3 Performance Table address to Variable for use in S4 resume.\r
+  //\r
+  PerformanceVariable.S3PerformanceTablePointer = (EFI_PHYSICAL_ADDRESS) (UINTN) mAcpiS3PerformanceTable;\r
+  //\r
+  // Update S3 Performance Table Pointer in template.\r
+  //\r
+  mFirmwarePerformanceTableTemplate.S3PointerRecord.S3PerformanceTablePointer = (UINT64) (UINTN) mAcpiS3PerformanceTable;\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
+                  EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
                   sizeof (PerformanceVariable),\r
                   &PerformanceVariable\r
                   );\r
@@ -436,7 +510,10 @@ InstallFirmwarePerformanceDataTable (
                                 &mFirmwarePerformanceTableTemplateKey\r
                                 );\r
   if (EFI_ERROR (Status)) {\r
-    FreePool (PerformanceRuntimeDataHead);\r
+    FreePages (mAcpiBootPerformanceTable, EFI_SIZE_TO_PAGES (BootPerformanceDataSize));\r
+    if (mAcpiS3PerformanceTable != NULL) {\r
+      FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)));\r
+    }\r
     mAcpiBootPerformanceTable = NULL;\r
     mAcpiS3PerformanceTable = NULL;\r
     return Status;\r
@@ -703,6 +780,7 @@ FirmwarePerformanceDxeEntryPoint (
   EFI_STATUS               Status;\r
   EFI_HOB_GUID_TYPE        *GuidHob;\r
   FIRMWARE_SEC_PERFORMANCE *Performance;\r
+  VOID                     *Registration;\r
 \r
   //\r
   // Get Report Status Code Handler Protocol.\r
@@ -769,5 +847,31 @@ FirmwarePerformanceDxeEntryPoint (
     DEBUG ((EFI_D_ERROR, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));\r
   }\r
 \r
+  if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {\r
+    //\r
+    // Register callback function upon VariableArchProtocol and LockBoxProtocol\r
+    // to allocate S3 performance table memory and save the pointer to LockBox.\r
+    //\r
+    EfiCreateProtocolNotifyEvent (\r
+      &gEfiVariableArchProtocolGuid,\r
+      TPL_CALLBACK,\r
+      FpdtAllocateS3PerformanceTableMemory,\r
+      NULL,\r
+      &Registration\r
+      );\r
+    EfiCreateProtocolNotifyEvent (\r
+      &gEfiLockBoxProtocolGuid,\r
+      TPL_CALLBACK,\r
+      FpdtAllocateS3PerformanceTableMemory,\r
+      NULL,\r
+      &Registration\r
+      );\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_PERFORMANCE_TABLE_POINTER_RECORD);\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
index 89424acaaeab7b7e6f3c3ac6285edf19d982db86..5a9628f9245e5ce84a46b6ffe71c60ba156e279e 100644 (file)
@@ -5,7 +5,7 @@
 #  for Firmware Basic Boot Performance Record and other boot performance records, \r
 #  and install FPDT to ACPI table.\r
 #\r
-#  Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2011 - 2013, 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
   MemoryAllocationLib\r
   PcdLib\r
   HobLib\r
+  LockBoxLib\r
+  UefiLib\r
 \r
 [Protocols]\r
   gEfiAcpiTableProtocolGuid                     ## SOMETIMES_CONSUMES\r
   gEfiRscHandlerProtocolGuid                    ## CONSUMES\r
   gEfiSmmCommunicationProtocolGuid              ## SOMETIMES_CONSUMES\r
+  gEfiVariableArchProtocolGuid                  ## SOMETIMES_CONSUMES\r
+  gEfiLockBoxProtocolGuid                       ## SOMETIMES_CONSUMES\r
 \r
 [Guids]\r
   gEfiEventExitBootServicesGuid                 ## CONSUMES\r
@@ -65,6 +69,7 @@
   gEfiFirmwarePerformanceGuid                   ## SOMETIMES_CONSUMES ## Hob\r
   gEfiFirmwarePerformanceGuid                   ## SOMETIMES_CONSUMES ## SmiHandler\r
   gEfiFirmwarePerformanceGuid                   ## SOMETIMES_CONSUMES ## StatusCode Data\r
+  gFirmwarePerformanceS3PointerGuid             ## SOMETIMES_PRODUCES # SaveLockBox\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeOsLoaderLoad\r
index af9b4e3c650e68678e83be589e7ba02887aaf11a..70592cbc3c71a66c5c75f455e60fb35be02836d0 100644 (file)
@@ -7,7 +7,7 @@
   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 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2011 - 2013, 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
@@ -20,7 +20,6 @@
 \r
 #include <PiPei.h>\r
 \r
-#include <Ppi/ReadOnlyVariable2.h>\r
 #include <Ppi/ReportStatusCodeHandler.h>\r
 #include <Ppi/SecPerformance.h>\r
 \r
@@ -68,9 +67,8 @@ FpdtStatusCodeListenerPei (
 {\r
   EFI_STATUS                           Status;\r
   UINT64                               CurrentTime;\r
-  EFI_PEI_READ_ONLY_VARIABLE2_PPI      *VariableServices;\r
   UINTN                                VarSize;\r
-  FIRMWARE_PERFORMANCE_VARIABLE        PerformanceVariable;\r
+  EFI_PHYSICAL_ADDRESS                 S3PerformanceTablePointer;\r
   S3_PERFORMANCE_TABLE                 *AcpiS3PerformanceTable;\r
   EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD   *AcpiS3ResumeRecord;\r
   UINT64                               S3ResumeTotal;\r
@@ -90,33 +88,20 @@ FpdtStatusCodeListenerPei (
   //\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
+  S3PerformanceTablePointer = 0;\r
+  VarSize = sizeof (EFI_PHYSICAL_ADDRESS);\r
+  Status = RestoreLockBox (&gFirmwarePerformanceS3PointerGuid, &S3PerformanceTablePointer, &VarSize);\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
-  AcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.S3PerformanceTablePointer;\r
+  AcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) (UINTN) S3PerformanceTablePointer;\r
   ASSERT (AcpiS3PerformanceTable != NULL);\r
-  ASSERT (AcpiS3PerformanceTable->Header.Signature == EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE);\r
+  if (AcpiS3PerformanceTable->Header.Signature != EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE) {\r
+    DEBUG ((EFI_D_ERROR, "FPDT S3 performance data in ACPI memory get corrupted\n"));\r
+    return EFI_ABORTED;\r
+  }\r
   AcpiS3ResumeRecord = &AcpiS3PerformanceTable->S3Resume;\r
   AcpiS3ResumeRecord->FullResume = CurrentTime;\r
   //\r
index 0694899bcbfc1fa67944306f66566eadfd9237ad..aced5c521eb759dafac8bc109cc7f04b28960718 100644 (file)
@@ -7,7 +7,7 @@
 #  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
+#  Copyright (c) 2011 - 2013, 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
 \r
 [Ppis]\r
   gEfiPeiRscHandlerPpiGuid                      ## CONSUMES\r
-  gEfiPeiReadOnlyVariable2PpiGuid               ## SOMETIMES_CONSUMES\r
   gPeiSecPerformancePpiGuid                     ## CONSUMES\r
 \r
 [Guids]\r
   gEfiFirmwarePerformanceGuid                   ## CONSUMES\r
+  gFirmwarePerformanceS3PointerGuid             ## CONSUMES\r
 \r
 [FeaturePcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwarePerformanceDataTableS3Support\r