]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Log performance data below 4G
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 14 Aug 2009 05:58:46 +0000 (05:58 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 14 Aug 2009 05:58:46 +0000 (05:58 +0000)
2. Reuse the allocated data region if it's already allocated

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9072 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c

index 66dd20a55b2ec760b39c25e0a047f3535076eb80..119a6e46d24fc8e86ab9defdf88f2e4776904f7c 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 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2004 - 2009, Intel Corporation. <BR>\r
 All rights reserved. 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
@@ -18,6 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 PERF_HEADER               mPerfHeader;\r
 PERF_DATA                 mPerfData;\r
+EFI_PHYSICAL_ADDRESS      mAcpiLowMemoryBase = 0x0FFFFFFFFULL;\r
 \r
 /**\r
   Get the short verion of PDB file name to be\r
@@ -144,7 +145,6 @@ WriteBootToOsPerformanceData (
   )\r
 {\r
   EFI_STATUS                Status;\r
-  EFI_PHYSICAL_ADDRESS      AcpiLowMemoryBase;\r
   UINT32                    AcpiLowMemoryLength;\r
   UINT32                    LimitCount;\r
   EFI_HANDLE                *Handles;\r
@@ -187,25 +187,6 @@ WriteBootToOsPerformanceData (
     CountUp            = FALSE;\r
   }\r
 \r
-  AcpiLowMemoryLength   = 0x2000;\r
-\r
-  //\r
-  // Allocate a block of memory that contain performance data to OS\r
-  //\r
-  Status = gBS->AllocatePages (\r
-                  AllocateAnyPages,\r
-                  EfiReservedMemoryType,\r
-                  EFI_SIZE_TO_PAGES (AcpiLowMemoryLength),\r
-                  &AcpiLowMemoryBase\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return ;\r
-  }\r
-\r
-\r
-  Ptr                   = (UINT8 *) ((UINT32) AcpiLowMemoryBase + sizeof (PERF_HEADER));\r
-  LimitCount            = (AcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);\r
-\r
   //\r
   // Put Detailed performance data into memory\r
   //\r
@@ -218,9 +199,32 @@ WriteBootToOsPerformanceData (
                   &Handles\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    gBS->FreePages (AcpiLowMemoryBase, 1);\r
     return ;\r
   }\r
+\r
+\r
+  AcpiLowMemoryLength = 0x4000;\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 (AcpiLowMemoryLength),\r
+                    &mAcpiLowMemoryBase\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      FreePool (Handles);\r
+      return ;\r
+    }\r
+  }\r
+\r
+\r
+  Ptr        = (UINT8 *) ((UINT32) mAcpiLowMemoryBase + sizeof (PERF_HEADER));\r
+  LimitCount = (AcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);\r
+\r
+\r
   \r
   //\r
   // Get DXE drivers performance\r
@@ -296,10 +300,10 @@ Done:
   mPerfHeader.Signiture = PERFORMANCE_SIGNATURE;\r
 \r
   //\r
-  // Put performance data to ACPI memory\r
+  // Put performance data to Reserved memory\r
   //\r
   CopyMem (\r
-    (UINTN *) (UINTN) AcpiLowMemoryBase,\r
+    (UINTN *) (UINTN) mAcpiLowMemoryBase,\r
     &mPerfHeader,\r
     sizeof (PERF_HEADER)\r
     );\r
@@ -309,7 +313,7 @@ Done:
         &gPerformanceProtocolGuid,\r
         EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
         sizeof (EFI_PHYSICAL_ADDRESS),\r
-        &AcpiLowMemoryBase\r
+        &mAcpiLowMemoryBase\r
         );\r
 \r
   return ;\r