]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c
Separate memory allocation for FPDT S3 performance table and boot performance table...
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / FirmwarePerformanceDataTablePei / FirmwarePerformancePei.c
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