]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Add performance property configuration table
authorStar Zeng <star.zeng@intel.com>
Sun, 12 Jun 2016 06:31:58 +0000 (23:31 -0700)
committerMichael Kinney <michael.d.kinney@intel.com>
Thu, 23 Feb 2017 17:01:17 +0000 (09:01 -0800)
Define PERFORMANCE_PROPERTY, and install performance property configuration
table in DxeCorePerformanceLib and SmmCorePerformanceLib.

Cc: Andrew Fish <afish@apple.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Cinnamon Shia <cinnamon.shia@hpe.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
MdeModulePkg/Include/Guid/Performance.h
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h
MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf

index c40046c878116ec22a398fefbaabe8ee85c0f366..df40c6ce5b7967de65e12e7a3060d2c414db4c6a 100644 (file)
@@ -4,7 +4,7 @@
   * performance protocol interfaces.\r
   * performance variables.  \r
 \r
-Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2009 - 2017, 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
@@ -18,6 +18,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef __PERFORMANCE_DATA_H__\r
 #define __PERFORMANCE_DATA_H__\r
 \r
+#define PERFORMANCE_PROPERTY_REVISION 0x1\r
+\r
+typedef struct {\r
+  UINT32                Revision;\r
+  UINT32                Reserved;\r
+  UINT64                Frequency;\r
+  UINT64                TimerStartValue;\r
+  UINT64                TimerEndValue;\r
+} PERFORMANCE_PROPERTY;\r
+\r
 //\r
 // PEI_PERFORMANCE_STRING_SIZE must be a multiple of 8.\r
 //\r
index 4739bb842661e834d1c65b05d74824342e3218c4..1564514518d3a5475a1812df5a24c7541831c86d 100644 (file)
@@ -10,7 +10,7 @@
   This library is mainly used by DxeCore to start performance logging to ensure that\r
   Performance Protocol is installed at the very beginning of DXE phase.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -61,6 +61,8 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {
   GetGaugeEx\r
   };\r
 \r
+PERFORMANCE_PROPERTY  mPerformanceProperty;\r
+\r
 /**\r
   Searches in the gauge array with keyword Handle, Token, Module and Identifier.\r
 \r
@@ -502,6 +504,8 @@ DxeCorePerformanceLibConstructor (
   )\r
 {\r
   EFI_STATUS                Status;\r
+  PERFORMANCE_PROPERTY      *PerformanceProperty;\r
+\r
 \r
   if (!PerformanceMeasurementEnabled ()) {\r
     //\r
@@ -531,7 +535,22 @@ DxeCorePerformanceLibConstructor (
 \r
   InternalGetPeiPerformance ();\r
 \r
-  return Status;\r
+  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, &PerformanceProperty);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Install configuration table for performance property.\r
+    //\r
+    mPerformanceProperty.Revision  = PERFORMANCE_PROPERTY_REVISION;\r
+    mPerformanceProperty.Reserved  = 0;\r
+    mPerformanceProperty.Frequency = GetPerformanceCounterProperties (\r
+                                       &mPerformanceProperty.TimerStartValue,\r
+                                       &mPerformanceProperty.TimerEndValue\r
+                                       );\r
+    Status = gBS->InstallConfigurationTable (&gPerformanceProtocolGuid, &mPerformanceProperty);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
index e091c6271426bf0ae093460765d303f5b6fa8421..5b89ce278d57614b52c2ecf22a7e1dd375a07149 100644 (file)
   BaseLib\r
   HobLib\r
   DebugLib\r
+  UefiLib\r
 \r
 \r
 [Guids]\r
   ## SOMETIMES_CONSUMES   ## HOB\r
   ## PRODUCES             ## UNDEFINED # Install protocol\r
+  ## PRODUCES             ## SystemTable\r
   gPerformanceProtocolGuid\r
   ## SOMETIMES_CONSUMES   ## HOB\r
   ## PRODUCES             ## UNDEFINED # Install protocol\r
index 2b9ccd2fee0c1895fb5044965302f5023e791f4a..f1540d8c1c2f964f2a0432ac5d2c141f1d468e67 100644 (file)
@@ -4,7 +4,7 @@
   This header file holds the prototypes of the Performance and PerformanceEx Protocol published by this\r
   library instance at its constructor.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, 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
@@ -32,6 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/PcdLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiLib.h>\r
 \r
 //\r
 // Interface declarations for PerformanceEx Protocol.\r
index 6f8d2dd064a3920b8715f9c1b42eda346abb3c3e..a03a8c8dcc4679d5d93533e5f32db13f319c6762 100644 (file)
@@ -69,6 +69,8 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {
   GetGaugeEx\r
 };\r
 \r
+PERFORMANCE_PROPERTY mPerformanceProperty;\r
+\r
 /**\r
   Searches in the gauge array with keyword Handle, Token, Module and Identfier.\r
 \r
@@ -687,6 +689,7 @@ InitializeSmmCorePerformanceLib (
 {\r
   EFI_STATUS                Status;\r
   EFI_HANDLE                Handle;\r
+  PERFORMANCE_PROPERTY      *PerformanceProperty;\r
 \r
   //\r
   // Initialize spin lock\r
@@ -725,6 +728,21 @@ InitializeSmmCorePerformanceLib (
   ASSERT_EFI_ERROR (Status);\r
   Status = gSmst->SmiHandlerRegister (SmmPerformanceHandlerEx, &gSmmPerformanceExProtocolGuid, &Handle);\r
   ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, &PerformanceProperty);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // Install configuration table for performance property.\r
+    //\r
+    mPerformanceProperty.Revision  = PERFORMANCE_PROPERTY_REVISION;\r
+    mPerformanceProperty.Reserved  = 0;\r
+    mPerformanceProperty.Frequency = GetPerformanceCounterProperties (\r
+                                       &mPerformanceProperty.TimerStartValue,\r
+                                       &mPerformanceProperty.TimerEndValue\r
+                                       );\r
+    Status = gBS->InstallConfigurationTable (&gPerformanceProtocolGuid, &mPerformanceProperty);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
 }\r
 \r
 /**\r
index 160a749390e13be343e3d2280309f61bf88789fe..1b2fbd3ea3ae99ac1cf748416ca26d51cd48006c 100644 (file)
@@ -8,7 +8,7 @@
 #  This library is mainly used by SMM Core to start performance logging to ensure that\r
 #  SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.\r
 #  \r
-#  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2011 - 2017, 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
@@ -57,6 +57,7 @@
   SynchronizationLib\r
   SmmServicesTableLib\r
   SmmMemLib\r
+  UefiLib\r
 \r
 [Protocols]\r
   gEfiSmmBase2ProtocolGuid                  ## CONSUMES\r
@@ -68,6 +69,8 @@
   ## PRODUCES ## UNDEFINED # Install protocol\r
   ## CONSUMES ## UNDEFINED # SmiHandlerRegister\r
   gSmmPerformanceExProtocolGuid\r
+  ## PRODUCES ## SystemTable\r
+  gPerformanceProtocolGuid\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask    ## CONSUMES\r