]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/Application/VariableInfo.c
Add Profiling support for Variable store and added a specialized caching algorithm
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / Application / VariableInfo.c
diff --git a/MdeModulePkg/Universal/Variable/Application/VariableInfo.c b/MdeModulePkg/Universal/Variable/Application/VariableInfo.c
new file mode 100644 (file)
index 0000000..8986626
--- /dev/null
@@ -0,0 +1,90 @@
+/** @file\r
+  If the Variable services have PcdVariableCollectStatistics set to TRUE then \r
+  the EFI system table will contain statistical information about variable usage\r
+  an this utility will print out the information. You can use console redirection\r
+  to capture the data.\r
+  \r
+  Copyright (c) 2006 - 2007, Intel Corporation                                                         \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
+  http://opensource.org/licenses/bsd-license.php                                            \r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiApplicationEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Guid/VariableInfo.h>\r
+\r
+\r
+/**\r
+  The user Entry Point for Application. The user code starts with this function\r
+  as the real entry point for the image goes into a library that calls this \r
+  function.\r
+\r
+\r
+  @param[in] ImageHandle    The firmware allocated handle for the EFI image.  \r
+  @param[in] SystemTable    A pointer to the EFI System Table.\r
+  \r
+  @retval EFI_SUCCESS       The entry point is executed successfully.\r
+  @retval other             Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+UefiMain (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  VARIABLE_INFO_ENTRY   *VariableInfo;\r
+  VARIABLE_INFO_ENTRY   *Entry;\r
+\r
+  Status = EfiGetSystemConfigurationTable (&gEfiVariableInfoGuid, (VOID **)&Entry);\r
+  if (!EFI_ERROR (Status) && (Entry != NULL)) {\r
+    Print (L"Non-Volatile EFI Variables:\n");\r
+    VariableInfo = Entry;\r
+    do {\r
+      if (!VariableInfo->Volatile) {\r
+        Print (\r
+          L"%g R%03d(%03d) W%03d D%03d:%s\n", \r
+          &VariableInfo->VendorGuid,  \r
+          VariableInfo->ReadCount,\r
+          VariableInfo->CacheCount,\r
+          VariableInfo->WriteCount,\r
+          VariableInfo->DeleteCount,\r
+          VariableInfo->Name\r
+          );\r
+      }\r
+\r
+      VariableInfo = VariableInfo->Next;\r
+    } while (VariableInfo != NULL);\r
+\r
+    Print (L"Volatile EFI Variables:\n");\r
+    VariableInfo = Entry;\r
+    do {\r
+      if (VariableInfo->Volatile) {\r
+        Print (\r
+          L"%g R%03d(%03d) W%03d D%03d:%s\n", \r
+          &VariableInfo->VendorGuid,  \r
+          VariableInfo->ReadCount,\r
+          VariableInfo->CacheCount,\r
+          VariableInfo->WriteCount,\r
+          VariableInfo->DeleteCount,\r
+          VariableInfo->Name\r
+          );\r
+      }\r
+      VariableInfo = VariableInfo->Next;\r
+    } while (VariableInfo != NULL);\r
+\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r