]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Move the memory allocation and variable set to BdsEntry, use VariableLock protocol...
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 23 May 2013 02:56:41 +0000 (02:56 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 23 May 2013 02:56:41 +0000 (02:56 +0000)
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14386 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h
IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c
IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h
IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
MdeModulePkg/Include/Guid/Performance.h

index c04c586f50d7ad2bc8e16e832754b3f6642373ba..06ba0fcf79031ca499ddca2cf2e4d2942f11bcb1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   BDS Lib functions which relate with create or process the boot option.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 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
@@ -2229,10 +2229,6 @@ BdsLibBootViaBootOption (
   LIST_ENTRY                TempBootLists;\r
   EFI_BOOT_LOGO_PROTOCOL    *BootLogo;\r
 \r
-  PERF_CODE (\r
-    AllocateMemoryForPerformanceData ();\r
-  );\r
-\r
   *ExitDataSize = 0;\r
   *ExitData     = NULL;\r
 \r
index 5d51635bf14b00be63fb797d03883b4cd41ab185..1384febc986f7b8570803555ffca96d3edce003c 100644 (file)
@@ -85,16 +85,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     #endif\r
 #endif\r
 \r
-/**\r
-\r
-  Allocates a block of memory to store performance data.\r
-\r
-**/\r
-VOID\r
-AllocateMemoryForPerformanceData (\r
-  VOID\r
-  );\r
-\r
 /**\r
 \r
   Writes performance data of booting into the allocated memory.\r
index 7e6d358d8463583f5e62c52ffcda965065acb0c3..047d2a7dbcd9c8557ba91cb904b4953ff33c30ba 100644 (file)
@@ -3,7 +3,7 @@
   performance, all the function will only include if the performance\r
   switch is set.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 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
@@ -19,7 +19,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 PERF_HEADER               mPerfHeader;\r
 PERF_DATA                 mPerfData;\r
 EFI_PHYSICAL_ADDRESS      mAcpiLowMemoryBase = 0x0FFFFFFFFULL;\r
-UINT32                    mAcpiLowMemoryLength = 0x4000;\r
 \r
 /**\r
   Get the short verion of PDB file name to be\r
@@ -134,40 +133,6 @@ GetNameFromHandle (
   return ;\r
 }\r
 \r
-/**\r
-\r
-  Allocates a block of memory to store performance data.\r
-\r
-**/\r
-VOID\r
-AllocateMemoryForPerformanceData (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-\r
-  if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {\r
-    //\r
-    // Allocate a block of memory that contain performance data to OS\r
-    //\r
-    Status = gBS->AllocatePages (\r
-                    AllocateMaxAddress,\r
-                    EfiReservedMemoryType,\r
-                    EFI_SIZE_TO_PAGES (mAcpiLowMemoryLength),\r
-                    &mAcpiLowMemoryBase\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      gRT->SetVariable (\r
-             L"PerfDataMemAddr",\r
-             &gPerformanceProtocolGuid,\r
-             EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-             sizeof (EFI_PHYSICAL_ADDRESS),\r
-             &mAcpiLowMemoryBase\r
-             );\r
-    }\r
-  }\r
-}\r
-\r
 /**\r
 \r
   Writes performance data of booting into the allocated memory.\r
@@ -209,16 +174,13 @@ WriteBootToOsPerformanceData (
   // List of flags indicating PerfEntry contains DXE handle\r
   //\r
   BOOLEAN                   *PerfEntriesAsDxeHandle;\r
+  UINTN                     VarSize;\r
 \r
   //\r
   // Record the performance data for End of BDS\r
   //\r
   PERF_END(NULL, "BDS", NULL, 0);\r
 \r
-  if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {\r
-    return;\r
-  }\r
-\r
   //\r
   // Retrieve time stamp count as early as possible\r
   //\r
@@ -241,6 +203,23 @@ WriteBootToOsPerformanceData (
     CountUp            = FALSE;\r
   }\r
 \r
+  if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {\r
+    VarSize = sizeof (EFI_PHYSICAL_ADDRESS);\r
+    Status = gRT->GetVariable (\r
+                    L"PerfDataMemAddr",\r
+                    &gPerformanceProtocolGuid,\r
+                    NULL,\r
+                    &VarSize,\r
+                    &mAcpiLowMemoryBase\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Fail to get the variable, return.\r
+      //\r
+      return;\r
+    }\r
+  }\r
+\r
   //\r
   // Put Detailed performance data into memory\r
   //\r
@@ -257,7 +236,7 @@ WriteBootToOsPerformanceData (
   }\r
 \r
   Ptr        = (UINT8 *) ((UINT32) mAcpiLowMemoryBase + sizeof (PERF_HEADER));\r
-  LimitCount = (mAcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);\r
+  LimitCount = (UINT32) (PERF_DATA_MAX_LENGTH - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);\r
 \r
   NumPerfEntries = 0;\r
   LogEntryKey    = 0;\r
index 14996f63e6f70ce473d2220632aee53bd23a59fc..0aba09c1bfb6db942eb3ca58a61ef1261095d759 100644 (file)
@@ -35,6 +35,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/LegacyDevOrder.h>\r
 #include <Guid/BdsHii.h>\r
 #include <Guid/ConnectConInEvent.h>\r
+#include <Guid/Performance.h>\r
 #include <Protocol/GenericMemoryTest.h>\r
 #include <Protocol/FormBrowser2.h>\r
 #include <Protocol/HiiConfigAccess.h>\r
@@ -66,7 +67,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/CapsuleLib.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/DevicePathLib.h>\r
-#include <Library/PcdLib.h>\r
 #include <Library/UefiHiiServicesLib.h>\r
 \r
 #include <Library/GenericBdsLib.h>\r
index 91c6dc72ddbc81176d7ea8a7f3c97d9175b27d47..77c88b0d241a5b77b5e609e44a04bb0d49b40968 100644 (file)
@@ -450,6 +450,54 @@ BdsFormalizeEfiGlobalVariable (
 \r
 }\r
 \r
+/**\r
+\r
+  Allocate a block of memory that will contain performance data to OS.\r
+\r
+**/\r
+VOID\r
+BdsAllocateMemoryForPerformanceData (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                    Status;\r
+  EFI_PHYSICAL_ADDRESS          AcpiLowMemoryBase;\r
+  EDKII_VARIABLE_LOCK_PROTOCOL  *VariableLock;\r
+\r
+  AcpiLowMemoryBase = 0x0FFFFFFFFULL;\r
+\r
+  //\r
+  // Allocate a block of memory that will contain performance data to OS.\r
+  //\r
+  Status = gBS->AllocatePages (\r
+                  AllocateMaxAddress,\r
+                  EfiReservedMemoryType,\r
+                  EFI_SIZE_TO_PAGES (PERF_DATA_MAX_LENGTH),\r
+                  &AcpiLowMemoryBase\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Save the pointer to variable for use in S3 resume.\r
+    //\r
+    Status = gRT->SetVariable (\r
+               L"PerfDataMemAddr",\r
+               &gPerformanceProtocolGuid,\r
+               EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+               sizeof (EFI_PHYSICAL_ADDRESS),\r
+               &AcpiLowMemoryBase\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+    //\r
+    // Mark L"PerfDataMemAddr" variable to read-only if the Variable Lock protocol exists\r
+    //\r
+    Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = VariableLock->RequestToLock (VariableLock, L"PerfDataMemAddr", &gPerformanceProtocolGuid);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+  }\r
+}\r
+\r
 /**\r
 \r
   Service routine for BdsInstance->Entry(). Devices are connected, the\r
@@ -479,6 +527,10 @@ BdsEntry (
   PERF_END (NULL, "DXE", NULL, 0);\r
   PERF_START (NULL, "BDS", NULL, 0);\r
 \r
+  PERF_CODE (\r
+    BdsAllocateMemoryForPerformanceData ();\r
+  );\r
+\r
   //\r
   // Initialize the global system boot option and driver option\r
   //\r
index d7768e1fc12669eade32e1f788ca548f45bb941b..c40046c878116ec22a398fefbaabe8ee85c0f366 100644 (file)
@@ -4,7 +4,7 @@
   * performance protocol interfaces.\r
   * performance variables.  \r
 \r
-Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available under \r
 the terms and conditions of the BSD License that accompanies this distribution.  \r
 The full text of the license may be found at\r
@@ -48,6 +48,7 @@ typedef struct {
 #define PERF_TOKEN_SIZE         28\r
 #define PERF_TOKEN_LENGTH       (PERF_TOKEN_SIZE - 1)\r
 #define PERF_PEI_ENTRY_MAX_NUM  50\r
+#define PERF_DATA_MAX_LENGTH    0x4000\r
 \r
 typedef struct {\r
   CHAR8   Token[PERF_TOKEN_SIZE];\r