]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg: Removing ipf which is no longer supported from edk2.
authorchenc2 <chen.a.chen@intel.com>
Fri, 29 Jun 2018 03:33:44 +0000 (11:33 +0800)
committerZhang, Chao B <chao.b.zhang@intel.com>
Fri, 29 Jun 2018 08:19:48 +0000 (16:19 +0800)
Removing rules for Ipf sources file:
* Remove the source file which path with "ipf" and also listed in
  [Sources.IPF] section of INF file.
* Remove the source file which listed in [Components.IPF] section
  of DSC file and not listed in any other [Components] section.
* Remove the embedded Ipf code for MDE_CPU_IPF.

Removing rules for Inf file:
* Remove IPF from VALID_ARCHITECTURES comments.
* Remove DXE_SAL_DRIVER from LIBRARY_CLASS in [Defines] section.
* Remove the INF which only listed in [Components.IPF] section in DSC.
* Remove statements from [BuildOptions] that provide IPF specific flags.
* Remove any IPF sepcific sections.

Removing rules for Dec file:
* Remove [Includes.IPF] section from Dec.

Removing rules for Dsc file:
* Remove IPF from SUPPORTED_ARCHITECTURES in [Defines] section of DSC.
* Remove any IPF specific sections.
* Remove statements from [BuildOptions] that provide IPF specific flags.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Chao B Zhang <chao.b.zhang@intel.com>
54 files changed:
SecurityPkg/Hash2DxeCrypto/Hash2DxeCrypto.inf
SecurityPkg/Library/DxeImageAuthenticationStatusLib/DxeImageAuthenticationStatusLib.inf
SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
SecurityPkg/Library/DxeRsa2048Sha256GuidedSectionExtractLib/DxeRsa2048Sha256GuidedSectionExtractLib.inf
SecurityPkg/Library/DxeTcg2PhysicalPresenceLib/DxeTcg2PhysicalPresenceLib.inf
SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.inf
SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
SecurityPkg/Library/DxeTpmMeasureBootLib/DxeTpmMeasureBootLib.inf
SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf
SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.inf
SecurityPkg/Library/HashInstanceLibSha1/HashInstanceLibSha1.inf
SecurityPkg/Library/HashInstanceLibSha256/HashInstanceLibSha256.inf
SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf
SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.inf
SecurityPkg/Library/HashLibTpm2/HashLibTpm2.inf
SecurityPkg/Library/PeiRsa2048Sha256GuidedSectionExtractLib/PeiRsa2048Sha256GuidedSectionExtractLib.inf
SecurityPkg/Library/PeiTcg2PhysicalPresenceLib/PeiTcg2PhysicalPresenceLib.inf
SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.inf
SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
SecurityPkg/Library/TcgPpVendorLibNull/TcgPpVendorLibNull.inf
SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm.inf
SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf
SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterDxe.inf
SecurityPkg/Library/Tpm2DeviceLibRouter/Tpm2DeviceLibRouterPei.inf
SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf
SecurityPkg/Library/TpmCommLib/TpmCommLib.inf
SecurityPkg/SecurityPkg.dsc
SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.inf
SecurityPkg/Tcg/MemoryOverwriteRequestControlLock/TcgMorLockSmm.inf
SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
SecurityPkg/Tcg/PhysicalPresencePei/PhysicalPresencePei.inf
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigDxe.inf
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPei.inf
SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf
SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf
SecurityPkg/Tcg/TcgDxe/TcgDxe.inf
SecurityPkg/Tcg/TcgPei/TcgPei.inf
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.c [deleted file]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.h [deleted file]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf [deleted file]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.uni [deleted file]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSalExtra.uni [deleted file]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c [deleted file]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Reclaim.c [deleted file]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c [deleted file]
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h [deleted file]
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf

index ffc0efc4d84d1f2c84f668c21c1e1ce643080fa5..35bf66f44d228dc278491c6d674076c92780bed2 100644 (file)
@@ -27,7 +27,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources.common]\r
index 6c826a9cbf3ac21cb02f6a5cc9ccc31cc6074d72..f72bd1f4d28710a157a1c8c02fbde11135eb9c73 100644 (file)
   FILE_GUID                      = EB92D1DE-7C36-4680-BB88-A67E96049F72\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   CONSTRUCTOR                    = DxeImageAuthenticationStatusLibConstructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 3430b6ea9dacd878443684c55d1dfbfb6a2b8028..7f09c629add0083c9ba7389a43973a68981f5935 100644 (file)
@@ -8,7 +8,7 @@
 #  This external input must be validated carefully to avoid security issues such as\r
 #  buffer overflow or integer overflow.\r
 #\r
-# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2018, 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
   FILE_GUID                      = 0CA970E1-43FA-4402-BC0A-81AF336BFFD6\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   CONSTRUCTOR                    = DxeImageVerificationLibConstructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index cbb553c0bfcb6789520f8f2ee41db3931010d875..5931d6c33990ff601f04f1b39d1fe6a60fb949fb 100644 (file)
   FILE_GUID                      = 0AD6C423-4732-4cf3-9CE3-0A5416D634A5\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = NULL|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   CONSTRUCTOR                    = DxeRsa2048Sha256GuidedSectionExtractLibConstructor\r
   MODULE_UNI_FILE                = DxeRsa2048Sha256GuidedSectionExtractLib.uni\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index d74f00020340669f568fef773b4a857ca4cbb1c3..18aa1b40cbb6bd6b9f65a9a3435667cc71b4fd1b 100644 (file)
   FILE_GUID                      = 7E507A86-DE8B-4AD3-BC4C-0498389098D3\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = Tcg2PhysicalPresenceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = Tcg2PhysicalPresenceLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index bf7e16ccb788b2064d436b08c7b37c430b9568b3..148a14fc2e3c5ea69fb99e27cb4ad3b768d13e7b 100644 (file)
   FILE_GUID                      = EBC43A46-34AC-4F07-A7F5-A5394619361C\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = TcgPhysicalPresenceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = TcgPhysicalPresenceLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   CONSTRUCTOR                    = TcgPhysicalPresenceLibConstructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index e5aaba2407af15fdd9d8cc6471be8a38028c13ad..22eaced5fa1e61435743d9d037933e50fb12288b 100644 (file)
   FILE_GUID                      = 778CE4F4-36BD-4ae7-B8F0-10B420B0D174\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   CONSTRUCTOR                    = DxeTpm2MeasureBootLibConstructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index a2c5847747713f91b515bab988af6bea2d56662e..ee4bcb87ff9a2b995d10b96dce7ef821e7af88d2 100644 (file)
   FILE_GUID                      = 6C60C7D0-922A-4b7c-87D7-E503EDD73BBF\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = NULL|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   CONSTRUCTOR                    = DxeTpmMeasureBootLibConstructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 17527ba025a212d5eaf41349a9d5cd754505bbb1..f6dfc1e08637636a227e7f19ed1dd088fe2eaa8c 100644 (file)
   FILE_GUID                      = 30930D10-AF5B-4abf-80E6-EB4FFC0AE9D1\r
   MODULE_TYPE                    = UEFI_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = TpmMeasurementLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = TpmMeasurementLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   MODULE_UNI_FILE                = DxeTpmMeasurementLib.uni\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 215b3cbecd1ee03e9271dd65be25d877d065f385..9b14a61bb0a986e5f9a4bbe06b3585f3f0d0ff2b 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 # Instance of FmpAuthentication Library for DXE/PEI post memory phase.\r
 #\r
-#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2016 - 2018, 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
@@ -26,7 +26,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index cdd22429c274fafd7a425a0bd7a011e2371de459..8633319e566361d51d3526e114d2a590a8ebf274 100644 (file)
@@ -26,7 +26,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 588c5f1ac4e63d0e866d42c190eba155f9a23534..83413c62e53e86e86beb7bbf377c6413bca61af1 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 #  This library can be registered to BaseCrypto router, to serve as hash engine.\r
 #\r
-# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2013 - 2018, 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
@@ -26,7 +26,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index a4b2ccf9e215a023b8f103ccf65582ff18c9003a..bedc15df024f98811bfa594d699c681cb041d0fb 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 #  This library can be registered to BaseCrypto router, to serve as hash engine.\r
 #\r
-# Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2013 - 2018, 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
@@ -26,7 +26,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 4e9ce56c69169e5a1eb6010aedfe51ea7cd9cf87..2aaa5a11129e0a041786b378d797f6b2b1d37ec1 100644 (file)
   FILE_GUID                      = 158DC712-F15A-44dc-93BB-1675045BE066\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = HashLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = HashLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
   CONSTRUCTOR                    = HashLibBaseCryptoRouterDxeConstructor\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 20824ce75e41ae6d46e95aa9ac97228a00e8cdb3..1463db9e6b8e9484bd78c1657292244acc7cda8c 100644 (file)
@@ -28,7 +28,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index db97d4547ddc43cec3a2c4bd24db525ceb573f9d..e74a56ffd0367b9d8751f6a348b2af21f62f8eb1 100644 (file)
@@ -26,7 +26,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index d11d7309f9e4790100e3cdea26844535596a33f7..da7ac38d0ae423d1f7394622a7c7e5fbf9117ffb 100644 (file)
@@ -29,7 +29,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index adcbceedb3501d83736b4f3effa3d60ed1558b32..ef00579b42d2ef3ffd1b4a40823a7e0b2b5e47a8 100644 (file)
@@ -25,7 +25,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 2f2ea4fc254c0177be48d426a6c1fce15f23dce8..979a33705de08d5d0620a5acb775ccc39cc8f8c9 100644 (file)
@@ -29,7 +29,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index dd46e0ec2171d8e4eec7fb2968abcc2924d8fc38..acbc357256a6415a0e315a9a07f7bfb7c24f60ac 100644 (file)
@@ -30,7 +30,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 0a1588a9087b4e0678804da87bb85cc4d8723bbf..1dd6681a7ee9c7c31222140d11d75d4e48aa1542 100644 (file)
@@ -23,7 +23,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index db1abb4c53dc76c2dc10b7f75dd513a30edb06d7..caedcd0883a15ba61bf373945c42e4d654ca0099 100644 (file)
@@ -23,7 +23,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index f5dbb721b80566ced7948a93f4af681c0292c779..e95b390df5e8f7cb3c22fae3269ecaa498ceb097 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 #  This library is used by other modules to send TPM 1.2 command.\r
 #\r
-# Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2013 - 2018, 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
@@ -25,7 +25,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 949493cae8030187bab495b0d7edfc0044016f1c..52c52ef0a04264b3cf07b18f516a6b80ababef67 100644 (file)
@@ -27,7 +27,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 25b7260f7229442776c8780a90629fdaff4c4f3e..72f513dfeee9e3e23277138bb652b1fafc9b5e1a 100644 (file)
   FILE_GUID                      = 4D8B77D9-E923-48f8-B070-4053D78B7E56\r
   MODULE_TYPE                    = BASE\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = Tpm12DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = Tpm12DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 481a8786717b44b0ae9c01f556f0e372928c095d..bf7f5852094e7927bd98819454ab1855b26b97d3 100644 (file)
@@ -3,7 +3,7 @@
 #\r
 #  This library is used by other modules to send TPM 2.0 command.\r
 #\r
-# Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2013 - 2018, 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
@@ -25,7 +25,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index b41c6cbd2d31b82bcbd655610fd31759f63fff57..b6867bc4fff4ecf00c9229eb4934f8eef5476ca2 100644 (file)
@@ -32,7 +32,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index b418e7380be5ca9f4b2663f782caf3dac63aa753..14e5e2e0f5f8ac086ae5f8fac1a8615639452554 100644 (file)
@@ -28,7 +28,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 26684f9864fadba1a4e2e23cd16ba47e3ed3cf3d..eaee48dc41a30451754dbc4265ef1d655ad0c0c8 100644 (file)
   FILE_GUID                      = C3D69D87-5200-4aab-A6DB-2569BA1A92FC\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = Tpm2DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = Tpm2DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 877cf95bc18e235c318f6effc6e2ad61440625e6..7bd0f96b222f8b89addc6e6362eae308458262e9 100644 (file)
@@ -27,7 +27,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index cffc4afb4d50f5da04d54e42470cac9c0eba6e9a..2a16c899cc34c480e5ca4b68b703780e812504e8 100644 (file)
   FILE_GUID                      = A1B0B230-67DC-431E-A94A-A96AF1EBE637\r
   MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = Tpm2DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
+  LIBRARY_CLASS                  = Tpm2DeviceLib|DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 9ca66d1805b70868ec4ce744387ab1cc4dde6ccf..c67efaa6c2dc5254078eb8999d7813c7557b81b2 100644 (file)
@@ -26,7 +26,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 9f1a91e5a9c7dd68b3a895c5f29b9166d1595b38..12994439f02cf7f41546b8f1099a7ec9ce643ec7 100644 (file)
@@ -19,7 +19,7 @@
   PLATFORM_VERSION               = 0.98\r
   DSC_SPECIFICATION              = 0x00010005\r
   OUTPUT_DIRECTORY               = Build/SecurityPkg\r
-  SUPPORTED_ARCHITECTURES        = IA32|IPF|X64|EBC|ARM|AARCH64\r
+  SUPPORTED_ARCHITECTURES        = IA32|X64|EBC|ARM|AARCH64\r
   BUILD_TARGETS                  = DEBUG|RELEASE|NOOPT\r
   SKUID_IDENTIFIER               = DEFAULT\r
 \r
   Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf\r
   Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf\r
 \r
-[LibraryClasses.IPF.DXE_SAL_DRIVER]\r
-  ExtendedSalLib|MdePkg/Library/DxeRuntimeExtendedSalLib/DxeRuntimeExtendedSalLib.inf\r
-  BaseCryptLib|CryptoPkg/Library/BaseCryptLibRuntimeCryptProtocol/BaseCryptLibRuntimeCryptProtocol.inf\r
-  HashLib|SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterDxe.inf\r
-  Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibTcg/Tpm12DeviceLibTcg.inf\r
-  Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf\r
-\r
 [LibraryClasses.common.DXE_SMM_DRIVER]\r
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf\r
   SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.inf\r
   SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationLibRsa2048Sha256.inf\r
 \r
-[Components.IA32, Components.X64, Components.IPF, Components.ARM, Components.AARCH64]\r
+[Components.IA32, Components.X64, Components.ARM, Components.AARCH64]\r
   SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf\r
 \r
-[Components.IA32, Components.X64, Components.IPF]\r
+[Components.IA32, Components.X64]\r
 #  SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProviderDxe.inf\r
 #  SecurityPkg/UserIdentification/UsbCredentialProviderDxe/UsbCredentialProviderDxe.inf\r
   SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf\r
   SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf\r
   SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.inf\r
 \r
-[Components.IPF]\r
-  SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf\r
-\r
 [BuildOptions]\r
    MSFT:*_*_IA32_DLINK_FLAGS = /ALIGN:256\r
   INTEL:*_*_IA32_DLINK_FLAGS = /ALIGN:256\r
index a131342bb603cfc78c830aca7001e8adca74ae84..6f9a77b868c9058f1420ca24603fd06f48fbe006 100644 (file)
@@ -5,7 +5,7 @@
 #  TPer Reset for those encrypted drives through EFI_STORAGE_SECURITY_COMMAND_PROTOCOL\r
 #  at EndOfDxe.\r
 #\r
-# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2018, 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
@@ -28,7 +28,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 1623bd03bb33804bb4dae85211401c0e86264dbe..d233ccdbdb0b32a0809d5a9343582b6059226fe4 100644 (file)
@@ -6,7 +6,7 @@
 #  NOTE: This module only handles secure MOR V1 and is deprecated.\r
 #  The secure MOR V2 is handled inside of variable driver.\r
 #\r
-# Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2015 - 2018, 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
@@ -29,7 +29,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 0ac550a728730fa3c5e5b065c8a9eb3d61ca8f51..0a82f30959bbcaab5b73575374e4c9f530174d0b 100644 (file)
@@ -25,7 +25,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index f4c0e059e7b863e8dd04f44a0d6759921928435f..d725c4f21e7022a19394e150ce556bff8fc9764a 100644 (file)
@@ -29,7 +29,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 2343ab49aa79dbbcdbb120d5015ac97de225fa8b..bb7a52192cca54daa7a8afe78ee124be6db397b8 100644 (file)
@@ -25,7 +25,7 @@
   UNLOAD_IMAGE                   = Tcg2ConfigDriverUnload\r
 \r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 0d151ba019197ce49b3684bf0457eb7fef81f570..a0136bc0c5900b860d6da0b18e8aa98ae4096c84 100644 (file)
@@ -24,7 +24,7 @@
   ENTRY_POINT                    = Tcg2ConfigPeimEntryPoint\r
 \r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 # [BootMode]\r
 #   S3_RESUME                 ## SOMETIMES_CONSUMES\r
index 2bc45bddf58dffa7b04099209da1a1bb3c1830aa..b875ab7e0106d493020d78dff1b0562e5122865c 100644 (file)
@@ -36,7 +36,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index a4aae1488ff8eb57842dbdb705c504c3f072b01f..9608f9ae7e459b6046dcc39433e97946140c95ee 100644 (file)
@@ -8,7 +8,7 @@
 #\r
 #  This module will initialize TPM device, measure reported FVs and BIOS version.\r
 #\r
-# Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # Copyright (c) 2017, Microsoft 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
@@ -31,7 +31,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 # [BootMode]\r
 #   S3_RESUME                 ## SOMETIMES_CONSUMES\r
index 22ff80aae2ff41dcab81c9bad906f04d923892e6..179426978ce43e61e2f0d383966acaf0beec79ff 100644 (file)
@@ -23,7 +23,7 @@
   UNLOAD_IMAGE                   = TcgConfigDriverUnload\r
 \r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r
index 320f55210a437c513b78c77c6f37c9d9b0c1a3b8..fee8dafc23d7c7a1ea1fa8659f4089729824d596 100644 (file)
@@ -24,7 +24,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
 #\r
 \r
 [Sources]\r
index 2573cd37d75d65551cc8e5cb5ffcb39bc280c851..0252511391bc1ad3cb8ea5926ca621dde5a5d9a9 100644 (file)
@@ -26,7 +26,7 @@
 #\r
 # The following information is for reference only and not required by the build tools.\r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 # [BootMode]\r
 #   S3_RESUME                 ## SOMETIMES_CONSUMES\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.c b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.c
deleted file mode 100644 (file)
index 8799458..0000000
+++ /dev/null
@@ -1,886 +0,0 @@
-/** @file\r
-  Implement authentication services for the authenticated variable\r
-  service in UEFI2.2.\r
-\r
-Copyright (c) 2009 - 2018, 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
-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 "Variable.h"\r
-#include "AuthService.h"\r
-\r
-///\r
-/// Global database array for scratch\r
-///\r
-UINT32   mPubKeyNumber;\r
-UINT32   mPlatformMode;\r
-EFI_GUID mSignatureSupport[SIGSUPPORT_NUM] = {EFI_CERT_RSA2048_SHA256_GUID, EFI_CERT_RSA2048_SHA1_GUID};\r
-//\r
-// Public Exponent of RSA Key.\r
-//\r
-CONST UINT8 mRsaE[] = { 0x01, 0x00, 0x01 };\r
-\r
-/**\r
-  Initializes for authenticated varibale service.\r
-\r
-  @retval EFI_SUCCESS           The function successfully executed.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to allocate enough memory resources.\r
-\r
-**/\r
-EFI_STATUS\r
-AutenticatedVariableServiceInitialize (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  VARIABLE_POINTER_TRACK            Variable;\r
-  UINT8                             VarValue;\r
-  UINT32                            VarAttr;\r
-  UINTN                             DataSize;\r
-  UINTN                             CtxSize;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-  BOOLEAN                           Valid;\r
-\r
-  ZeroMem (&VariableHeader, sizeof (AUTHENTICATED_VARIABLE_HEADER));\r
-\r
-  mVariableModuleGlobal->AuthenticatedVariableGuid[Physical] = &gEfiAuthenticatedVariableGuid;\r
-  mVariableModuleGlobal->CertRsa2048Sha256Guid[Physical]     = &gEfiCertRsa2048Sha256Guid;\r
-  mVariableModuleGlobal->ImageSecurityDatabaseGuid[Physical] = &gEfiImageSecurityDatabaseGuid;\r
-\r
-  //\r
-  // Initialize hash context.\r
-  //\r
-  CtxSize   = Sha256GetContextSize ();\r
-  mVariableModuleGlobal->HashContext[Physical] = AllocateRuntimePool (CtxSize);\r
-  ASSERT (mVariableModuleGlobal->HashContext[Physical] != NULL);\r
-  //\r
-  // Check "AuthVarKeyDatabase" variable's existence.\r
-  // If it doesn't exist, create a new one with initial value of 0 and EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.\r
-  //\r
-  Status = FindVariable (\r
-             mVariableModuleGlobal->VariableName[Physical][VAR_AUTH_KEY_DB],\r
-             &gEfiAuthenticatedVariableGuid,\r
-             &Variable,\r
-             &mVariableModuleGlobal->VariableGlobal[Physical],\r
-             mVariableModuleGlobal->FvbInstance\r
-             );\r
-\r
-  if (Variable.CurrPtr == 0x0) {\r
-    VarAttr       = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS;\r
-    VarValue      = 0;\r
-    mPubKeyNumber = 0;\r
-    Status        = UpdateVariable (\r
-                      mVariableModuleGlobal->VariableName[Physical][VAR_AUTH_KEY_DB],\r
-                      &gEfiAuthenticatedVariableGuid,\r
-                      &VarValue,\r
-                      sizeof(UINT8),\r
-                      VarAttr,\r
-                      0,\r
-                      0,\r
-                      FALSE,\r
-                      mVariableModuleGlobal,\r
-                      &Variable\r
-                      );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  } else {\r
-    //\r
-    // Load database in global variable for cache.\r
-    //\r
-    Valid = IsValidVariableHeader (\r
-              Variable.CurrPtr,\r
-              Variable.Volatile,\r
-              &mVariableModuleGlobal->VariableGlobal[Physical],\r
-              mVariableModuleGlobal->FvbInstance,\r
-              &VariableHeader\r
-              );\r
-    ASSERT (Valid);\r
-\r
-    DataSize  = DataSizeOfVariable (&VariableHeader);\r
-    ASSERT (DataSize <= MAX_KEYDB_SIZE);\r
-    GetVariableDataPtr (\r
-      Variable.CurrPtr,\r
-      Variable.Volatile,\r
-      &mVariableModuleGlobal->VariableGlobal[Physical],\r
-      mVariableModuleGlobal->FvbInstance,\r
-      (CHAR16 *) mVariableModuleGlobal->PubKeyStore\r
-      );\r
-\r
-    mPubKeyNumber = (UINT32) (DataSize / EFI_CERT_TYPE_RSA2048_SIZE);\r
-  }\r
-  //\r
-  // Check "SetupMode" variable's existence.\r
-  // If it doesn't exist, check PK database's existence to determine the value.\r
-  // Then create a new one with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.\r
-  //\r
-  Status = FindVariable (\r
-             mVariableModuleGlobal->VariableName[Physical][VAR_SETUP_MODE],\r
-             &gEfiGlobalVariableGuid,\r
-             &Variable,\r
-             &mVariableModuleGlobal->VariableGlobal[Physical],\r
-             mVariableModuleGlobal->FvbInstance\r
-             );\r
-\r
-  if (Variable.CurrPtr == 0x0) {\r
-    Status = FindVariable (\r
-               mVariableModuleGlobal->VariableName[Physical][VAR_PLATFORM_KEY],\r
-               &gEfiGlobalVariableGuid,\r
-               &Variable,\r
-               &mVariableModuleGlobal->VariableGlobal[Physical],\r
-               mVariableModuleGlobal->FvbInstance\r
-               );\r
-    if (Variable.CurrPtr == 0x0) {\r
-      mPlatformMode = SETUP_MODE;\r
-    } else {\r
-      mPlatformMode = USER_MODE;\r
-    }\r
-\r
-    VarAttr = EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS;\r
-    Status  = UpdateVariable (\r
-                mVariableModuleGlobal->VariableName[Physical][VAR_SETUP_MODE],\r
-                &gEfiGlobalVariableGuid,\r
-                &mPlatformMode,\r
-                sizeof(UINT8),\r
-                VarAttr,\r
-                0,\r
-                0,\r
-                FALSE,\r
-                mVariableModuleGlobal,\r
-                &Variable\r
-                );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  } else {\r
-    GetVariableDataPtr (\r
-      Variable.CurrPtr,\r
-      Variable.Volatile,\r
-      &mVariableModuleGlobal->VariableGlobal[Physical],\r
-      mVariableModuleGlobal->FvbInstance,\r
-      (CHAR16 *) &mPlatformMode\r
-      );\r
-  }\r
-  //\r
-  // Check "SignatureSupport" variable's existence.\r
-  // If it doesn't exist, then create a new one with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.\r
-  //\r
-  Status = FindVariable (\r
-             EFI_SIGNATURE_SUPPORT_NAME,\r
-             &gEfiGlobalVariableGuid,\r
-             &Variable,\r
-             &mVariableModuleGlobal->VariableGlobal[Physical],\r
-             mVariableModuleGlobal->FvbInstance\r
-             );\r
-\r
-  if (Variable.CurrPtr == 0x0) {\r
-    VarAttr = EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS;\r
-    Status  = UpdateVariable (\r
-                EFI_SIGNATURE_SUPPORT_NAME,\r
-                &gEfiGlobalVariableGuid,\r
-                mSignatureSupport,\r
-                SIGSUPPORT_NUM * sizeof(EFI_GUID),\r
-                VarAttr,\r
-                0,\r
-                0,\r
-                FALSE,\r
-                mVariableModuleGlobal,\r
-                &Variable\r
-                );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Add public key in store and return its index.\r
-\r
-  @param[in]  VirtualMode             The current calling mode for this function.\r
-  @param[in]  Global                  The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  PubKey                  The input pointer to Public Key data.\r
-\r
-  @return                             The index of new added item.\r
-\r
-**/\r
-UINT32\r
-AddPubKeyInStore (\r
-  IN  BOOLEAN                   VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL      *Global,\r
-  IN  UINT8                     *PubKey\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  BOOLEAN                 IsFound;\r
-  UINT32                  Index;\r
-  VARIABLE_POINTER_TRACK  Variable;\r
-  UINT8                   *Ptr;\r
-\r
-  if (PubKey == NULL) {\r
-    return 0;\r
-  }\r
-\r
-  Status = FindVariable (\r
-             Global->VariableName[VirtualMode][VAR_AUTH_KEY_DB],\r
-             Global->AuthenticatedVariableGuid[VirtualMode],\r
-             &Variable,\r
-             &Global->VariableGlobal[VirtualMode],\r
-             Global->FvbInstance\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-  //\r
-  // Check whether the public key entry does exist.\r
-  //\r
-  IsFound = FALSE;\r
-  for (Ptr = Global->PubKeyStore, Index = 1; Index <= mPubKeyNumber; Index++) {\r
-    if (CompareMem (Ptr, PubKey, EFI_CERT_TYPE_RSA2048_SIZE) == 0) {\r
-      IsFound = TRUE;\r
-      break;\r
-    }\r
-    Ptr += EFI_CERT_TYPE_RSA2048_SIZE;\r
-  }\r
-\r
-  if (!IsFound) {\r
-    //\r
-    // Add public key in database.\r
-    //\r
-    if (mPubKeyNumber == MAX_KEY_NUM) {\r
-      //\r
-      // Notes: Database is full, need enhancement here, currently just return 0.\r
-      //\r
-      return 0;\r
-    }\r
-\r
-    CopyMem (Global->PubKeyStore + mPubKeyNumber * EFI_CERT_TYPE_RSA2048_SIZE, PubKey, EFI_CERT_TYPE_RSA2048_SIZE);\r
-    Index = ++mPubKeyNumber;\r
-    //\r
-    // Update public key database variable.\r
-    //\r
-    Status = UpdateVariable (\r
-               Global->VariableName[VirtualMode][VAR_AUTH_KEY_DB],\r
-               Global->AuthenticatedVariableGuid[VirtualMode],\r
-               Global->PubKeyStore,\r
-               mPubKeyNumber * EFI_CERT_TYPE_RSA2048_SIZE,\r
-               EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS,\r
-               0,\r
-               0,\r
-               VirtualMode,\r
-               Global,\r
-               &Variable\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  return Index;\r
-}\r
-\r
-/**\r
-  Verify data payload with AuthInfo in EFI_CERT_TYPE_RSA2048_SHA256 type.\r
-  Follow the steps in UEFI2.2.\r
-\r
-  @param[in]  VirtualMode             The current calling mode for this function.\r
-  @param[in]  Global                  The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  Data                    The pointer to data with AuthInfo.\r
-  @param[in]  DataSize                The size of Data.\r
-  @param[in]  PubKey                  The public key used for verification.\r
-\r
-  @retval EFI_INVALID_PARAMETER       Invalid parameter.\r
-  @retval EFI_SECURITY_VIOLATION      Authentication failed.\r
-  @retval EFI_SUCCESS                 Authentication successful.\r
-\r
-**/\r
-EFI_STATUS\r
-VerifyDataPayload (\r
-  IN  BOOLEAN                   VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL      *Global,\r
-  IN  UINT8                     *Data,\r
-  IN  UINTN                     DataSize,\r
-  IN  UINT8                     *PubKey\r
-  )\r
-{\r
-  BOOLEAN                         Status;\r
-  EFI_VARIABLE_AUTHENTICATION     *CertData;\r
-  EFI_CERT_BLOCK_RSA_2048_SHA256  *CertBlock;\r
-  UINT8                           Digest[SHA256_DIGEST_SIZE];\r
-  VOID                            *Rsa;\r
-  VOID                            *HashContext;\r
-\r
-  Rsa         = NULL;\r
-  CertData    = NULL;\r
-  CertBlock   = NULL;\r
-\r
-  if (Data == NULL || PubKey == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  CertData  = (EFI_VARIABLE_AUTHENTICATION *) Data;\r
-  CertBlock = (EFI_CERT_BLOCK_RSA_2048_SHA256 *) (CertData->AuthInfo.CertData);\r
-\r
-  //\r
-  // wCertificateType should be WIN_CERT_TYPE_EFI_GUID.\r
-  // Cert type should be EFI_CERT_TYPE_RSA2048_SHA256.\r
-  //\r
-  if ((CertData->AuthInfo.Hdr.wCertificateType != WIN_CERT_TYPE_EFI_GUID) ||\r
-      !CompareGuid (&CertData->AuthInfo.CertType, Global->CertRsa2048Sha256Guid[VirtualMode])\r
-        ) {\r
-    //\r
-    // Invalid AuthInfo type, return EFI_SECURITY_VIOLATION.\r
-    //\r
-    return EFI_SECURITY_VIOLATION;\r
-  }\r
-\r
-  //\r
-  // Hash data payload with SHA256.\r
-  //\r
-  ZeroMem (Digest, SHA256_DIGEST_SIZE);\r
-  HashContext = Global->HashContext[VirtualMode];\r
-  Status  = Sha256Init (HashContext);\r
-  if (!Status) {\r
-    goto Done;\r
-  }\r
-  Status  = Sha256Update (HashContext, Data + AUTHINFO_SIZE, (UINTN) (DataSize - AUTHINFO_SIZE));\r
-  if (!Status) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Hash Monotonic Count.\r
-  //\r
-  Status  = Sha256Update (HashContext, &CertData->MonotonicCount, sizeof (UINT64));\r
-  if (!Status) {\r
-    goto Done;\r
-  }\r
-  Status  = Sha256Final (HashContext, Digest);\r
-  if (!Status) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Generate & Initialize RSA Context.\r
-  //\r
-  Rsa = RsaNew ();\r
-  ASSERT (Rsa != NULL);\r
-  //\r
-  // Set RSA Key Components.\r
-  // NOTE: Only N and E are needed to be set as RSA public key for signature verification.\r
-  //\r
-  Status = RsaSetKey (Rsa, RsaKeyN, PubKey, EFI_CERT_TYPE_RSA2048_SIZE);\r
-  if (!Status) {\r
-    goto Done;\r
-  }\r
-  Status = RsaSetKey (Rsa, RsaKeyE, mRsaE, sizeof (mRsaE));\r
-  if (!Status) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Verify the signature.\r
-  //\r
-  Status = RsaPkcs1Verify (\r
-             Rsa,\r
-             Digest,\r
-             SHA256_DIGEST_SIZE,\r
-             CertBlock->Signature,\r
-             EFI_CERT_TYPE_RSA2048_SHA256_SIZE\r
-             );\r
-\r
-Done:\r
-  if (Rsa != NULL) {\r
-    RsaFree (Rsa);\r
-  }\r
-  if (Status) {\r
-    return EFI_SUCCESS;\r
-  } else {\r
-    return EFI_SECURITY_VIOLATION;\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Update platform mode.\r
-\r
-  @param[in]  VirtualMode             The current calling mode for this function.\r
-  @param[in]  Global                  The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  Mode                    SETUP_MODE or USER_MODE.\r
-\r
-**/\r
-VOID\r
-UpdatePlatformMode (\r
-  IN  BOOLEAN                   VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL      *Global,\r
-  IN  UINT32                    Mode\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  VARIABLE_POINTER_TRACK  Variable;\r
-  UINT32                  VarAttr;\r
-\r
-  Status = FindVariable (\r
-             Global->VariableName[VirtualMode][VAR_SETUP_MODE],\r
-             Global->GlobalVariableGuid[VirtualMode],\r
-             &Variable,\r
-             &Global->VariableGlobal[VirtualMode],\r
-             Global->FvbInstance\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  mPlatformMode  = Mode;\r
-  VarAttr        = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS;\r
-  Status         = UpdateVariable (\r
-                     Global->VariableName[VirtualMode][VAR_SETUP_MODE],\r
-                     Global->GlobalVariableGuid[VirtualMode],\r
-                     &mPlatformMode,\r
-                     sizeof(UINT8),\r
-                     VarAttr,\r
-                     0,\r
-                     0,\r
-                     VirtualMode,\r
-                     Global,\r
-                     &Variable\r
-                     );\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
-\r
-/**\r
-  Process variable with platform key for verification.\r
-\r
-  @param[in]  VariableName                The name of Variable to be found.\r
-  @param[in]  VendorGuid                  The variable vendor GUID.\r
-  @param[in]  Data                        The data pointer.\r
-  @param[in]  DataSize                    The size of Data found. If size is less than the\r
-                                          data, this value contains the required size.\r
-  @param[in]  VirtualMode                 The current calling mode for this function.\r
-  @param[in]  Global                      The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  Variable                    The variable information which is used to keep track of variable usage.\r
-  @param[in]  Attributes                  The attribute value of the variable.\r
-  @param[in]  IsPk                        Indicates whether to process pk.\r
-\r
-  @retval EFI_INVALID_PARAMETER           Invalid parameter.\r
-  @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation\r
-                                          check carried out by the firmware.\r
-  @retval EFI_SUCCESS                     The variable passed validation successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessVarWithPk (\r
-  IN  CHAR16                    *VariableName,\r
-  IN  EFI_GUID                  *VendorGuid,\r
-  IN  VOID                      *Data,\r
-  IN  UINTN                     DataSize,\r
-  IN  BOOLEAN                   VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL      *Global,\r
-  IN  VARIABLE_POINTER_TRACK    *Variable,\r
-  IN  UINT32                    Attributes OPTIONAL,\r
-  IN  BOOLEAN                   IsPk\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  VARIABLE_POINTER_TRACK        PkVariable;\r
-  EFI_SIGNATURE_LIST            *OldPkList;\r
-  EFI_SIGNATURE_DATA            *OldPkData;\r
-  EFI_VARIABLE_AUTHENTICATION   *CertData;\r
-  AUTHENTICATED_VARIABLE_HEADER VariableHeader;\r
-  BOOLEAN                       Valid;\r
-\r
-  OldPkList = NULL;\r
-  ZeroMem (&VariableHeader, sizeof (AUTHENTICATED_VARIABLE_HEADER));\r
-\r
-  if ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
-    //\r
-    // PK and KEK should set EFI_VARIABLE_NON_VOLATILE attribute.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (mPlatformMode == USER_MODE) {\r
-    if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) == 0) {\r
-      //\r
-      // In user mode, PK and KEK should set EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS attribute.\r
-      //\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    CertData = (EFI_VARIABLE_AUTHENTICATION *) Data;\r
-\r
-    if (Variable->CurrPtr != 0x0) {\r
-      Valid = IsValidVariableHeader (\r
-                Variable->CurrPtr,\r
-                Variable->Volatile,\r
-                &Global->VariableGlobal[VirtualMode],\r
-                Global->FvbInstance,\r
-                &VariableHeader\r
-                );\r
-      ASSERT (Valid);\r
-\r
-      if (CertData->MonotonicCount <= VariableHeader.MonotonicCount) {\r
-        //\r
-        // Monotonic count check fail, suspicious replay attack, return EFI_SECURITY_VIOLATION.\r
-        //\r
-        return EFI_SECURITY_VIOLATION;\r
-      }\r
-    }\r
-    //\r
-    // Get platform key from variable.\r
-    //\r
-    Status = FindVariable (\r
-               Global->VariableName[VirtualMode][VAR_PLATFORM_KEY],\r
-               Global->GlobalVariableGuid[VirtualMode],\r
-               &PkVariable,\r
-               &Global->VariableGlobal[VirtualMode],\r
-               Global->FvbInstance\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    ZeroMem (Global->KeyList, MAX_KEYDB_SIZE);\r
-    GetVariableDataPtr (\r
-      PkVariable.CurrPtr,\r
-      PkVariable.Volatile,\r
-      &Global->VariableGlobal[VirtualMode],\r
-      Global->FvbInstance,\r
-      (CHAR16 *) Global->KeyList\r
-      );\r
-\r
-    OldPkList = (EFI_SIGNATURE_LIST *) Global->KeyList;\r
-    OldPkData = (EFI_SIGNATURE_DATA *) ((UINT8 *) OldPkList + sizeof (EFI_SIGNATURE_LIST) + OldPkList->SignatureHeaderSize);\r
-    Status    = VerifyDataPayload (VirtualMode, Global, Data, DataSize, OldPkData->SignatureData);\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = UpdateVariable (\r
-                 VariableName,\r
-                 VendorGuid,\r
-                 (UINT8*)Data + AUTHINFO_SIZE,\r
-                 DataSize - AUTHINFO_SIZE,\r
-                 Attributes,\r
-                 0,\r
-                 CertData->MonotonicCount,\r
-                 VirtualMode,\r
-                 Global,\r
-                 Variable\r
-                 );\r
-\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // If delete PK in user mode, need change to setup mode.\r
-        //\r
-        if ((DataSize == AUTHINFO_SIZE) && IsPk) {\r
-          UpdatePlatformMode (VirtualMode, Global, SETUP_MODE);\r
-        }\r
-      }\r
-    }\r
-  } else {\r
-    Status = UpdateVariable (VariableName, VendorGuid, Data, DataSize, Attributes, 0, 0, VirtualMode, Global, Variable);\r
-    //\r
-    // If enroll PK in setup mode, need change to user mode.\r
-    //\r
-    if ((DataSize != 0) && IsPk) {\r
-      UpdatePlatformMode (VirtualMode, Global, USER_MODE);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Process variable with key exchange key for verification.\r
-\r
-  @param[in]  VariableName                The name of Variable to be found.\r
-  @param[in]  VendorGuid                  The variable vendor GUID.\r
-  @param[in]  Data                        The data pointer.\r
-  @param[in]  DataSize                    The size of Data found. If size is less than the\r
-                                          data, this value contains the required size.\r
-  @param[in]  VirtualMode                 The current calling mode for this function.\r
-  @param[in]  Global                      The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  Variable                    The variable information which is used to keep track of variable usage.\r
-  @param[in]  Attributes                  The attribute value of the variable.\r
-\r
-  @retval EFI_INVALID_PARAMETER           Invalid parameter.\r
-  @retval EFI_SECURITY_VIOLATION          The variable did NOT pass the validation\r
-                                          check carried out by the firmware.\r
-  @retval EFI_SUCCESS                     The variable passed validation successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessVarWithKek (\r
-  IN  CHAR16                               *VariableName,\r
-  IN  EFI_GUID                             *VendorGuid,\r
-  IN  VOID                                 *Data,\r
-  IN  UINTN                                DataSize,\r
-  IN  BOOLEAN                              VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL                 *Global,\r
-  IN  VARIABLE_POINTER_TRACK               *Variable,\r
-  IN  UINT32                               Attributes OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  VARIABLE_POINTER_TRACK          KekVariable;\r
-  EFI_SIGNATURE_LIST              *KekList;\r
-  EFI_SIGNATURE_DATA              *KekItem;\r
-  UINT32                          KekCount;\r
-  EFI_VARIABLE_AUTHENTICATION     *CertData;\r
-  EFI_CERT_BLOCK_RSA_2048_SHA256  *CertBlock;\r
-  BOOLEAN                         IsFound;\r
-  UINT32                          Index;\r
-  AUTHENTICATED_VARIABLE_HEADER   VariableHeader;\r
-  BOOLEAN                         Valid;\r
-\r
-  KekList = NULL;\r
-  ZeroMem (&VariableHeader, sizeof (AUTHENTICATED_VARIABLE_HEADER));\r
-\r
-  if (mPlatformMode == USER_MODE) {\r
-    if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) == 0) {\r
-      //\r
-      // In user mode, should set EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS attribute.\r
-      //\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    CertData  = (EFI_VARIABLE_AUTHENTICATION *) Data;\r
-    CertBlock = (EFI_CERT_BLOCK_RSA_2048_SHA256 *) (CertData->AuthInfo.CertData);\r
-    if (Variable->CurrPtr != 0x0) {\r
-      Valid = IsValidVariableHeader (\r
-                Variable->CurrPtr,\r
-                Variable->Volatile,\r
-                &Global->VariableGlobal[VirtualMode],\r
-                Global->FvbInstance,\r
-                &VariableHeader\r
-                );\r
-      ASSERT (Valid);\r
-\r
-      if (CertData->MonotonicCount <= VariableHeader.MonotonicCount) {\r
-        //\r
-        // Monotonic count check fail, suspicious replay attack, return EFI_SECURITY_VIOLATION.\r
-        //\r
-        return EFI_SECURITY_VIOLATION;\r
-      }\r
-    }\r
-    //\r
-    // Get KEK database from variable.\r
-    //\r
-    Status = FindVariable (\r
-               Global->VariableName[VirtualMode][VAR_KEY_EXCHANGE_KEY],\r
-               Global->GlobalVariableGuid[VirtualMode],\r
-               &KekVariable,\r
-               &Global->VariableGlobal[VirtualMode],\r
-               Global->FvbInstance\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-\r
-    ZeroMem (Global->KeyList, MAX_KEYDB_SIZE);\r
-    GetVariableDataPtr (\r
-      KekVariable.CurrPtr,\r
-      KekVariable.Volatile,\r
-      &Global->VariableGlobal[VirtualMode],\r
-      Global->FvbInstance,\r
-      (CHAR16 *) Global->KeyList\r
-      );\r
-    //\r
-    // Enumerate all Kek items in this list to verify the variable certificate data.\r
-    // If anyone is authenticated successfully, it means the variable is correct!\r
-    //\r
-    KekList   = (EFI_SIGNATURE_LIST *) Global->KeyList;\r
-    IsFound   = FALSE;\r
-    KekCount  = (KekList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - KekList->SignatureHeaderSize) / KekList->SignatureSize;\r
-    KekItem   = (EFI_SIGNATURE_DATA *) ((UINT8 *) KekList + sizeof (EFI_SIGNATURE_LIST) + KekList->SignatureHeaderSize);\r
-    for (Index = 0; Index < KekCount; Index++) {\r
-      if (CompareMem (KekItem->SignatureData, CertBlock->PublicKey, EFI_CERT_TYPE_RSA2048_SIZE) == 0) {\r
-        IsFound = TRUE;\r
-        break;\r
-      }\r
-      KekItem = (EFI_SIGNATURE_DATA *) ((UINT8 *) KekItem + KekList->SignatureSize);\r
-    }\r
-\r
-    if (!IsFound) {\r
-      return EFI_SECURITY_VIOLATION;\r
-    }\r
-\r
-    Status = VerifyDataPayload (VirtualMode, Global, Data, DataSize, CertBlock->PublicKey);\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = UpdateVariable (\r
-                 VariableName,\r
-                 VendorGuid,\r
-                 (UINT8*)Data + AUTHINFO_SIZE,\r
-                 DataSize - AUTHINFO_SIZE,\r
-                 Attributes,\r
-                 0,\r
-                 CertData->MonotonicCount,\r
-                 VirtualMode,\r
-                 Global,\r
-                 Variable\r
-                 );\r
-    }\r
-  } else {\r
-    //\r
-    // If in setup mode, no authentication needed.\r
-    //\r
-    Status = UpdateVariable (\r
-               VariableName,\r
-               VendorGuid,\r
-               Data,\r
-               DataSize,\r
-               Attributes,\r
-               0,\r
-               0,\r
-               VirtualMode,\r
-               Global,\r
-               Variable\r
-               );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Process variable with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set, and return the index of associated public key.\r
-\r
-  @param[in]  Data                        The data pointer.\r
-  @param[in]  DataSize                    The size of Data found. If size is less than the\r
-                                          data, this value contains the required size.\r
-  @param[in]  VirtualMode                 The current calling mode for this function.\r
-  @param[in]  Global                      The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  Variable                    The variable information which is used to keep track of variable usage.\r
-  @param[in]  Attributes                  The attribute value of the variable.\r
-  @param[out] KeyIndex                    The output index of corresponding public key in database.\r
-  @param[out] MonotonicCount              The output value of corresponding Monotonic Count.\r
-\r
-  @retval EFI_INVALID_PARAMETER           Invalid parameter.\r
-  @retval EFI_WRITE_PROTECTED             The variable is write-protected and needs authentication with\r
-                                          EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.\r
-  @retval EFI_SECURITY_VIOLATION          The variable is with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r
-                                          set, but the AuthInfo does NOT pass the validation\r
-                                          check carried out by the firmware.\r
-  @retval EFI_SUCCESS                     The variable is not write-protected, or passed validation successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-VerifyVariable (\r
-  IN  VOID                      *Data,\r
-  IN  UINTN                     DataSize,\r
-  IN  BOOLEAN                   VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL      *Global,\r
-  IN  VARIABLE_POINTER_TRACK    *Variable,\r
-  IN  UINT32                    Attributes OPTIONAL,\r
-  OUT UINT32                    *KeyIndex OPTIONAL,\r
-  OUT UINT64                    *MonotonicCount OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  BOOLEAN                         IsDeletion;\r
-  BOOLEAN                         IsFirstTime;\r
-  UINT8                           *PubKey;\r
-  EFI_VARIABLE_AUTHENTICATION     *CertData;\r
-  EFI_CERT_BLOCK_RSA_2048_SHA256  *CertBlock;\r
-  AUTHENTICATED_VARIABLE_HEADER   VariableHeader;\r
-  BOOLEAN                         Valid;\r
-\r
-  CertData    = NULL;\r
-  CertBlock   = NULL;\r
-  PubKey      = NULL;\r
-  IsDeletion  = FALSE;\r
-  Valid       = FALSE;\r
-\r
-  if (KeyIndex != NULL) {\r
-    *KeyIndex = 0;\r
-  }\r
-  //\r
-  // Determine if first time SetVariable with the EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS.\r
-  //\r
-  ZeroMem (&VariableHeader, sizeof (AUTHENTICATED_VARIABLE_HEADER));\r
-  if (Variable->CurrPtr != 0x0) {\r
-    Valid = IsValidVariableHeader (\r
-              Variable->CurrPtr,\r
-              Variable->Volatile,\r
-              &Global->VariableGlobal[VirtualMode],\r
-              Global->FvbInstance,\r
-              &VariableHeader\r
-              );\r
-    ASSERT (Valid);\r
-  }\r
-\r
-  if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
-    if (KeyIndex == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    //\r
-    // Determine current operation type.\r
-    //\r
-    if (DataSize == AUTHINFO_SIZE) {\r
-      IsDeletion = TRUE;\r
-    }\r
-    //\r
-    // Determine whether this is the first time with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.\r
-    //\r
-    if (Variable->CurrPtr == 0x0) {\r
-      IsFirstTime = TRUE;\r
-    } else if (Valid &&(VariableHeader.Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) == 0) {\r
-      IsFirstTime = TRUE;\r
-    } else {\r
-      *KeyIndex   = VariableHeader.PubKeyIndex;\r
-      IsFirstTime = FALSE;\r
-    }\r
-  } else if (Valid && (VariableHeader.Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
-      //\r
-      // If the variable is already write-protected, it always needs authentication before update.\r
-      //\r
-      return EFI_WRITE_PROTECTED;\r
-  } else {\r
-    //\r
-    // If without EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, set and attributes collision.\r
-    // That means it is not authenticated variable, just return EFI_SUCCESS.\r
-    //\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // Get PubKey and check Monotonic Count value corresponding to the variable.\r
-  //\r
-  CertData  = (EFI_VARIABLE_AUTHENTICATION *) Data;\r
-  CertBlock = (EFI_CERT_BLOCK_RSA_2048_SHA256 *) (CertData->AuthInfo.CertData);\r
-  PubKey    = CertBlock->PublicKey;\r
-\r
-  if (MonotonicCount != NULL) {\r
-    //\r
-    // Update Monotonic Count value.\r
-    //\r
-    *MonotonicCount = CertData->MonotonicCount;\r
-  }\r
-\r
-  if (!IsFirstTime) {\r
-    //\r
-    // Check input PubKey.\r
-    //\r
-    if (CompareMem (PubKey, Global->PubKeyStore + (*KeyIndex - 1) * EFI_CERT_TYPE_RSA2048_SIZE, EFI_CERT_TYPE_RSA2048_SIZE) != 0) {\r
-      return EFI_SECURITY_VIOLATION;\r
-    }\r
-    //\r
-    // Compare the current monotonic count and ensure that it is greater than the last SetVariable\r
-    // operation with the EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS attribute set.\r
-    //\r
-    if (CertData->MonotonicCount <= VariableHeader.MonotonicCount) {\r
-      //\r
-      // Monotonic count check fail, suspicious replay attack, return EFI_SECURITY_VIOLATION.\r
-      //\r
-      return EFI_SECURITY_VIOLATION;\r
-    }\r
-  }\r
-  //\r
-  // Verify the certificate in Data payload.\r
-  //\r
-  Status = VerifyDataPayload (VirtualMode, Global, Data, DataSize, PubKey);\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Now, the signature has been verified!\r
-    //\r
-    if (IsFirstTime && !IsDeletion) {\r
-      //\r
-      // Update public key database variable if need and return the index.\r
-      //\r
-      *KeyIndex = AddPubKeyInStore (VirtualMode, Global, PubKey);\r
-    }\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.h b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/AuthService.h
deleted file mode 100644 (file)
index 9df3020..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/** @file\r
-  The internal header file includes the common header files, defines\r
-  internal structure and functions used by AuthService module.\r
-\r
-Copyright (c) 2009 - 2018, 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
-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
-#ifndef _AUTHSERVICE_H_\r
-#define _AUTHSERVICE_H_\r
-\r
-#define EFI_CERT_TYPE_RSA2048_SHA256_SIZE 256\r
-#define EFI_CERT_TYPE_RSA2048_SIZE        256\r
-\r
-///\r
-/// Size of AuthInfo prior to the data payload\r
-///\r
-#define AUTHINFO_SIZE (((UINTN)(((EFI_VARIABLE_AUTHENTICATION *) 0)->AuthInfo.CertData)) + sizeof (EFI_CERT_BLOCK_RSA_2048_SHA256))\r
-\r
-///\r
-/// Item number of support signature types.\r
-///\r
-#define SIGSUPPORT_NUM 2\r
-\r
-/**\r
-  Process variable with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set, and return the index of associated public key.\r
-\r
-  @param[in]  Data                        The data pointer.\r
-  @param[in]  DataSize                    The size of Data found. If size is less than the\r
-                                          data, this value contains the required size.\r
-  @param[in]  VirtualMode                 The current calling mode for this function.\r
-  @param[in]  Global                      The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  Variable                    The variable information which is used to keep track of variable usage.\r
-  @param[in]  Attributes                  The attribute value of the variable.\r
-  @param[out] KeyIndex                    The output index of corresponding public key in database.\r
-  @param[out] MonotonicCount              The output value of corresponding Monotonic Count.\r
-\r
-  @retval EFI_INVALID_PARAMETER           Invalid parameter.\r
-  @retval EFI_WRITE_PROTECTED             The variable is write-protected and needs authentication with\r
-                                          EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.\r
-  @retval EFI_SECURITY_VIOLATION          The variable is with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r
-                                          set, but the AuthInfo does NOT pass the validation\r
-                                          check carried out by the firmware.\r
-  @retval EFI_SUCCESS                     The variable is not write-protected, or passed validation successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-VerifyVariable (\r
-  IN  VOID                      *Data,\r
-  IN  UINTN                     DataSize,\r
-  IN  BOOLEAN                   VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL      *Global,\r
-  IN  VARIABLE_POINTER_TRACK    *Variable,\r
-  IN  UINT32                    Attributes OPTIONAL,\r
-  OUT UINT32                    *KeyIndex OPTIONAL,\r
-  OUT UINT64                    *MonotonicCount OPTIONAL\r
-  );\r
-\r
-/**\r
-  Initializes for authenticated varibale service.\r
-\r
-  @retval EFI_SUCCESS           The function successfully executed.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to allocate enough memory resources.\r
-\r
-**/\r
-EFI_STATUS\r
-AutenticatedVariableServiceInitialize (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Initializes for cryptlib service before use, include register algrithm and allocate scratch.\r
-\r
-**/\r
-VOID\r
-CryptLibraryInitialize (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  Process variable with platform key for verification.\r
-\r
-  @param[in]  VariableName                The name of Variable to be found.\r
-  @param[in]  VendorGuid                  Variable vendor GUID.\r
-  @param[in]  Data                        The data pointer.\r
-  @param[in]  DataSize                    The size of Data found. If size is less than the\r
-                                          data, this value contains the required size.\r
-  @param[in]  VirtualMode                 The current calling mode for this function.\r
-  @param[in]  Global                      The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  Variable                    The variable information which is used to keep track of variable usage.\r
-  @param[in]  Attributes                  The attribute value of the variable.\r
-  @param[in]  IsPk                        Indicates whether to process pk.\r
-\r
-  @retval EFI_INVALID_PARAMETER           Invalid parameter.\r
-  @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation\r
-                                          check carried out by the firmware.\r
-  @retval EFI_SUCCESS                     The variable passed validation successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessVarWithPk (\r
-  IN  CHAR16                    *VariableName,\r
-  IN  EFI_GUID                  *VendorGuid,\r
-  IN  VOID                      *Data,\r
-  IN  UINTN                     DataSize,\r
-  IN  BOOLEAN                   VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL      *Global,\r
-  IN  VARIABLE_POINTER_TRACK    *Variable,\r
-  IN  UINT32                    Attributes OPTIONAL,\r
-  IN  BOOLEAN                   IsPk\r
-  );\r
-\r
-/**\r
-  Process variable with key exchange key for verification.\r
-\r
-  @param[in]  VariableName                The name of Variable to be found.\r
-  @param[in]  VendorGuid                  The variable vendor GUID.\r
-  @param[in]  Data                        The data pointer.\r
-  @param[in]  DataSize                    Size of Data found. If size is less than the\r
-                                          data, this value contains the required size.\r
-  @param[in]  VirtualMode                 The current calling mode for this function.\r
-  @param[in]  Global                      The context of this Extended SAL Variable Services Class call.\r
-  @param[in]  Variable                    The variable information which is used to keep track of variable usage.\r
-  @param[in]  Attributes                  The attribute value of the variable.\r
-\r
-  @retval EFI_INVALID_PARAMETER           Invalid parameter.\r
-  @retval EFI_SECURITY_VIOLATION          The variable does NOT pass the validation\r
-                                          check carried out by the firmware.\r
-  @retval EFI_SUCCESS                     The variable passed validation successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessVarWithKek (\r
-  IN  CHAR16                               *VariableName,\r
-  IN  EFI_GUID                             *VendorGuid,\r
-  IN  VOID                                 *Data,\r
-  IN  UINTN                                DataSize,\r
-  IN  BOOLEAN                              VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL                 *Global,\r
-  IN  VARIABLE_POINTER_TRACK               *Variable,\r
-  IN  UINT32                               Attributes OPTIONAL\r
-  );\r
-\r
-#endif\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf
deleted file mode 100644 (file)
index fcfda3d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-## @file\r
-#  Provides authenticated variable service for IPF platform\r
-#\r
-#  This module installs variable arch protocol and variable write arch protocol to provide\r
-#  four EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName and QueryVariableInfo.\r
-#\r
-# Copyright (c) 2009 - 2018, 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
-# http://opensource.org/licenses/bsd-license.php\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
-[Defines]\r
-  INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = EsalVariableDxeSal\r
-  MODULE_UNI_FILE                = EsalVariableDxeSal.uni\r
-  FILE_GUID                      = 14610837-4E97-4427-96E0-21D9B2956996\r
-  MODULE_TYPE                    = DXE_SAL_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-\r
-  ENTRY_POINT                    = VariableServiceInitialize\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IPF\r
-#\r
-#  VIRTUAL_ADDRESS_MAP_CALLBACK  =  VariableClassAddressChangeEvent\r
-#\r
-\r
-[Sources.common]\r
-  InitVariable.c\r
-  Reclaim.c\r
-  Variable.c\r
-  Variable.h\r
-  AuthService.c\r
-  AuthService.h\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-  CryptoPkg/CryptoPkg.dec\r
-  SecurityPkg/SecurityPkg.dec\r
-\r
-[LibraryClasses]\r
-  MemoryAllocationLib\r
-  BaseLib\r
-  SynchronizationLib\r
-  UefiLib\r
-  UefiBootServicesTableLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  UefiRuntimeLib\r
-  DxeServicesTableLib\r
-  UefiDriverEntryPoint\r
-  PcdLib\r
-  ExtendedSalLib\r
-  BaseCryptLib\r
-  HobLib\r
-\r
-[Protocols]\r
-  gEfiFirmwareVolumeBlockProtocolGuid           ## SOMETIMES_CONSUMES\r
-  gEfiFaultTolerantWriteProtocolGuid            ## SOMETIMES_CONSUMES\r
-\r
-[Guids]\r
-  ## SOMETIMES_CONSUMES   ## Variable:L"PK"\r
-  ## CONSUMES             ## Variable:L"SetupMode"\r
-  ## PRODUCES             ## Variable:L"SetupMode"\r
-  ## CONSUMES             ## Variable:L"SignatureSupport"\r
-  ## PRODUCES             ## Variable:L"SignatureSupport"\r
-  gEfiGlobalVariableGuid\r
-\r
-  ## PRODUCES             ## GUID # Variable store header\r
-  ## CONSUMES             ## GUID # Variable store header\r
-  ## SOMETIMES_CONSUMES   ## HOB\r
-  ## SOMETIMES_PRODUCES   ## SystemTable\r
-  gEfiAuthenticatedVariableGuid\r
-\r
-  gEfiEventVirtualAddressChangeGuid             ## CONSUMES               ## Event\r
-  gEfiCertRsa2048Sha256Guid                     ## CONSUMES               ## GUID        # Unique ID for the format of the CertType.\r
-\r
-  ## SOMETIMES_CONSUMES   ## Variable:L"DB"\r
-  ## SOMETIMES_CONSUMES   ## Variable:L"DBX"\r
-  gEfiImageSecurityDatabaseGuid\r
-\r
-[Pcd.common]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize            ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase            ## SOMETIMES_CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize                       ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize          ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize                     ## CONSUMES\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize                      ## CONSUMES\r
-\r
-[FeaturePcd.common]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics             ## CONSUMES    # statistic the information of variable.\r
-\r
-[Depex]\r
-  gEfiExtendedSalFvBlockServicesProtocolGuid AND gEfiFaultTolerantWriteProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
-  EsalVariableDxeSalExtra.uni\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.uni b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.uni
deleted file mode 100644 (file)
index 08588fc..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// /** @file\r
-// Provides authenticated variable service for IPF platform\r
-//\r
-// This module installs variable arch protocol and variable write arch protocol to provide\r
-// four EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName and QueryVariableInfo.\r
-//\r
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\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
-// http://opensource.org/licenses/bsd-license.php\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
-\r
-#string STR_MODULE_ABSTRACT             #language en-US "Provides authenticated variable service for IPF platform"\r
-\r
-#string STR_MODULE_DESCRIPTION          #language en-US "This module installs variable arch protocol and variable write arch protocol to provide four EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName and QueryVariableInfo."\r
-\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSalExtra.uni b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSalExtra.uni
deleted file mode 100644 (file)
index 6b3342c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// /** @file\r
-// EsalVariableDxeSal Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\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
-// http://opensource.org/licenses/bsd-license.php\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
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Esal Authenticated Variable DXE"\r
-\r
-\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c
deleted file mode 100644 (file)
index a9e739d..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/** @file\r
-  Entrypoint of Extended SAL variable service module.\r
-\r
-Copyright (c) 2009 - 2018, 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
-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 "Variable.h"\r
-#include "AuthService.h"\r
-\r
-//\r
-// Don't use module globals after the SetVirtualAddress map is signaled\r
-//\r
-EFI_EVENT mEfiVirtualNotifyEvent;\r
-\r
-/**\r
-  Common entry for Extended SAL Variable Services Class.\r
-\r
-  This is the common entry of all functions of Extended SAL Variable Services Class.\r
-\r
-  @param[in]  FunctionId        The Function ID of member function in Extended SAL Variable Services Class.\r
-  @param[in]  Arg2              The 2nd parameter for SAL procedure call.\r
-  @param[in]  Arg3              The 3rd parameter for SAL procedure call.\r
-  @param[in]  Arg4              The 4th parameter for SAL procedure call.\r
-  @param[in]  Arg5              The 5th parameter for SAL procedure call.\r
-  @param[in]  Arg6              The 6th parameter for SAL procedure call.\r
-  @param[in]  Arg7              The 7th parameter for SAL procedure call.\r
-  @param[in]  Arg8              The 8th parameter for SAL procedure call.\r
-  @param[in]  VirtualMode       The current calling mode for this function.\r
-  @param[in]  Global            The context of this Extended SAL Variable Services Class call.\r
-\r
-  @return                       The register of SAL.\r
-\r
-**/\r
-SAL_RETURN_REGS\r
-EFIAPI\r
-EsalVariableCommonEntry (\r
-  IN  UINT64                                      FunctionId,\r
-  IN  UINT64                                      Arg2,\r
-  IN  UINT64                                      Arg3,\r
-  IN  UINT64                                      Arg4,\r
-  IN  UINT64                                      Arg5,\r
-  IN  UINT64                                      Arg6,\r
-  IN  UINT64                                      Arg7,\r
-  IN  UINT64                                      Arg8,\r
-  IN  BOOLEAN                                     VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL                        *Global\r
-  )\r
-{\r
-  SAL_RETURN_REGS ReturnVal;\r
-\r
-  ReturnVal.r9  = 0;\r
-  ReturnVal.r10 = 0;\r
-  ReturnVal.r11 = 0;\r
-\r
-  switch (FunctionId) {\r
-  case EsalGetVariableFunctionId:\r
-    ReturnVal.Status = EsalGetVariable (\r
-                         (CHAR16 *) Arg2,\r
-                         (EFI_GUID *) Arg3,\r
-                         (UINT32 *) Arg4,\r
-                         (UINTN *) Arg5,\r
-                         (VOID *) Arg6,\r
-                         VirtualMode,\r
-                         Global\r
-                         );\r
-    return ReturnVal;\r
-\r
-  case EsalGetNextVariableNameFunctionId:\r
-    ReturnVal.Status = EsalGetNextVariableName (\r
-                         (UINTN *) Arg2,\r
-                         (CHAR16 *) Arg3,\r
-                         (EFI_GUID *) Arg4,\r
-                         VirtualMode,\r
-                         Global\r
-                         );\r
-    return ReturnVal;\r
-\r
-  case EsalSetVariableFunctionId:\r
-    ReturnVal.Status = EsalSetVariable (\r
-                         (CHAR16 *) Arg2,\r
-                         (EFI_GUID *) Arg3,\r
-                         (UINT32) Arg4,\r
-                         (UINTN) Arg5,\r
-                         (VOID *) Arg6,\r
-                         VirtualMode,\r
-                         Global\r
-                         );\r
-    return ReturnVal;\r
-\r
-  case EsalQueryVariableInfoFunctionId:\r
-    ReturnVal.Status = EsalQueryVariableInfo (\r
-                         (UINT32) Arg2,\r
-                         (UINT64 *) Arg3,\r
-                         (UINT64 *) Arg4,\r
-                         (UINT64 *) Arg5,\r
-                         VirtualMode,\r
-                         Global\r
-                         );\r
-    return ReturnVal;\r
-\r
-  default:\r
-    ReturnVal.Status = EFI_SAL_INVALID_ARGUMENT;\r
-    return ReturnVal;\r
-  }\r
-}\r
-\r
-/**\r
-  Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
-\r
-  This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
-  It convers pointer to new virtual address.\r
-\r
-  @param[in]  Event        The event whose notification function is being invoked.\r
-  @param[in]  Context      The pointer to the notification function's context.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VariableClassAddressChangeEvent (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  )\r
-{\r
-  UINTN Index;\r
-\r
-  CopyMem (\r
-    &mVariableModuleGlobal->VariableGlobal[Virtual],\r
-    &mVariableModuleGlobal->VariableGlobal[Physical],\r
-    sizeof (VARIABLE_GLOBAL)\r
-    );\r
-\r
-  EfiConvertPointer (\r
-    0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableGlobal[Virtual].NonVolatileVariableBase\r
-    );\r
-  EfiConvertPointer (\r
-    0x0,\r
-    (VOID **) &mVariableModuleGlobal->VariableGlobal[Virtual].VolatileVariableBase\r
-    );\r
-\r
-  mVariableModuleGlobal->PlatformLangCodes[Virtual] = mVariableModuleGlobal->PlatformLangCodes[Physical];\r
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->PlatformLangCodes[Virtual]);\r
-\r
-  mVariableModuleGlobal->LangCodes[Virtual] = mVariableModuleGlobal->LangCodes[Physical];\r
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->LangCodes[Virtual]);\r
-\r
-  mVariableModuleGlobal->PlatformLang[Virtual] = mVariableModuleGlobal->PlatformLang[Physical];\r
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->PlatformLang[Virtual]);\r
-\r
-  CopyMem (\r
-    mVariableModuleGlobal->VariableName[Virtual],\r
-    mVariableModuleGlobal->VariableName[Physical],\r
-    sizeof (mVariableModuleGlobal->VariableName[Physical])\r
-    );\r
-  for (Index = 0; Index < NUM_VAR_NAME; Index++) {\r
-    EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->VariableName[Virtual][Index]);\r
-  }\r
-\r
-  mVariableModuleGlobal->GlobalVariableGuid[Virtual] = &gEfiGlobalVariableGuid;\r
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->GlobalVariableGuid[Virtual]);\r
-\r
-  mVariableModuleGlobal->AuthenticatedVariableGuid[Virtual] = &gEfiAuthenticatedVariableGuid;\r
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->AuthenticatedVariableGuid[Virtual]);\r
-\r
-  mVariableModuleGlobal->CertRsa2048Sha256Guid[Virtual] = &gEfiCertRsa2048Sha256Guid;\r
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->CertRsa2048Sha256Guid[Virtual]);\r
-\r
-  mVariableModuleGlobal->ImageSecurityDatabaseGuid[Virtual] = &gEfiImageSecurityDatabaseGuid;\r
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->ImageSecurityDatabaseGuid[Virtual]);\r
-\r
-  mVariableModuleGlobal->HashContext[Virtual] = mVariableModuleGlobal->HashContext[Physical];\r
-  EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal->HashContext[Virtual]);\r
-}\r
-\r
-/**\r
-  Entry point of Extended SAL Variable service module.\r
-\r
-  This function is the entry point of Extended SAL Variable service module.\r
-  It registers all functions of Extended SAL Variable class, initializes\r
-  variable store for non-volatile and volatile variables, and registers\r
-  notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
-\r
-  @param[in]  ImageHandle   The Image handle of this driver.\r
-  @param[in]  SystemTable   The pointer of EFI_SYSTEM_TABLE.\r
-\r
-  @retval     EFI_SUCCESS   Extended SAL Variable Services Class successfully registered.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VariableServiceInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = gBS->CreateEventEx (\r
-                  EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
-                  VariableClassAddressChangeEvent,\r
-                  NULL,\r
-                  &gEfiEventVirtualAddressChangeGuid,\r
-                  &mEfiVirtualNotifyEvent\r
-                  );\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = VariableCommonInitialize (ImageHandle, SystemTable);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Authenticated variable initialize\r
-  //\r
-  Status = AutenticatedVariableServiceInitialize ();\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  FlushHob2Nv ();\r
-\r
-  //\r
-  // Register All the Functions with Extended SAL Variable Services Class\r
-  //\r
-  RegisterEsalClass (\r
-    EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID_LO,\r
-    EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID_HI,\r
-    mVariableModuleGlobal,\r
-    EsalVariableCommonEntry,\r
-    EsalGetVariableFunctionId,\r
-    EsalVariableCommonEntry,\r
-    EsalGetNextVariableNameFunctionId,\r
-    EsalVariableCommonEntry,\r
-    EsalSetVariableFunctionId,\r
-    EsalVariableCommonEntry,\r
-    EsalQueryVariableInfoFunctionId,\r
-    NULL\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Reclaim.c b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Reclaim.c
deleted file mode 100644 (file)
index 898974c..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/** @file\r
-  Handles non-volatile variable store garbage collection, using FTW\r
-  (Fault Tolerant Write) protocol.\r
-\r
-Copyright (c) 2006 - 2018, 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
-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 "Variable.h"\r
-\r
-/**\r
-  Gets firmware volume block handle by given address.\r
-\r
-  This function gets firmware volume block handle whose\r
-  address range contains the parameter Address.\r
-\r
-  @param[in]  Address    Address which should be contained\r
-                         by returned FVB handle.\r
-  @param[out] FvbHandle  Pointer to FVB handle for output.\r
-\r
-  @retval EFI_SUCCESS    FVB handle successfully returned.\r
-  @retval EFI_NOT_FOUND  Failed to find FVB handle by address.\r
-\r
-**/\r
-EFI_STATUS\r
-GetFvbHandleByAddress (\r
-  IN  EFI_PHYSICAL_ADDRESS   Address,\r
-  OUT EFI_HANDLE             *FvbHandle\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_HANDLE                          *HandleBuffer;\r
-  UINTN                               HandleCount;\r
-  UINTN                               Index;\r
-  EFI_PHYSICAL_ADDRESS                FvbBaseAddress;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
-  EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
-\r
-  *FvbHandle = NULL;\r
-  //\r
-  // Locate all handles with Firmware Volume Block protocol\r
-  //\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Traverse all the handles, searching for the one containing parameter Address\r
-  //\r
-  for (Index = 0; Index < HandleCount; Index += 1) {\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                    (VOID **) &Fvb\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      Status = EFI_NOT_FOUND;\r
-      break;\r
-    }\r
-    //\r
-    // Checks if the address range of this handle contains parameter Address\r
-    //\r
-    Status = Fvb->GetPhysicalAddress (Fvb, &FvbBaseAddress);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvbBaseAddress);\r
-    if ((Address >= FvbBaseAddress) && (Address <= (FvbBaseAddress + FwVolHeader->FvLength))) {\r
-      *FvbHandle  = HandleBuffer[Index];\r
-      Status      = EFI_SUCCESS;\r
-      break;\r
-    }\r
-  }\r
-\r
-  FreePool (HandleBuffer);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Gets LBA of block and offset by given address.\r
-\r
-  This function gets the Logical Block Address (LBA) of firmware\r
-  volume block containing the given address, and the offset of\r
-  address on the block.\r
-\r
-  @param[in]  Address    Address which should be contained\r
-                         by returned FVB handle.\r
-  @param[out] Lba        The pointer to LBA for output.\r
-  @param[out] Offset     The pointer to offset for output.\r
-\r
-  @retval EFI_SUCCESS    LBA and offset successfully returned.\r
-  @retval EFI_NOT_FOUND  Failed to find FVB handle by address.\r
-  @retval EFI_ABORTED    Failed to find valid LBA and offset.\r
-\r
-**/\r
-EFI_STATUS\r
-GetLbaAndOffsetByAddress (\r
-  IN  EFI_PHYSICAL_ADDRESS   Address,\r
-  OUT EFI_LBA                *Lba,\r
-  OUT UINTN                  *Offset\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_HANDLE                          FvbHandle;\r
-  EFI_PHYSICAL_ADDRESS                FvbBaseAddress;\r
-  EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL  *Fvb;\r
-  EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
-  EFI_FV_BLOCK_MAP_ENTRY              *FvbMapEntry;\r
-  UINT32                              LbaIndex;\r
-\r
-  *Lba    = (EFI_LBA) (-1);\r
-  *Offset = 0;\r
-\r
-  //\r
-  // Gets firmware volume block handle by given address.\r
-  //\r
-  Status = GetFvbHandleByAddress (Address, &FvbHandle);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  FvbHandle,\r
-                  &gEfiFirmwareVolumeBlockProtocolGuid,\r
-                  (VOID **) &Fvb\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Get the Base Address of FV\r
-  //\r
-  Status = Fvb->GetPhysicalAddress (Fvb, &FvbBaseAddress);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvbBaseAddress);\r
-\r
-  //\r
-  // Get the (LBA, Offset) of Address\r
-  //\r
-  if ((Address >= FvbBaseAddress) && (Address <= (FvbBaseAddress + FwVolHeader->FvLength))) {\r
-    if ((FwVolHeader->FvLength) > (FwVolHeader->HeaderLength)) {\r
-      //\r
-      // BUGBUG: Assume one FV has one type of BlockLength\r
-      //\r
-      FvbMapEntry = &FwVolHeader->BlockMap[0];\r
-      for (LbaIndex = 1; LbaIndex <= FvbMapEntry->NumBlocks; LbaIndex += 1) {\r
-        if (Address < (FvbBaseAddress + FvbMapEntry->Length * LbaIndex)) {\r
-          //\r
-          // Found the (Lba, Offset)\r
-          //\r
-          *Lba    = LbaIndex - 1;\r
-          *Offset = (UINTN) (Address - (FvbBaseAddress + FvbMapEntry->Length * (LbaIndex - 1)));\r
-          return EFI_SUCCESS;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_ABORTED;\r
-}\r
-\r
-/**\r
-  Writes a buffer to variable storage space.\r
-\r
-  This function writes a buffer to variable storage space into firmware\r
-  volume block device. The destination is specified by parameter\r
-  VariableBase. Fault Tolerant Write protocol is used for writing.\r
-\r
-  @param[in] VariableBase The base address of the variable to write.\r
-  @param[in] Buffer       Points to the data buffer.\r
-  @param[in] BufferSize   The number of bytes of the data Buffer.\r
-\r
-  @retval EFI_SUCCESS     The function completed successfully.\r
-  @retval EFI_NOT_FOUND   Fail to locate Fault Tolerant Write protocol.\r
-  @retval Other           The function could not complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-FtwVariableSpace (\r
-  IN EFI_PHYSICAL_ADDRESS   VariableBase,\r
-  IN UINT8                  *Buffer,\r
-  IN UINTN                  BufferSize\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_HANDLE            FvbHandle;\r
-  EFI_LBA               VarLba;\r
-  UINTN                 VarOffset;\r
-  UINT8                 *FtwBuffer;\r
-  UINTN                 FtwBufferSize;\r
-  EFI_FAULT_TOLERANT_WRITE_PROTOCOL  *FtwProtocol;\r
-\r
-  //\r
-  // Locate Fault Tolerant Write protocol\r
-  //\r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiFaultTolerantWriteProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &FtwProtocol\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  //\r
-  // Gets firmware volume block handle by VariableBase.\r
-  //\r
-  Status = GetFvbHandleByAddress (VariableBase, &FvbHandle);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Gets LBA of block and offset by VariableBase.\r
-  //\r
-  Status = GetLbaAndOffsetByAddress (VariableBase, &VarLba, &VarOffset);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_ABORTED;\r
-  }\r
-  //\r
-  // Prepare for the variable data\r
-  //\r
-  FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size;\r
-  FtwBuffer     = AllocatePool (FtwBufferSize);\r
-  if (FtwBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  SetMem (FtwBuffer, FtwBufferSize, (UINT8) 0xff);\r
-  CopyMem (FtwBuffer, Buffer, BufferSize);\r
-\r
-  //\r
-  // FTW write record\r
-  //\r
-  Status = FtwProtocol->Write (\r
-                          FtwProtocol,\r
-                          VarLba,         // LBA\r
-                          VarOffset,      // Offset\r
-                          FtwBufferSize,  // NumBytes,\r
-                          NULL,\r
-                          FvbHandle,\r
-                          FtwBuffer\r
-                          );\r
-\r
-  FreePool (FtwBuffer);\r
-  return Status;\r
-}\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
deleted file mode 100644 (file)
index b8a0af4..0000000
+++ /dev/null
@@ -1,3257 +0,0 @@
-/** @file\r
-  The implementation of Extended SAL variable services.\r
-\r
-Copyright (c) 2009 - 2018, 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
-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 "Variable.h"\r
-#include "AuthService.h"\r
-\r
-//\r
-// Don't use module globals after the SetVirtualAddress map is signaled\r
-//\r
-ESAL_VARIABLE_GLOBAL  *mVariableModuleGlobal;\r
-CHAR16 *mVariableName[NUM_VAR_NAME] = {\r
-  L"PlatformLangCodes",\r
-  L"LangCodes",\r
-  L"PlatformLang",\r
-  L"Lang",\r
-  L"HwErrRec",\r
-  AUTHVAR_KEYDB_NAME,\r
-  EFI_SETUP_MODE_NAME,\r
-  EFI_PLATFORM_KEY_NAME,\r
-  EFI_KEY_EXCHANGE_KEY_NAME\r
-};\r
-\r
-GLOBAL_REMOVE_IF_UNREFERENCED VARIABLE_INFO_ENTRY *gVariableInfo = NULL;\r
-\r
-//\r
-// The current Hii implementation accesses this variable a larg # of times on every boot.\r
-// Other common variables are only accessed a single time. This is why this cache algorithm\r
-// only targets a single variable. Probably to get an performance improvement out of\r
-// a Cache you would need a cache that improves the search performance for a variable.\r
-//\r
-VARIABLE_CACHE_ENTRY mVariableCache[] = {\r
-  {\r
-    &gEfiGlobalVariableGuid,\r
-    L"Lang",\r
-    0x00000000,\r
-    0x00,\r
-    NULL\r
-  },\r
-  {\r
-    &gEfiGlobalVariableGuid,\r
-    L"PlatformLang",\r
-    0x00000000,\r
-    0x00,\r
-    NULL\r
-  }\r
-};\r
-\r
-/**\r
-  Acquires lock only at boot time. Simply returns at runtime.\r
-\r
-  This is a temperary function which will be removed when\r
-  EfiAcquireLock() in UefiLib can handle the call in UEFI\r
-  Runtimer driver in RT phase.\r
-  It calls EfiAcquireLock() at boot time, and simply returns\r
-  at runtime.\r
-\r
-  @param[in]  Lock     A pointer to the lock to acquire.\r
-\r
-**/\r
-VOID\r
-AcquireLockOnlyAtBootTime (\r
-  IN EFI_LOCK  *Lock\r
-  )\r
-{\r
-  if (!EfiAtRuntime ()) {\r
-    EfiAcquireLock (Lock);\r
-  }\r
-}\r
-\r
-/**\r
-  Releases lock only at boot time. Simply returns at runtime.\r
-\r
-  This is a temperary function which will be removed when\r
-  EfiReleaseLock() in UefiLib can handle the call in UEFI\r
-  Runtimer driver in RT phase.\r
-  It calls EfiReleaseLock() at boot time, and simply returns\r
-  at runtime\r
-\r
-  @param[in]  Lock    A pointer to the lock to release.\r
-\r
-**/\r
-VOID\r
-ReleaseLockOnlyAtBootTime (\r
-  IN EFI_LOCK  *Lock\r
-  )\r
-{\r
-  if (!EfiAtRuntime ()) {\r
-    EfiReleaseLock (Lock);\r
-  }\r
-}\r
-\r
-/**\r
-  Reads/Writes variable storage, volatile or non-volatile.\r
-\r
-  This function reads or writes volatile or non-volatile variable stroage.\r
-  For volatile storage, it performs memory copy.\r
-  For non-volatile storage, it accesses data on firmware storage. Data\r
-  area to access can span multiple firmware blocks.\r
-\r
-  @param[in]      Write           TRUE  - Write variable store.\r
-                                  FALSE - Read variable store.\r
-  @param[in]      Global          Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]      Volatile        TRUE  - Variable is volatile.\r
-                                  FALSE - Variable is non-volatile.\r
-  @param[in]      Instance        Instance of FV Block services.\r
-  @param[in]      StartAddress    Start address of data to access.\r
-  @param[in]      DataSize        Size of data to access.\r
-  @param[in, out] Buffer          For write, pointer to the buffer from which data is written.\r
-                                  For read, pointer to the buffer to hold the data read.\r
-\r
-  @retval EFI_SUCCESS            Variable store successfully accessed.\r
-  @retval EFI_INVALID_PARAMETER  Data area to access exceeds valid variable storage.\r
-\r
-**/\r
-EFI_STATUS\r
-AccessVariableStore (\r
-  IN     BOOLEAN                 Write,\r
-  IN     VARIABLE_GLOBAL         *Global,\r
-  IN     BOOLEAN                 Volatile,\r
-  IN     UINTN                   Instance,\r
-  IN     EFI_PHYSICAL_ADDRESS    StartAddress,\r
-  IN     UINT32                  DataSize,\r
-  IN OUT VOID                    *Buffer\r
-  )\r
-{\r
-  EFI_FV_BLOCK_MAP_ENTRY      *PtrBlockMapEntry;\r
-  UINTN                       BlockIndex;\r
-  UINTN                       LinearOffset;\r
-  UINTN                       CurrWriteSize;\r
-  UINTN                       CurrWritePtr;\r
-  UINT8                       *CurrBuffer;\r
-  EFI_LBA                     LbaNumber;\r
-  UINTN                       Size;\r
-  EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader;\r
-  VARIABLE_STORE_HEADER       *VolatileBase;\r
-  EFI_PHYSICAL_ADDRESS        FvVolHdr;\r
-  EFI_STATUS                  Status;\r
-  VARIABLE_STORE_HEADER       *VariableStoreHeader;\r
-\r
-  FvVolHdr = 0;\r
-  FwVolHeader = NULL;\r
-\r
-  if (Volatile) {\r
-    //\r
-    // If data is volatile, simply calculate the data pointer and copy memory.\r
-    // Data pointer should point to the actual address where data is to be\r
-    // accessed.\r
-    //\r
-    VolatileBase = (VARIABLE_STORE_HEADER *) ((UINTN) Global->VolatileVariableBase);\r
-\r
-    if ((StartAddress + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + VolatileBase->Size))) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-\r
-    //\r
-    // For volatile variable, a simple memory copy is enough.\r
-    //\r
-    if (Write) {\r
-      CopyMem ((VOID *) StartAddress, Buffer, DataSize);\r
-    } else {\r
-      CopyMem (Buffer, (VOID *) StartAddress, DataSize);\r
-    }\r
-\r
-    return EFI_SUCCESS;\r
-  }\r
-\r
-  //\r
-  // If data is non-volatile, calculate firmware volume header and data pointer.\r
-  //\r
-  Status = (EFI_STATUS) EsalCall (\r
-                          EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
-                          EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                          GetPhysicalAddressFunctionId,\r
-                          Instance,\r
-                          (UINT64) &FvVolHdr,\r
-                          0,\r
-                          0,\r
-                          0,\r
-                          0,\r
-                          0\r
-                          ).Status;\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvVolHdr);\r
-  ASSERT (FwVolHeader != NULL);\r
-  VariableStoreHeader = (VARIABLE_STORE_HEADER *)(FwVolHeader + 1);\r
-\r
-  if ((StartAddress + DataSize) > ((EFI_PHYSICAL_ADDRESS) (UINTN) ((CHAR8 *)VariableStoreHeader + VariableStoreHeader->Size))) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  LinearOffset  = (UINTN) FwVolHeader;\r
-  CurrWritePtr  = StartAddress;\r
-  CurrWriteSize = DataSize;\r
-  CurrBuffer    = Buffer;\r
-  LbaNumber     = 0;\r
-\r
-  if (CurrWritePtr < LinearOffset) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Traverse data blocks of this firmware storage to find the one where CurrWritePtr locates\r
-  //\r
-  for (PtrBlockMapEntry = FwVolHeader->BlockMap; PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) {\r
-    for (BlockIndex = 0; BlockIndex < PtrBlockMapEntry->NumBlocks; BlockIndex++) {\r
-      if ((CurrWritePtr >= LinearOffset) && (CurrWritePtr < LinearOffset + PtrBlockMapEntry->Length)) {\r
-        //\r
-        // Check to see if the data area to access spans multiple blocks.\r
-        //\r
-        if ((CurrWritePtr + CurrWriteSize) <= (LinearOffset + PtrBlockMapEntry->Length)) {\r
-          //\r
-          // If data area to access is contained in one block, just access and return.\r
-          //\r
-          if (Write) {\r
-            Status = (EFI_STATUS) EsalCall (\r
-                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
-                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                                    WriteFunctionId,\r
-                                    Instance,\r
-                                    LbaNumber,\r
-                                    (CurrWritePtr - LinearOffset),\r
-                                    (UINT64) &CurrWriteSize,\r
-                                    (UINT64) CurrBuffer,\r
-                                    0,\r
-                                    0\r
-                                    ).Status;\r
-          } else {\r
-            Status = (EFI_STATUS) EsalCall (\r
-                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
-                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                                    ReadFunctionId,\r
-                                    Instance,\r
-                                    LbaNumber,\r
-                                    (CurrWritePtr - LinearOffset),\r
-                                    (UINT64) &CurrWriteSize,\r
-                                    (UINT64) CurrBuffer,\r
-                                    0,\r
-                                    0\r
-                                    ).Status;\r
-          }\r
-          return Status;\r
-        } else {\r
-          //\r
-          // If data area to access spans multiple blocks, access this one and adjust for the next one.\r
-          //\r
-          Size = (UINT32) (LinearOffset + PtrBlockMapEntry->Length - CurrWritePtr);\r
-          if (Write) {\r
-            Status = (EFI_STATUS) EsalCall (\r
-                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
-                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                                    WriteFunctionId,\r
-                                    Instance,\r
-                                    LbaNumber,\r
-                                    (CurrWritePtr - LinearOffset),\r
-                                    (UINT64) &Size,\r
-                                    (UINT64) CurrBuffer,\r
-                                    0,\r
-                                    0\r
-                                    ).Status;\r
-          } else {\r
-            Status = (EFI_STATUS) EsalCall (\r
-                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
-                                    EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                                    ReadFunctionId,\r
-                                    Instance,\r
-                                    LbaNumber,\r
-                                    (CurrWritePtr - LinearOffset),\r
-                                    (UINT64) &Size,\r
-                                    (UINT64) CurrBuffer,\r
-                                    0,\r
-                                    0\r
-                                    ).Status;\r
-          }\r
-          if (EFI_ERROR (Status)) {\r
-            return Status;\r
-          }\r
-          //\r
-          // Adjust for the remaining data.\r
-          //\r
-          CurrWritePtr  = LinearOffset + PtrBlockMapEntry->Length;\r
-          CurrBuffer    = CurrBuffer + Size;\r
-          CurrWriteSize = CurrWriteSize - Size;\r
-        }\r
-      }\r
-\r
-      LinearOffset += PtrBlockMapEntry->Length;\r
-      LbaNumber++;\r
-    }\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Retrieves header of volatile or non-volatile variable stroage.\r
-\r
-  @param[in]  VarStoreAddress    Start address of variable storage.\r
-  @param[in]  Volatile           TRUE  - Variable storage is volatile.\r
-                                 FALSE - Variable storage is non-volatile.\r
-  @param[in]  Global             Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]  Instance           Instance of FV Block services.\r
-  @param[out] VarStoreHeader     Pointer to VARIABLE_STORE_HEADER for output.\r
-\r
-**/\r
-VOID\r
-GetVarStoreHeader (\r
-  IN  EFI_PHYSICAL_ADDRESS   VarStoreAddress,\r
-  IN  BOOLEAN                Volatile,\r
-  IN  VARIABLE_GLOBAL        *Global,\r
-  IN  UINTN                  Instance,\r
-  OUT VARIABLE_STORE_HEADER  *VarStoreHeader\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-\r
-  Status = AccessVariableStore (\r
-             FALSE,\r
-             Global,\r
-             Volatile,\r
-             Instance,\r
-             VarStoreAddress,\r
-             sizeof (VARIABLE_STORE_HEADER),\r
-             VarStoreHeader\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
-\r
-/**\r
-  Checks variable header.\r
-\r
-  This function checks if variable header is valid or not.\r
-\r
-  @param[in]  VariableAddress    Start address of variable header.\r
-  @param[in]  Volatile           TRUE  - Variable is volatile.\r
-                                 FALSE - Variable is non-volatile.\r
-  @param[in]  Global             Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]  Instance           Instance of FV Block services.\r
-  @param[out] VariableHeader     Pointer to AUTHENTICATED_VARIABLE_HEADER for output.\r
-\r
-  @retval TRUE                   Variable header is valid.\r
-  @retval FALSE                  Variable header is not valid.\r
-\r
-**/\r
-BOOLEAN\r
-IsValidVariableHeader (\r
-  IN  EFI_PHYSICAL_ADDRESS              VariableAddress,\r
-  IN  BOOLEAN                           Volatile,\r
-  IN  VARIABLE_GLOBAL                   *Global,\r
-  IN  UINTN                             Instance,\r
-  OUT AUTHENTICATED_VARIABLE_HEADER     *VariableHeader  OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS                            Status;\r
-  AUTHENTICATED_VARIABLE_HEADER         LocalVariableHeader;\r
-\r
-  Status = AccessVariableStore (\r
-             FALSE,\r
-             Global,\r
-             Volatile,\r
-             Instance,\r
-             VariableAddress,\r
-             sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
-             &LocalVariableHeader\r
-             );\r
-\r
-  if (EFI_ERROR (Status) || LocalVariableHeader.StartId != VARIABLE_DATA) {\r
-    return FALSE;\r
-  }\r
-\r
-  if (VariableHeader != NULL) {\r
-    CopyMem (VariableHeader, &LocalVariableHeader, sizeof (AUTHENTICATED_VARIABLE_HEADER));\r
-  }\r
-\r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Gets status of variable store.\r
-\r
-  This function gets the current status of variable store.\r
-\r
-  @param[in] VarStoreHeader  Pointer to header of variable store.\r
-\r
-  @retval EfiRaw          Variable store status is raw.\r
-  @retval EfiValid        Variable store status is valid.\r
-  @retval EfiInvalid      Variable store status is invalid.\r
-\r
-**/\r
-VARIABLE_STORE_STATUS\r
-GetVariableStoreStatus (\r
-  IN VARIABLE_STORE_HEADER *VarStoreHeader\r
-  )\r
-{\r
-\r
-  if (CompareGuid (&VarStoreHeader->Signature, &gEfiAuthenticatedVariableGuid) &&\r
-      VarStoreHeader->Format == VARIABLE_STORE_FORMATTED &&\r
-      VarStoreHeader->State == VARIABLE_STORE_HEALTHY\r
-      ) {\r
-\r
-    return EfiValid;\r
-  } else if (((UINT32 *)(&VarStoreHeader->Signature))[0] == 0xffffffff &&\r
-             ((UINT32 *)(&VarStoreHeader->Signature))[1] == 0xffffffff &&\r
-             ((UINT32 *)(&VarStoreHeader->Signature))[2] == 0xffffffff &&\r
-             ((UINT32 *)(&VarStoreHeader->Signature))[3] == 0xffffffff &&\r
-             VarStoreHeader->Size == 0xffffffff &&\r
-             VarStoreHeader->Format == 0xff &&\r
-             VarStoreHeader->State == 0xff\r
-          ) {\r
-\r
-    return EfiRaw;\r
-  } else {\r
-    return EfiInvalid;\r
-  }\r
-}\r
-\r
-/**\r
-  Gets the size of variable name.\r
-\r
-  This function gets the size of variable name.\r
-  The variable is specified by its variable header.\r
-  If variable header contains raw data, just return 0.\r
-\r
-  @param[in] Variable  Pointer to the variable header.\r
-\r
-  @return              Size of variable name in bytes.\r
-\r
-**/\r
-UINTN\r
-NameSizeOfVariable (\r
-  IN  AUTHENTICATED_VARIABLE_HEADER     *Variable\r
-  )\r
-{\r
-  if (Variable->State    == (UINT8) (-1) ||\r
-      Variable->DataSize == (UINT32) -1 ||\r
-      Variable->NameSize == (UINT32) -1 ||\r
-      Variable->Attributes == (UINT32) -1) {\r
-    return 0;\r
-  }\r
-  return (UINTN) Variable->NameSize;\r
-}\r
-\r
-/**\r
-  Gets the size of variable data area.\r
-\r
-  This function gets the size of variable data area.\r
-  The variable is specified by its variable header.\r
-  If variable header contains raw data, just return 0.\r
-\r
-  @param[in]  Variable  Pointer to the variable header.\r
-\r
-  @return               Size of variable data area in bytes.\r
-\r
-**/\r
-UINTN\r
-DataSizeOfVariable (\r
-  IN  AUTHENTICATED_VARIABLE_HEADER     *Variable\r
-  )\r
-{\r
-  if (Variable->State    == (UINT8)  -1 ||\r
-      Variable->DataSize == (UINT32) -1 ||\r
-      Variable->NameSize == (UINT32) -1 ||\r
-      Variable->Attributes == (UINT32) -1) {\r
-    return 0;\r
-  }\r
-  return (UINTN) Variable->DataSize;\r
-}\r
-\r
-/**\r
-  Gets the pointer to variable name.\r
-\r
-  This function gets the pointer to variable name.\r
-  The variable is specified by its variable header.\r
-\r
-  @param[in]  VariableAddress    Start address of variable header.\r
-  @param[in]  Volatile           TRUE  - Variable is volatile.\r
-                                 FALSE - Variable is non-volatile.\r
-  @param[in]  Global             Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]  Instance           Instance of FV Block services.\r
-  @param[out] VariableName       Buffer to hold variable name for output.\r
-\r
-**/\r
-VOID\r
-GetVariableNamePtr (\r
-  IN  EFI_PHYSICAL_ADDRESS   VariableAddress,\r
-  IN  BOOLEAN                Volatile,\r
-  IN  VARIABLE_GLOBAL        *Global,\r
-  IN  UINTN                  Instance,\r
-  OUT CHAR16                 *VariableName\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_PHYSICAL_ADDRESS              Address;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-  BOOLEAN                           IsValid;\r
-\r
-  IsValid = IsValidVariableHeader (VariableAddress, Volatile, Global, Instance, &VariableHeader);\r
-  ASSERT (IsValid);\r
-\r
-  //\r
-  // Name area follows variable header.\r
-  //\r
-  Address = VariableAddress + sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
-\r
-  Status = AccessVariableStore (\r
-             FALSE,\r
-             Global,\r
-             Volatile,\r
-             Instance,\r
-             Address,\r
-             VariableHeader.NameSize,\r
-             VariableName\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
-\r
-/**\r
-  Gets the pointer to variable data area.\r
-\r
-  This function gets the pointer to variable data area.\r
-  The variable is specified by its variable header.\r
-\r
-  @param[in]  VariableAddress    Start address of variable header.\r
-  @param[in]  Volatile           TRUE  - Variable is volatile.\r
-                                 FALSE - Variable is non-volatile.\r
-  @param[in]  Global             Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]  Instance           Instance of FV Block services.\r
-  @param[out] VariableData       Buffer to hold variable data for output.\r
-\r
-**/\r
-VOID\r
-GetVariableDataPtr (\r
-  IN  EFI_PHYSICAL_ADDRESS   VariableAddress,\r
-  IN  BOOLEAN                Volatile,\r
-  IN  VARIABLE_GLOBAL        *Global,\r
-  IN  UINTN                  Instance,\r
-  OUT CHAR16                 *VariableData\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  EFI_PHYSICAL_ADDRESS              Address;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-  BOOLEAN                           IsValid;\r
-\r
-  IsValid = IsValidVariableHeader (VariableAddress, Volatile, Global, Instance, &VariableHeader);\r
-  ASSERT (IsValid);\r
-\r
-  //\r
-  // Data area follows variable name.\r
-  // Be careful about pad size for alignment\r
-  //\r
-  Address =  VariableAddress + sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
-  Address += NameSizeOfVariable (&VariableHeader);\r
-  Address += GET_PAD_SIZE (NameSizeOfVariable (&VariableHeader));\r
-\r
-  Status = AccessVariableStore (\r
-             FALSE,\r
-             Global,\r
-             Volatile,\r
-             Instance,\r
-             Address,\r
-             VariableHeader.DataSize,\r
-             VariableData\r
-             );\r
-  ASSERT_EFI_ERROR (Status);\r
-}\r
-\r
-\r
-/**\r
-  Gets the pointer to the next variable header.\r
-\r
-  This function gets the pointer to the next variable header.\r
-  The variable is specified by its variable header.\r
-\r
-  @param[in]  VariableAddress    Start address of variable header.\r
-  @param[in]  Volatile           TRUE  - Variable is volatile.\r
-                                 FALSE - Variable is non-volatile.\r
-  @param[in]  Global             Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]  Instance           Instance of FV Block services.\r
-\r
-  @return                        Pointer to the next variable header.\r
-                                 NULL if variable header is invalid.\r
-\r
-**/\r
-EFI_PHYSICAL_ADDRESS\r
-GetNextVariablePtr (\r
-  IN  EFI_PHYSICAL_ADDRESS   VariableAddress,\r
-  IN  BOOLEAN                Volatile,\r
-  IN  VARIABLE_GLOBAL        *Global,\r
-  IN  UINTN                  Instance\r
-  )\r
-{\r
-  EFI_PHYSICAL_ADDRESS              Address;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-\r
-  if (!IsValidVariableHeader (VariableAddress, Volatile, Global, Instance, &VariableHeader)) {\r
-    return 0x0;\r
-  }\r
-\r
-  //\r
-  // Header of next variable follows data area of this variable\r
-  //\r
-  Address =  VariableAddress + sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
-  Address += NameSizeOfVariable (&VariableHeader);\r
-  Address += GET_PAD_SIZE (NameSizeOfVariable (&VariableHeader));\r
-  Address += DataSizeOfVariable (&VariableHeader);\r
-  Address += GET_PAD_SIZE (DataSizeOfVariable (&VariableHeader));\r
-\r
-  //\r
-  // Be careful about pad size for alignment\r
-  //\r
-  return HEADER_ALIGN (Address);\r
-}\r
-\r
-/**\r
-  Gets the pointer to the first variable header in given variable store area.\r
-\r
-  This function gets the pointer to the first variable header in given variable\r
-  store area. The variable store area is given by its start address.\r
-\r
-  @param[in] VarStoreHeaderAddress  Pointer to the header of variable store area.\r
-\r
-  @return                           Pointer to the first variable header.\r
-\r
-**/\r
-EFI_PHYSICAL_ADDRESS\r
-GetStartPointer (\r
-  IN EFI_PHYSICAL_ADDRESS  VarStoreHeaderAddress\r
-  )\r
-{\r
-  return HEADER_ALIGN (VarStoreHeaderAddress + sizeof (VARIABLE_STORE_HEADER));\r
-}\r
-\r
-/**\r
-  Gets the pointer to the end of given variable store area.\r
-\r
-  This function gets the pointer to the end of given variable store area.\r
-  The variable store area is given by its start address.\r
-\r
-  @param[in]  VarStoreHeaderAddress  Pointer to the header of variable store area.\r
-  @param[in]  Volatile               TRUE  - Variable is volatile.\r
-                                     FALSE - Variable is non-volatile.\r
-  @param[in]  Global                 Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]  Instance               Instance of FV Block services.\r
-\r
-  @return                            Pointer to the end of given variable store area.\r
-\r
-**/\r
-EFI_PHYSICAL_ADDRESS\r
-GetEndPointer (\r
-  IN EFI_PHYSICAL_ADDRESS  VarStoreHeaderAddress,\r
-  IN  BOOLEAN              Volatile,\r
-  IN  VARIABLE_GLOBAL      *Global,\r
-  IN  UINTN                Instance\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  VARIABLE_STORE_HEADER VariableStoreHeader;\r
-\r
-  Status = AccessVariableStore (\r
-             FALSE,\r
-             Global,\r
-             Volatile,\r
-             Instance,\r
-             VarStoreHeaderAddress,\r
-             sizeof (VARIABLE_STORE_HEADER),\r
-             &VariableStoreHeader\r
-             );\r
-\r
-  ASSERT_EFI_ERROR (Status);\r
-  return HEADER_ALIGN (VarStoreHeaderAddress + VariableStoreHeader.Size);\r
-}\r
-\r
-/**\r
-  Updates variable info entry in EFI system table for statistical information.\r
-\r
-  Routine used to track statistical information about variable usage.\r
-  The data is stored in the EFI system table so it can be accessed later.\r
-  VariableInfo.efi can dump out the table. Only Boot Services variable\r
-  accesses are tracked by this code. The PcdVariableCollectStatistics\r
-  build flag controls if this feature is enabled.\r
-  A read that hits in the cache will have Read and Cache true for\r
-  the transaction. Data is allocated by this routine, but never\r
-  freed.\r
-\r
-  @param[in]  VariableName   Name of the Variable to track.\r
-  @param[in]  VendorGuid     Guid of the Variable to track.\r
-  @param[in]  Volatile       TRUE if volatile FALSE if non-volatile.\r
-  @param[in]  Read           TRUE if GetVariable() was called.\r
-  @param[in]  Write          TRUE if SetVariable() was called.\r
-  @param[in]  Delete         TRUE if deleted via SetVariable().\r
-  @param[in]  Cache          TRUE for a cache hit.\r
-\r
-**/\r
-VOID\r
-UpdateVariableInfo (\r
-  IN  CHAR16                  *VariableName,\r
-  IN  EFI_GUID                *VendorGuid,\r
-  IN  BOOLEAN                 Volatile,\r
-  IN  BOOLEAN                 Read,\r
-  IN  BOOLEAN                 Write,\r
-  IN  BOOLEAN                 Delete,\r
-  IN  BOOLEAN                 Cache\r
-  )\r
-{\r
-  VARIABLE_INFO_ENTRY   *Entry;\r
-\r
-  if (FeaturePcdGet (PcdVariableCollectStatistics)) {\r
-\r
-    if (EfiAtRuntime ()) {\r
-      //\r
-      // Don't collect statistics at runtime\r
-      //\r
-      return;\r
-    }\r
-\r
-    if (gVariableInfo == NULL) {\r
-      //\r
-      // on the first call allocate a entry and place a pointer to it in\r
-      // the EFI System Table\r
-      //\r
-      gVariableInfo = AllocateZeroPool (sizeof (VARIABLE_INFO_ENTRY));\r
-      ASSERT (gVariableInfo != NULL);\r
-\r
-      CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);\r
-      gVariableInfo->Name = AllocatePool (StrSize (VariableName));\r
-      ASSERT (gVariableInfo->Name != NULL);\r
-      StrCpyS (gVariableInfo->Name, StrSize (VariableName) / sizeof (CHAR16), VariableName);\r
-      gVariableInfo->Volatile = Volatile;\r
-\r
-      gBS->InstallConfigurationTable (&gEfiAuthenticatedVariableGuid, gVariableInfo);\r
-    }\r
-\r
-\r
-    for (Entry = gVariableInfo; Entry != NULL; Entry = Entry->Next) {\r
-      if (CompareGuid (VendorGuid, &Entry->VendorGuid)) {\r
-        if (StrCmp (VariableName, Entry->Name) == 0) {\r
-          //\r
-          // Find the entry matching both variable name and vender GUID,\r
-          // and update counters for all types.\r
-          //\r
-          if (Read) {\r
-            Entry->ReadCount++;\r
-          }\r
-          if (Write) {\r
-            Entry->WriteCount++;\r
-          }\r
-          if (Delete) {\r
-            Entry->DeleteCount++;\r
-          }\r
-          if (Cache) {\r
-            Entry->CacheCount++;\r
-          }\r
-\r
-          return;\r
-        }\r
-      }\r
-\r
-      if (Entry->Next == NULL) {\r
-        //\r
-        // If the entry is not in the table add it.\r
-        // Next iteration of the loop will fill in the data\r
-        //\r
-        Entry->Next = AllocateZeroPool (sizeof (VARIABLE_INFO_ENTRY));\r
-        ASSERT (Entry->Next != NULL);\r
-\r
-        CopyGuid (&Entry->Next->VendorGuid, VendorGuid);\r
-        Entry->Next->Name = AllocatePool (StrSize (VariableName));\r
-        ASSERT (Entry->Next->Name != NULL);\r
-        StrCpyS (Entry->Next->Name, StrSize (VariableName) / sizeof (CHAR16), VariableName);\r
-        Entry->Next->Volatile = Volatile;\r
-      }\r
-\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Updates variable in cache.\r
-\r
-  This function searches the variable cache. If the variable to set exists in the cache,\r
-  it updates the variable in cache. It has the same parameters with UEFI SetVariable()\r
-  service.\r
-\r
-  @param[in]  VariableName  A Null-terminated Unicode string that is the name of the vendor's\r
-                            variable.  Each VariableName is unique for each VendorGuid.\r
-  @param[in]  VendorGuid    A unique identifier for the vendor.\r
-  @param[in]  Attributes    Attributes bitmask to set for the variable.\r
-  @param[in]  DataSize      The size in bytes of the Data buffer.  A size of zero causes the\r
-                            variable to be deleted.\r
-  @param[in]  Data          The contents for the variable.\r
-\r
-**/\r
-VOID\r
-UpdateVariableCache (\r
-  IN      CHAR16            *VariableName,\r
-  IN      EFI_GUID          *VendorGuid,\r
-  IN      UINT32            Attributes,\r
-  IN      UINTN             DataSize,\r
-  IN      VOID              *Data\r
-  )\r
-{\r
-  VARIABLE_CACHE_ENTRY      *Entry;\r
-  UINTN                     Index;\r
-\r
-  if (EfiAtRuntime ()) {\r
-    //\r
-    // Don't use the cache at runtime\r
-    //\r
-    return;\r
-  }\r
-\r
-  //\r
-  // Searches cache for the variable to update. If it exists, update it.\r
-  //\r
-  for (Index = 0, Entry = mVariableCache; Index < sizeof (mVariableCache)/sizeof (VARIABLE_CACHE_ENTRY); Index++, Entry++) {\r
-    if (CompareGuid (VendorGuid, Entry->Guid)) {\r
-      if (StrCmp (VariableName, Entry->Name) == 0) {\r
-        Entry->Attributes = Attributes;\r
-        if (DataSize == 0) {\r
-          //\r
-          // If DataSize is 0, delete the variable.\r
-          //\r
-          if (Entry->DataSize != 0) {\r
-            FreePool (Entry->Data);\r
-          }\r
-          Entry->DataSize = DataSize;\r
-        } else if (DataSize == Entry->DataSize) {\r
-          //\r
-          // If size of data does not change, simply copy data\r
-          //\r
-          CopyMem (Entry->Data, Data, DataSize);\r
-        } else {\r
-          //\r
-          // If size of data changes, allocate pool and copy data.\r
-          //\r
-          Entry->Data = AllocatePool (DataSize);\r
-          ASSERT (Entry->Data != NULL);\r
-          Entry->DataSize = DataSize;\r
-          CopyMem (Entry->Data, Data, DataSize);\r
-        }\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-\r
-/**\r
-  Search the cache to check if the variable is in it.\r
-\r
-  This function searches the variable cache. If the variable to find exists, return its data\r
-  and attributes.\r
-\r
-  @param[in]      VariableName   A Null-terminated Unicode string that is the name of the vendor's\r
-                                 variable.  Each VariableName is unique for each VendorGuid.\r
-  @param[in]      VendorGuid     A unique identifier for the vendor\r
-  @param[out]     Attributes     Pointer to the attributes bitmask of the variable for output.\r
-  @param[in, out] DataSize       On input, size of the buffer of Data.\r
-                                 On output, size of the variable's data.\r
-  @param[out]     Data           Pointer to the data buffer for output.\r
-\r
-  @retval EFI_SUCCESS           VariableGuid & VariableName data was returned.\r
-  @retval EFI_NOT_FOUND         No matching variable found in cache.\r
-  @retval EFI_BUFFER_TOO_SMALL  *DataSize is smaller than size of the variable's data to return.\r
-\r
-**/\r
-EFI_STATUS\r
-FindVariableInCache (\r
-  IN      CHAR16            *VariableName,\r
-  IN      EFI_GUID          *VendorGuid,\r
-  OUT     UINT32            *Attributes OPTIONAL,\r
-  IN OUT  UINTN             *DataSize,\r
-  OUT     VOID              *Data\r
-  )\r
-{\r
-  VARIABLE_CACHE_ENTRY      *Entry;\r
-  UINTN                     Index;\r
-\r
-  if (EfiAtRuntime ()) {\r
-    //\r
-    // Don't use the cache at runtime\r
-    //\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Searches cache for the variable\r
-  //\r
-  for (Index = 0, Entry = mVariableCache; Index < sizeof (mVariableCache)/sizeof (VARIABLE_CACHE_ENTRY); Index++, Entry++) {\r
-    if (CompareGuid (VendorGuid, Entry->Guid)) {\r
-      if (StrCmp (VariableName, Entry->Name) == 0) {\r
-        if (Entry->DataSize == 0) {\r
-          //\r
-          // Variable has been deleted so return EFI_NOT_FOUND\r
-          //\r
-          return EFI_NOT_FOUND;\r
-        } else if (Entry->DataSize > *DataSize) {\r
-          //\r
-          // If buffer is too small, return the size needed and EFI_BUFFER_TOO_SMALL\r
-          //\r
-          *DataSize = Entry->DataSize;\r
-          return EFI_BUFFER_TOO_SMALL;\r
-        } else {\r
-          //\r
-          // If buffer is large enough, return the data\r
-          //\r
-          *DataSize = Entry->DataSize;\r
-          CopyMem (Data, Entry->Data, Entry->DataSize);\r
-          //\r
-          // If Attributes is not NULL, return the variable's attribute.\r
-          //\r
-          if (Attributes != NULL) {\r
-            *Attributes = Entry->Attributes;\r
-          }\r
-          return EFI_SUCCESS;\r
-        }\r
-      }\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Finds variable in volatile and non-volatile storage areas.\r
-\r
-  This code finds variable in volatile and non-volatile storage areas.\r
-  If VariableName is an empty string, then we just return the first\r
-  qualified variable without comparing VariableName and VendorGuid.\r
-  Otherwise, VariableName and VendorGuid are compared.\r
-\r
-  @param[in]  VariableName            Name of the variable to be found.\r
-  @param[in]  VendorGuid              Vendor GUID to be found.\r
-  @param[out] PtrTrack                VARIABLE_POINTER_TRACK structure for output,\r
-                                      including the range searched and the target position.\r
-  @param[in]  Global                  Pointer to VARIABLE_GLOBAL structure, including\r
-                                      base of volatile variable storage area, base of\r
-                                      NV variable storage area, and a lock.\r
-  @param[in]  Instance                Instance of FV Block services.\r
-\r
-  @retval EFI_INVALID_PARAMETER       If VariableName is not an empty string, while\r
-                                      VendorGuid is NULL.\r
-  @retval EFI_SUCCESS                 Variable successfully found.\r
-  @retval EFI_INVALID_PARAMETER       Variable not found.\r
-\r
-**/\r
-EFI_STATUS\r
-FindVariable (\r
-  IN  CHAR16                  *VariableName,\r
-  IN  EFI_GUID                *VendorGuid,\r
-  OUT VARIABLE_POINTER_TRACK  *PtrTrack,\r
-  IN  VARIABLE_GLOBAL         *Global,\r
-  IN  UINTN                   Instance\r
-  )\r
-{\r
-  EFI_PHYSICAL_ADDRESS              Variable[2];\r
-  EFI_PHYSICAL_ADDRESS              InDeletedVariable;\r
-  EFI_PHYSICAL_ADDRESS              VariableStoreHeader[2];\r
-  UINTN                             InDeletedStorageIndex;\r
-  UINTN                             Index;\r
-  CHAR16                            LocalVariableName[MAX_NAME_SIZE];\r
-  BOOLEAN                           Volatile;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-\r
-  //\r
-  // 0: Volatile, 1: Non-Volatile\r
-  // The index and attributes mapping must be kept in this order as RuntimeServiceGetNextVariableName\r
-  // make use of this mapping to implement search algorithme.\r
-  //\r
-  VariableStoreHeader[0]  = Global->VolatileVariableBase;\r
-  VariableStoreHeader[1]  = Global->NonVolatileVariableBase;\r
-\r
-  //\r
-  // Start Pointers for the variable.\r
-  // Actual Data Pointer where data can be written.\r
-  //\r
-  Variable[0] = GetStartPointer (VariableStoreHeader[0]);\r
-  Variable[1] = GetStartPointer (VariableStoreHeader[1]);\r
-\r
-  if (VariableName[0] != 0 && VendorGuid == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Find the variable by walk through volatile and then non-volatile variable store\r
-  //\r
-  InDeletedVariable     = 0x0;\r
-  InDeletedStorageIndex = 0;\r
-  Volatile = TRUE;\r
-  for (Index = 0; Index < 2; Index++) {\r
-    if (Index == 1) {\r
-      Volatile = FALSE;\r
-    }\r
-    while (IsValidVariableHeader (Variable[Index], Volatile, Global, Instance, &VariableHeader)) {\r
-      if (VariableHeader.State == VAR_ADDED ||\r
-          VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)\r
-         ) {\r
-        if (!EfiAtRuntime () || ((VariableHeader.Attributes & EFI_VARIABLE_RUNTIME_ACCESS) != 0)) {\r
-          if (VariableName[0] == 0) {\r
-            //\r
-            // If VariableName is an empty string, then we just find the first qualified variable\r
-            // without comparing VariableName and VendorGuid\r
-            //\r
-            if (VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) {\r
-              //\r
-              // If variable is in delete transition, record it.\r
-              //\r
-              InDeletedVariable     = Variable[Index];\r
-              InDeletedStorageIndex = Index;\r
-            } else {\r
-              //\r
-              // If variable is not in delete transition, return it.\r
-              //\r
-              PtrTrack->StartPtr  = GetStartPointer (VariableStoreHeader[Index]);\r
-              PtrTrack->EndPtr    = GetEndPointer (VariableStoreHeader[Index], Volatile, Global, Instance);\r
-              PtrTrack->CurrPtr   = Variable[Index];\r
-              PtrTrack->Volatile  = Volatile;\r
-\r
-              return EFI_SUCCESS;\r
-            }\r
-          } else {\r
-            //\r
-            // If VariableName is not an empty string, then VariableName and VendorGuid are compared.\r
-            //\r
-            if (CompareGuid (VendorGuid, &VariableHeader.VendorGuid)) {\r
-              GetVariableNamePtr (\r
-                Variable[Index],\r
-                Volatile,\r
-                Global,\r
-                Instance,\r
-                LocalVariableName\r
-                );\r
-\r
-              ASSERT (NameSizeOfVariable (&VariableHeader) != 0);\r
-              if (CompareMem (VariableName, LocalVariableName, NameSizeOfVariable (&VariableHeader)) == 0) {\r
-                if (VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) {\r
-                  //\r
-                  // If variable is in delete transition, record it.\r
-                  // We will use if only no VAR_ADDED variable is found.\r
-                  //\r
-                  InDeletedVariable     = Variable[Index];\r
-                  InDeletedStorageIndex = Index;\r
-                } else {\r
-                  //\r
-                  // If variable is not in delete transition, return it.\r
-                  //\r
-                  PtrTrack->StartPtr  = GetStartPointer (VariableStoreHeader[Index]);\r
-                  PtrTrack->EndPtr    = GetEndPointer (VariableStoreHeader[Index], Volatile, Global, Instance);\r
-                  PtrTrack->CurrPtr   = Variable[Index];\r
-                  PtrTrack->Volatile  = Volatile;\r
-\r
-                  return EFI_SUCCESS;\r
-                }\r
-              }\r
-            }\r
-          }\r
-        }\r
-      }\r
-\r
-      Variable[Index] = GetNextVariablePtr (\r
-                          Variable[Index],\r
-                          Volatile,\r
-                          Global,\r
-                          Instance\r
-                          );\r
-    }\r
-    if (InDeletedVariable != 0x0) {\r
-      //\r
-      // If no VAR_ADDED variable is found, and only variable in delete transition, then use this one.\r
-      //\r
-      PtrTrack->StartPtr  = GetStartPointer (VariableStoreHeader[InDeletedStorageIndex]);\r
-      PtrTrack->EndPtr    = GetEndPointer (\r
-                              VariableStoreHeader[InDeletedStorageIndex],\r
-                              (BOOLEAN)(InDeletedStorageIndex == 0),\r
-                              Global,\r
-                              Instance\r
-                              );\r
-      PtrTrack->CurrPtr   = InDeletedVariable;\r
-      PtrTrack->Volatile  = (BOOLEAN)(InDeletedStorageIndex == 0);\r
-      return EFI_SUCCESS;\r
-    }\r
-  }\r
-  PtrTrack->CurrPtr = 0x0;\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Variable store garbage collection and reclaim operation.\r
-\r
-  @param[in]  VariableBase        Base address of variable store area.\r
-  @param[out] LastVariableOffset  Offset of last variable.\r
-  @param[in]  IsVolatile          The variable store is volatile or not,\r
-                                  if it is non-volatile, need FTW.\r
-  @param[in]  VirtualMode         Current calling mode for this function.\r
-  @param[in]  Global              Context of this Extended SAL Variable Services Class call.\r
-  @param[in]  UpdatingVariable    Pointer to header of the variable that is being updated.\r
-\r
-  @retval EFI_SUCCESS             Variable store successfully reclaimed.\r
-  @retval EFI_OUT_OF_RESOURCES    Fail to allocate memory buffer to hold all valid variables.\r
-\r
-**/\r
-EFI_STATUS\r
-Reclaim (\r
-  IN  EFI_PHYSICAL_ADDRESS  VariableBase,\r
-  OUT UINTN                 *LastVariableOffset,\r
-  IN  BOOLEAN               IsVolatile,\r
-  IN  BOOLEAN               VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL  *Global,\r
-  IN  EFI_PHYSICAL_ADDRESS  UpdatingVariable\r
-  )\r
-{\r
-  EFI_PHYSICAL_ADDRESS              Variable;\r
-  EFI_PHYSICAL_ADDRESS              AddedVariable;\r
-  EFI_PHYSICAL_ADDRESS              NextVariable;\r
-  EFI_PHYSICAL_ADDRESS              NextAddedVariable;\r
-  VARIABLE_STORE_HEADER             VariableStoreHeader;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-  AUTHENTICATED_VARIABLE_HEADER     AddedVariableHeader;\r
-  CHAR16                            VariableName[MAX_NAME_SIZE];\r
-  CHAR16                            AddedVariableName[MAX_NAME_SIZE];\r
-  UINT8                             *ValidBuffer;\r
-  UINTN                             MaximumBufferSize;\r
-  UINTN                             VariableSize;\r
-  UINTN                             NameSize;\r
-  UINT8                             *CurrPtr;\r
-  BOOLEAN                           FoundAdded;\r
-  EFI_STATUS                        Status;\r
-  VARIABLE_GLOBAL                   *VariableGlobal;\r
-  UINT32                            Instance;\r
-\r
-  VariableGlobal = &Global->VariableGlobal[VirtualMode];\r
-  Instance = Global->FvbInstance;\r
-\r
-  GetVarStoreHeader (VariableBase, IsVolatile, VariableGlobal, Instance, &VariableStoreHeader);\r
-  //\r
-  // recaluate the total size of Common/HwErr type variables in non-volatile area.\r
-  //\r
-  if (!IsVolatile) {\r
-    Global->CommonVariableTotalSize = 0;\r
-    Global->HwErrVariableTotalSize  = 0;\r
-  }\r
-\r
-  //\r
-  // Calculate the size of buffer needed to gather all valid variables\r
-  //\r
-  Variable          = GetStartPointer (VariableBase);\r
-  MaximumBufferSize = sizeof (VARIABLE_STORE_HEADER);\r
-\r
-  while (IsValidVariableHeader (Variable, IsVolatile, VariableGlobal, Instance, &VariableHeader)) {\r
-    NextVariable = GetNextVariablePtr (Variable, IsVolatile, VariableGlobal, Instance);\r
-    //\r
-    // Collect VAR_ADDED variables, and variables in delete transition status.\r
-    //\r
-    if (VariableHeader.State == VAR_ADDED ||\r
-        VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)\r
-       ) {\r
-      VariableSize = NextVariable - Variable;\r
-      MaximumBufferSize += VariableSize;\r
-    }\r
-\r
-    Variable = NextVariable;\r
-  }\r
-\r
-  //\r
-  // Reserve the 1 Bytes with Oxff to identify the\r
-  // end of the variable buffer.\r
-  //\r
-  MaximumBufferSize += 1;\r
-  ValidBuffer = AllocatePool (MaximumBufferSize);\r
-  if (ValidBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  SetMem (ValidBuffer, MaximumBufferSize, 0xff);\r
-\r
-  //\r
-  // Copy variable store header\r
-  //\r
-  CopyMem (ValidBuffer, &VariableStoreHeader, sizeof (VARIABLE_STORE_HEADER));\r
-  CurrPtr = (UINT8 *) GetStartPointer ((EFI_PHYSICAL_ADDRESS) ValidBuffer);\r
-\r
-  //\r
-  // Reinstall all ADDED variables\r
-  //\r
-  Variable = GetStartPointer (VariableBase);\r
-  while (IsValidVariableHeader (Variable, IsVolatile, VariableGlobal, Instance, &VariableHeader)) {\r
-    NextVariable = GetNextVariablePtr (Variable, IsVolatile, VariableGlobal, Instance);\r
-    if (VariableHeader.State == VAR_ADDED) {\r
-      VariableSize = NextVariable - Variable;\r
-      CopyMem (CurrPtr, (UINT8 *) Variable, VariableSize);\r
-      CurrPtr += VariableSize;\r
-      if ((!IsVolatile) && ((((AUTHENTICATED_VARIABLE_HEADER*)Variable)->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-        Global->HwErrVariableTotalSize += VariableSize;\r
-      } else if ((!IsVolatile) && ((((AUTHENTICATED_VARIABLE_HEADER*)Variable)->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-        Global->CommonVariableTotalSize += VariableSize;\r
-      }\r
-    }\r
-    Variable = NextVariable;\r
-  }\r
-  //\r
-  // Reinstall in delete transition variables\r
-  //\r
-  Variable = GetStartPointer (VariableBase);\r
-  while (IsValidVariableHeader (Variable, IsVolatile, VariableGlobal, Instance, &VariableHeader)) {\r
-    NextVariable = GetNextVariablePtr (Variable, IsVolatile, VariableGlobal, Instance);\r
-    if (VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)) {\r
-\r
-      //\r
-      // Buffer has cached all ADDED variable.\r
-      // Per IN_DELETED variable, we have to guarantee that\r
-      // no ADDED one in previous buffer.\r
-      //\r
-      FoundAdded = FALSE;\r
-      AddedVariable = GetStartPointer ((EFI_PHYSICAL_ADDRESS) ValidBuffer);\r
-      while (IsValidVariableHeader (AddedVariable, IsVolatile, VariableGlobal, Instance, &AddedVariableHeader)) {\r
-        NextAddedVariable = GetNextVariablePtr (AddedVariable, IsVolatile, VariableGlobal, Instance);\r
-        NameSize = NameSizeOfVariable (&AddedVariableHeader);\r
-        if (CompareGuid (&AddedVariableHeader.VendorGuid, &VariableHeader.VendorGuid) &&\r
-            NameSize == NameSizeOfVariable (&VariableHeader)\r
-           ) {\r
-          GetVariableNamePtr (Variable, IsVolatile, VariableGlobal, Instance, VariableName);\r
-          GetVariableNamePtr (AddedVariable, IsVolatile, VariableGlobal, Instance, AddedVariableName);\r
-          if (CompareMem (VariableName, AddedVariableName, NameSize) == 0) {\r
-            //\r
-            // If ADDED variable with the same name and vender GUID has been reinstalled,\r
-            // then discard this IN_DELETED copy.\r
-            //\r
-            FoundAdded = TRUE;\r
-            break;\r
-          }\r
-        }\r
-        AddedVariable = NextAddedVariable;\r
-      }\r
-      //\r
-      // Add IN_DELETE variables that have not been added to buffer\r
-      //\r
-      if (!FoundAdded) {\r
-        VariableSize = NextVariable - Variable;\r
-        CopyMem (CurrPtr, (UINT8 *) Variable, VariableSize);\r
-        if (Variable != UpdatingVariable) {\r
-          //\r
-          // Make this IN_DELETE instance valid if:\r
-          // 1. No valid instance of this variable exists.\r
-          // 2. It is not the variable that is going to be updated.\r
-          //\r
-          ((AUTHENTICATED_VARIABLE_HEADER *) CurrPtr)->State = VAR_ADDED;\r
-        }\r
-        CurrPtr += VariableSize;\r
-        if ((!IsVolatile) && ((((AUTHENTICATED_VARIABLE_HEADER*)Variable)->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-          Global->HwErrVariableTotalSize += VariableSize;\r
-        } else if ((!IsVolatile) && ((((AUTHENTICATED_VARIABLE_HEADER*)Variable)->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-          Global->CommonVariableTotalSize += VariableSize;\r
-        }\r
-      }\r
-    }\r
-    Variable = NextVariable;\r
-  }\r
-\r
-  if (IsVolatile) {\r
-    //\r
-    // If volatile variable store, just copy valid buffer\r
-    //\r
-    SetMem ((UINT8 *) (UINTN) VariableBase, VariableStoreHeader.Size, 0xff);\r
-    CopyMem ((UINT8 *) (UINTN) VariableBase, ValidBuffer, (UINTN) (CurrPtr - (UINT8 *) ValidBuffer));\r
-    Status = EFI_SUCCESS;\r
-  } else {\r
-    //\r
-    // If non-volatile variable store, perform FTW here.\r
-    // Write ValidBuffer to destination specified by VariableBase.\r
-    //\r
-    Status = FtwVariableSpace (\r
-               VariableBase,\r
-               ValidBuffer,\r
-               (UINTN) (CurrPtr - (UINT8 *) ValidBuffer)\r
-               );\r
-  }\r
-  if (!EFI_ERROR (Status)) {\r
-    *LastVariableOffset = (UINTN) (CurrPtr - (UINT8 *) ValidBuffer);\r
-  } else {\r
-    *LastVariableOffset = 0;\r
-  }\r
-\r
-  FreePool (ValidBuffer);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Get index from supported language codes according to language string.\r
-\r
-  This code is used to get corresponding index in supported language codes. It can handle\r
-  RFC4646 and ISO639 language tags.\r
-  In ISO639 language tags, take 3-characters as a delimitation to find matched string and calculate the index.\r
-  In RFC4646 language tags, take semicolon as a delimitation to find matched string and calculate the index.\r
-\r
-  For example:\r
-    SupportedLang  = "engfraengfra"\r
-    Lang           = "eng"\r
-    Iso639Language = TRUE\r
-  The return value is "0".\r
-  Another example:\r
-    SupportedLang  = "en;fr;en-US;fr-FR"\r
-    Lang           = "fr-FR"\r
-    Iso639Language = FALSE\r
-  The return value is "3".\r
-\r
-  @param[in]  SupportedLang          Platform supported language codes.\r
-  @param[in]  Lang                   Configured language.\r
-  @param[in]  Iso639Language         A bool value to signify if the handler is operated on ISO639 or RFC4646.\r
-\r
-  @return                            The index of language in the language codes.\r
-\r
-**/\r
-UINTN\r
-GetIndexFromSupportedLangCodes(\r
-  IN  CHAR8            *SupportedLang,\r
-  IN  CHAR8            *Lang,\r
-  IN  BOOLEAN          Iso639Language\r
-  )\r
-{\r
-  UINTN    Index;\r
-  UINTN    CompareLength;\r
-  UINTN    LanguageLength;\r
-\r
-  if (Iso639Language) {\r
-    CompareLength = ISO_639_2_ENTRY_SIZE;\r
-    for (Index = 0; Index < AsciiStrLen (SupportedLang); Index += CompareLength) {\r
-      if (AsciiStrnCmp (Lang, SupportedLang + Index, CompareLength) == 0) {\r
-        //\r
-        // Successfully find the index of Lang string in SupportedLang string.\r
-        //\r
-        Index = Index / CompareLength;\r
-        return Index;\r
-      }\r
-    }\r
-    ASSERT (FALSE);\r
-    return 0;\r
-  } else {\r
-    //\r
-    // Compare RFC4646 language code\r
-    //\r
-    Index = 0;\r
-    for (LanguageLength = 0; Lang[LanguageLength] != '\0'; LanguageLength++);\r
-\r
-    for (Index = 0; *SupportedLang != '\0'; Index++, SupportedLang += CompareLength) {\r
-      //\r
-      // Skip ';' characters in SupportedLang\r
-      //\r
-      for (; *SupportedLang != '\0' && *SupportedLang == ';'; SupportedLang++);\r
-      //\r
-      // Determine the length of the next language code in SupportedLang\r
-      //\r
-      for (CompareLength = 0; SupportedLang[CompareLength] != '\0' && SupportedLang[CompareLength] != ';'; CompareLength++);\r
-\r
-      if ((CompareLength == LanguageLength) &&\r
-          (AsciiStrnCmp (Lang, SupportedLang, CompareLength) == 0)) {\r
-        //\r
-        // Successfully find the index of Lang string in SupportedLang string.\r
-        //\r
-        return Index;\r
-      }\r
-    }\r
-    ASSERT (FALSE);\r
-    return 0;\r
-  }\r
-}\r
-\r
-/**\r
-  Get language string from supported language codes according to index.\r
-\r
-  This code is used to get corresponding language string in supported language codes. It can handle\r
-  RFC4646 and ISO639 language tags.\r
-  In ISO639 language tags, take 3-characters as a delimitation. Find language string according to the index.\r
-  In RFC4646 language tags, take semicolon as a delimitation. Find language string according to the index.\r
-\r
-  For example:\r
-    SupportedLang  = "engfraengfra"\r
-    Index          = "1"\r
-    Iso639Language = TRUE\r
-  The return value is "fra".\r
-  Another example:\r
-    SupportedLang  = "en;fr;en-US;fr-FR"\r
-    Index          = "1"\r
-    Iso639Language = FALSE\r
-  The return value is "fr".\r
-\r
-  @param[in]  SupportedLang   Platform supported language codes.\r
-  @param[in]  Index           the index in supported language codes.\r
-  @param[in]  Iso639Language  A bool value to signify if the handler is operated on ISO639 or RFC4646.\r
-  @param[in]  VirtualMode     Current calling mode for this function.\r
-  @param[in]  Global          Context of this Extended SAL Variable Services Class call.\r
-\r
-  @return                     The language string in the language codes.\r
-\r
-**/\r
-CHAR8 *\r
-GetLangFromSupportedLangCodes (\r
-  IN  CHAR8                 *SupportedLang,\r
-  IN  UINTN                 Index,\r
-  IN  BOOLEAN               Iso639Language,\r
-  IN  BOOLEAN               VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL  *Global\r
-  )\r
-{\r
-  UINTN    SubIndex;\r
-  UINTN    CompareLength;\r
-  CHAR8    *Supported;\r
-\r
-  SubIndex  = 0;\r
-  Supported = SupportedLang;\r
-  if (Iso639Language) {\r
-    //\r
-    // according to the index of Lang string in SupportedLang string to get the language.\r
-    // As this code will be invoked in RUNTIME, therefore there is not memory allocate/free operation.\r
-    // In driver entry, it pre-allocates a runtime attribute memory to accommodate this string.\r
-    //\r
-    CompareLength = ISO_639_2_ENTRY_SIZE;\r
-    Global->Lang[CompareLength] = '\0';\r
-    return CopyMem (Global->Lang, SupportedLang + Index * CompareLength, CompareLength);\r
-\r
-  } else {\r
-    while (TRUE) {\r
-      //\r
-      // take semicolon as delimitation, sequentially traverse supported language codes.\r
-      //\r
-      for (CompareLength = 0; *Supported != ';' && *Supported != '\0'; CompareLength++) {\r
-        Supported++;\r
-      }\r
-      if ((*Supported == '\0') && (SubIndex != Index)) {\r
-        //\r
-        // Have completed the traverse, but not find corrsponding string.\r
-        // This case is not allowed to happen.\r
-        //\r
-        ASSERT(FALSE);\r
-        return NULL;\r
-      }\r
-      if (SubIndex == Index) {\r
-        //\r
-        // according to the index of Lang string in SupportedLang string to get the language.\r
-        // As this code will be invoked in RUNTIME, therefore there is not memory allocate/free operation.\r
-        // In driver entry, it pre-allocates a runtime attribute memory to accommodate this string.\r
-        //\r
-        Global->PlatformLang[VirtualMode][CompareLength] = '\0';\r
-        return CopyMem (Global->PlatformLang[VirtualMode], Supported - CompareLength, CompareLength);\r
-      }\r
-      SubIndex++;\r
-\r
-      //\r
-      // Skip ';' characters in Supported\r
-      //\r
-      for (; *Supported != '\0' && *Supported == ';'; Supported++);\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Returns a pointer to an allocated buffer that contains the best matching language\r
-  from a set of supported languages.\r
-\r
-  This function supports both ISO 639-2 and RFC 4646 language codes, but language\r
-  code types may not be mixed in a single call to this function. This function\r
-  supports a variable argument list that allows the caller to pass in a prioritized\r
-  list of language codes to test against all the language codes in SupportedLanguages.\r
-\r
-  If SupportedLanguages is NULL, then ASSERT().\r
-\r
-  @param[in]  SupportedLanguages  A pointer to a Null-terminated ASCII string that\r
-                                  contains a set of language codes in the format\r
-                                  specified by Iso639Language.\r
-  @param[in]  Iso639Language      If TRUE, then all language codes are assumed to be\r
-                                  in ISO 639-2 format.  If FALSE, then all language\r
-                                  codes are assumed to be in RFC 4646 language format.\r
-  @param[in]  VirtualMode         Current calling mode for this function.\r
-  @param[in]  ...                 A variable argument list that contains pointers to\r
-                                  Null-terminated ASCII strings that contain one or more\r
-                                  language codes in the format specified by Iso639Language.\r
-                                  The first language code from each of these language\r
-                                  code lists is used to determine if it is an exact or\r
-                                  close match to any of the language codes in\r
-                                  SupportedLanguages.  Close matches only apply to RFC 4646\r
-                                  language codes, and the matching algorithm from RFC 4647\r
-                                  is used to determine if a close match is present.  If\r
-                                  an exact or close match is found, then the matching\r
-                                  language code from SupportedLanguages is returned.  If\r
-                                  no matches are found, then the next variable argument\r
-                                  parameter is evaluated.  The variable argument list\r
-                                  is terminated by a NULL.\r
-\r
-  @retval NULL   The best matching language could not be found in SupportedLanguages.\r
-  @retval NULL   There are not enough resources available to return the best matching\r
-                 language.\r
-  @retval Other  A pointer to a Null-terminated ASCII string that is the best matching\r
-                 language in SupportedLanguages.\r
-\r
-**/\r
-CHAR8 *\r
-VariableGetBestLanguage (\r
-  IN CONST CHAR8  *SupportedLanguages,\r
-  IN BOOLEAN      Iso639Language,\r
-  IN BOOLEAN      VirtualMode,\r
-  ...\r
-  )\r
-{\r
-  VA_LIST      Args;\r
-  CHAR8        *Language;\r
-  UINTN        CompareLength;\r
-  UINTN        LanguageLength;\r
-  CONST CHAR8  *Supported;\r
-  CHAR8        *Buffer;\r
-\r
-  ASSERT (SupportedLanguages != NULL);\r
-\r
-  VA_START (Args, VirtualMode);\r
-  while ((Language = VA_ARG (Args, CHAR8 *)) != NULL) {\r
-    //\r
-    // Default to ISO 639-2 mode\r
-    //\r
-    CompareLength  = 3;\r
-    LanguageLength = MIN (3, AsciiStrLen (Language));\r
-\r
-    //\r
-    // If in RFC 4646 mode, then determine the length of the first RFC 4646 language code in Language\r
-    //\r
-    if (!Iso639Language) {\r
-      for (LanguageLength = 0; Language[LanguageLength] != 0 && Language[LanguageLength] != ';'; LanguageLength++);\r
-    }\r
-\r
-    //\r
-    // Trim back the length of Language used until it is empty\r
-    //\r
-    while (LanguageLength > 0) {\r
-      //\r
-      // Loop through all language codes in SupportedLanguages\r
-      //\r
-      for (Supported = SupportedLanguages; *Supported != '\0'; Supported += CompareLength) {\r
-        //\r
-        // In RFC 4646 mode, then Loop through all language codes in SupportedLanguages\r
-        //\r
-        if (!Iso639Language) {\r
-          //\r
-          // Skip ';' characters in Supported\r
-          //\r
-          for (; *Supported != '\0' && *Supported == ';'; Supported++);\r
-          //\r
-          // Determine the length of the next language code in Supported\r
-          //\r
-          for (CompareLength = 0; Supported[CompareLength] != 0 && Supported[CompareLength] != ';'; CompareLength++);\r
-          //\r
-          // If Language is longer than the Supported, then skip to the next language\r
-          //\r
-          if (LanguageLength > CompareLength) {\r
-            continue;\r
-          }\r
-        }\r
-        //\r
-        // See if the first LanguageLength characters in Supported match Language\r
-        //\r
-        if (AsciiStrnCmp (Supported, Language, LanguageLength) == 0) {\r
-          VA_END (Args);\r
-\r
-          Buffer = Iso639Language ? mVariableModuleGlobal->Lang : mVariableModuleGlobal->PlatformLang[VirtualMode];\r
-          Buffer[CompareLength] = '\0';\r
-          return CopyMem (Buffer, Supported, CompareLength);\r
-        }\r
-      }\r
-\r
-      if (Iso639Language) {\r
-        //\r
-        // If ISO 639 mode, then each language can only be tested once\r
-        //\r
-        LanguageLength = 0;\r
-      } else {\r
-        //\r
-        // If RFC 4646 mode, then trim Language from the right to the next '-' character\r
-        //\r
-        for (LanguageLength--; LanguageLength > 0 && Language[LanguageLength] != '-'; LanguageLength--);\r
-      }\r
-    }\r
-  }\r
-  VA_END (Args);\r
-\r
-  //\r
-  // No matches were found\r
-  //\r
-  return NULL;\r
-}\r
-\r
-/**\r
-  Hook the operations in PlatformLangCodes, LangCodes, PlatformLang and Lang.\r
-\r
-  When setting Lang/LangCodes, simultaneously update PlatformLang/PlatformLangCodes.\r
-  According to UEFI spec, PlatformLangCodes/LangCodes are only set once in firmware initialization,\r
-  and are read-only. Therefore, in variable driver, only store the original value for other use.\r
-\r
-  @param[in] VariableName  Name of variable.\r
-  @param[in] Data          Variable data.\r
-  @param[in] DataSize      Size of data. 0 means delete.\r
-  @param[in] VirtualMode   Current calling mode for this function.\r
-  @param[in] Global        Context of this Extended SAL Variable Services Class call.\r
-\r
-**/\r
-VOID\r
-AutoUpdateLangVariable(\r
-  IN  CHAR16                *VariableName,\r
-  IN  VOID                  *Data,\r
-  IN  UINTN                 DataSize,\r
-  IN  BOOLEAN               VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL  *Global\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  CHAR8                   *BestPlatformLang;\r
-  CHAR8                   *BestLang;\r
-  UINTN                   Index;\r
-  UINT32                  Attributes;\r
-  VARIABLE_POINTER_TRACK  Variable;\r
-  BOOLEAN                 SetLanguageCodes;\r
-  CHAR16                  **PredefinedVariableName;\r
-  VARIABLE_GLOBAL         *VariableGlobal;\r
-  UINT32                  Instance;\r
-\r
-  //\r
-  // Don't do updates for delete operation\r
-  //\r
-  if (DataSize == 0) {\r
-    return;\r
-  }\r
-\r
-  SetLanguageCodes = FALSE;\r
-  VariableGlobal   = &Global->VariableGlobal[VirtualMode];\r
-  Instance         = Global->FvbInstance;\r
-\r
-\r
-  PredefinedVariableName = &Global->VariableName[VirtualMode][0];\r
-  if (StrCmp (VariableName, PredefinedVariableName[VAR_PLATFORM_LANG_CODES]) == 0) {\r
-    //\r
-    // PlatformLangCodes is a volatile variable, so it can not be updated at runtime.\r
-    //\r
-    if (EfiAtRuntime ()) {\r
-      return;\r
-    }\r
-\r
-    SetLanguageCodes = TRUE;\r
-\r
-    //\r
-    // According to UEFI spec, PlatformLangCodes is only set once in firmware initialization, and is read-only\r
-    // Therefore, in variable driver, only store the original value for other use.\r
-    //\r
-    if (Global->PlatformLangCodes[VirtualMode] != NULL) {\r
-      FreePool (Global->PlatformLangCodes[VirtualMode]);\r
-    }\r
-    Global->PlatformLangCodes[VirtualMode] = AllocateRuntimeCopyPool (DataSize, Data);\r
-    ASSERT (Global->PlatformLangCodes[VirtualMode] != NULL);\r
-\r
-    //\r
-    // PlatformLang holds a single language from PlatformLangCodes,\r
-    // so the size of PlatformLangCodes is enough for the PlatformLang.\r
-    //\r
-    if (Global->PlatformLang[VirtualMode] != NULL) {\r
-      FreePool (Global->PlatformLang[VirtualMode]);\r
-    }\r
-    Global->PlatformLang[VirtualMode] = AllocateRuntimePool (DataSize);\r
-    ASSERT (Global->PlatformLang[VirtualMode] != NULL);\r
-\r
-  } else if (StrCmp (VariableName, PredefinedVariableName[VAR_LANG_CODES]) == 0) {\r
-    //\r
-    // LangCodes is a volatile variable, so it can not be updated at runtime.\r
-    //\r
-    if (EfiAtRuntime ()) {\r
-      return;\r
-    }\r
-\r
-    SetLanguageCodes = TRUE;\r
-\r
-    //\r
-    // According to UEFI spec, LangCodes is only set once in firmware initialization, and is read-only\r
-    // Therefore, in variable driver, only store the original value for other use.\r
-    //\r
-    if (Global->LangCodes[VirtualMode] != NULL) {\r
-      FreePool (Global->LangCodes[VirtualMode]);\r
-    }\r
-    Global->LangCodes[VirtualMode] = AllocateRuntimeCopyPool (DataSize, Data);\r
-    ASSERT (Global->LangCodes[VirtualMode] != NULL);\r
-  }\r
-\r
-  if (SetLanguageCodes\r
-      && (Global->PlatformLangCodes[VirtualMode] != NULL)\r
-      && (Global->LangCodes[VirtualMode] != NULL)) {\r
-    //\r
-    // Update Lang if PlatformLang is already set\r
-    // Update PlatformLang if Lang is already set\r
-    //\r
-    Status = FindVariable (PredefinedVariableName[VAR_PLATFORM_LANG], Global->GlobalVariableGuid[VirtualMode], &Variable, VariableGlobal, Instance);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // Update Lang\r
-      //\r
-      VariableName = PredefinedVariableName[VAR_PLATFORM_LANG];\r
-    } else {\r
-      Status = FindVariable (PredefinedVariableName[VAR_LANG], Global->GlobalVariableGuid[VirtualMode], &Variable, VariableGlobal, Instance);\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Update PlatformLang\r
-        //\r
-        VariableName = PredefinedVariableName[VAR_LANG];\r
-      } else {\r
-        //\r
-        // Neither PlatformLang nor Lang is set, directly return\r
-        //\r
-        return;\r
-      }\r
-    }\r
-    Data    = (VOID *) GetEndPointer (VariableGlobal->VolatileVariableBase, TRUE, VariableGlobal, Instance);\r
-    GetVariableDataPtr ((EFI_PHYSICAL_ADDRESS) Variable.CurrPtr, Variable.Volatile, VariableGlobal, Instance, (CHAR16 *) Data);\r
-\r
-    Status = AccessVariableStore (\r
-               FALSE,\r
-               VariableGlobal,\r
-               Variable.Volatile,\r
-               Instance,\r
-               (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable.CurrPtr)->DataSize),\r
-               sizeof (DataSize),\r
-               &DataSize\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-\r
-  //\r
-  // According to UEFI spec, "Lang" and "PlatformLang" is NV|BS|RT attributions.\r
-  //\r
-  Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;\r
-\r
-  if (StrCmp (VariableName, PredefinedVariableName[VAR_PLATFORM_LANG]) == 0) {\r
-    //\r
-    // Update Lang when PlatformLangCodes/LangCodes were set.\r
-    //\r
-    if ((Global->PlatformLangCodes[VirtualMode] != NULL) && (Global->LangCodes[VirtualMode] != NULL)) {\r
-      //\r
-      // When setting PlatformLang, firstly get most matched language string from supported language codes.\r
-      //\r
-      BestPlatformLang = VariableGetBestLanguage (Global->PlatformLangCodes[VirtualMode], FALSE, VirtualMode, Data, NULL);\r
-      if (BestPlatformLang != NULL) {\r
-        //\r
-        // Get the corresponding index in language codes.\r
-        //\r
-        Index = GetIndexFromSupportedLangCodes (Global->PlatformLangCodes[VirtualMode], BestPlatformLang, FALSE);\r
-\r
-        //\r
-        // Get the corresponding ISO639 language tag according to RFC4646 language tag.\r
-        //\r
-        BestLang = GetLangFromSupportedLangCodes (Global->LangCodes[VirtualMode], Index, TRUE, VirtualMode, Global);\r
-\r
-        //\r
-        // Successfully convert PlatformLang to Lang, and set the BestLang value into Lang variable simultaneously.\r
-        //\r
-        FindVariable (PredefinedVariableName[VAR_LANG], Global->GlobalVariableGuid[VirtualMode], &Variable, VariableGlobal, Instance);\r
-\r
-        Status = UpdateVariable (\r
-                   PredefinedVariableName[VAR_LANG],\r
-                   Global->GlobalVariableGuid[VirtualMode],\r
-                   BestLang,\r
-                   ISO_639_2_ENTRY_SIZE + 1,\r
-                   Attributes,\r
-                   0,\r
-                   0,\r
-                   VirtualMode,\r
-                   Global,\r
-                   &Variable\r
-                   );\r
-\r
-        DEBUG ((EFI_D_INFO, "Variable Driver Auto Update PlatformLang, PlatformLang:%a, Lang:%a\n", BestPlatformLang, BestLang));\r
-\r
-        ASSERT_EFI_ERROR (Status);\r
-      }\r
-    }\r
-\r
-  } else if (StrCmp (VariableName, PredefinedVariableName[VAR_LANG]) == 0) {\r
-    //\r
-    // Update PlatformLang when PlatformLangCodes/LangCodes were set.\r
-    //\r
-    if ((Global->PlatformLangCodes[VirtualMode] != NULL) && (Global->LangCodes[VirtualMode] != NULL)) {\r
-      //\r
-      // When setting Lang, firstly get most matched language string from supported language codes.\r
-      //\r
-      BestLang = VariableGetBestLanguage (Global->LangCodes[VirtualMode], TRUE, VirtualMode, Data, NULL);\r
-      if (BestLang != NULL) {\r
-        //\r
-        // Get the corresponding index in language codes.\r
-        //\r
-        Index = GetIndexFromSupportedLangCodes (Global->LangCodes[VirtualMode], BestLang, TRUE);\r
-\r
-        //\r
-        // Get the corresponding RFC4646 language tag according to ISO639 language tag.\r
-        //\r
-        BestPlatformLang = GetLangFromSupportedLangCodes (Global->PlatformLangCodes[VirtualMode], Index, FALSE, VirtualMode, Global);\r
-\r
-        //\r
-        // Successfully convert Lang to PlatformLang, and set the BestPlatformLang value into PlatformLang variable simultaneously.\r
-        //\r
-        FindVariable (PredefinedVariableName[VAR_PLATFORM_LANG], Global->GlobalVariableGuid[VirtualMode], &Variable, VariableGlobal, Instance);\r
-\r
-        Status = UpdateVariable (\r
-                   PredefinedVariableName[VAR_PLATFORM_LANG],\r
-                   Global->GlobalVariableGuid[VirtualMode],\r
-                   BestPlatformLang,\r
-                   AsciiStrSize (BestPlatformLang),\r
-                   Attributes,\r
-                   0,\r
-                   0,\r
-                   VirtualMode,\r
-                   Global,\r
-                   &Variable\r
-                   );\r
-\r
-        DEBUG ((EFI_D_INFO, "Variable Driver Auto Update Lang, Lang:%a, PlatformLang:%a\n", BestLang, BestPlatformLang));\r
-        ASSERT_EFI_ERROR (Status);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Update the variable region with Variable information. These are the same\r
-  arguments as the EFI Variable services.\r
-\r
-  @param[in] VariableName       Name of variable.\r
-  @param[in] VendorGuid         Guid of variable.\r
-  @param[in] Data               Variable data.\r
-  @param[in] DataSize           Size of data. 0 means delete.\r
-  @param[in] Attributes         Attributes of the variable.\r
-  @param[in] KeyIndex           Index of associated public key.\r
-  @param[in] MonotonicCount     Value of associated monotonic count.\r
-  @param[in] VirtualMode        Current calling mode for this function.\r
-  @param[in] Global             Context of this Extended SAL Variable Services Class call.\r
-  @param[in] Variable           The variable information which is used to keep track of variable usage.\r
-\r
-  @retval EFI_SUCCESS           The update operation is success.\r
-  @retval EFI_OUT_OF_RESOURCES  Variable region is full, can not write other data into this region.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UpdateVariable (\r
-  IN      CHAR16                  *VariableName,\r
-  IN      EFI_GUID                *VendorGuid,\r
-  IN      VOID                    *Data,\r
-  IN      UINTN                   DataSize,\r
-  IN      UINT32                  Attributes OPTIONAL,\r
-  IN      UINT32                  KeyIndex  OPTIONAL,\r
-  IN      UINT64                  MonotonicCount  OPTIONAL,\r
-  IN      BOOLEAN                 VirtualMode,\r
-  IN      ESAL_VARIABLE_GLOBAL    *Global,\r
-  IN      VARIABLE_POINTER_TRACK  *Variable\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  AUTHENTICATED_VARIABLE_HEADER       *NextVariable;\r
-  UINTN                               VarNameOffset;\r
-  UINTN                               VarDataOffset;\r
-  UINTN                               VarNameSize;\r
-  UINTN                               VarSize;\r
-  BOOLEAN                             Volatile;\r
-  UINT8                               State;\r
-  AUTHENTICATED_VARIABLE_HEADER       VariableHeader;\r
-  AUTHENTICATED_VARIABLE_HEADER       *NextVariableHeader;\r
-  BOOLEAN                             Valid;\r
-  BOOLEAN                             Reclaimed;\r
-  VARIABLE_STORE_HEADER               VariableStoreHeader;\r
-  UINTN                               ScratchSize;\r
-  VARIABLE_GLOBAL                     *VariableGlobal;\r
-  UINT32                              Instance;\r
-\r
-  VariableGlobal = &Global->VariableGlobal[VirtualMode];\r
-  Instance = Global->FvbInstance;\r
-\r
-  Reclaimed  = FALSE;\r
-\r
-  if (Variable->CurrPtr != 0) {\r
-\r
-    Valid = IsValidVariableHeader (Variable->CurrPtr, Variable->Volatile, VariableGlobal, Instance, &VariableHeader);\r
-    if (!Valid) {\r
-      Status = EFI_NOT_FOUND;\r
-      goto Done;\r
-    }\r
-\r
-    //\r
-    // Update/Delete existing variable\r
-    //\r
-    Volatile = Variable->Volatile;\r
-\r
-    if (EfiAtRuntime ()) {\r
-      //\r
-      // If EfiAtRuntime and the variable is Volatile and Runtime Access,\r
-      // the volatile is ReadOnly, and SetVariable should be aborted and\r
-      // return EFI_WRITE_PROTECTED.\r
-      //\r
-      if (Variable->Volatile) {\r
-        Status = EFI_WRITE_PROTECTED;\r
-        goto Done;\r
-      }\r
-      //\r
-      // Only variable have NV attribute can be updated/deleted in Runtime\r
-      //\r
-      if ((VariableHeader.Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
-        Status = EFI_INVALID_PARAMETER;\r
-        goto Done;\r
-      }\r
-    }\r
-    //\r
-    // Setting a data variable with no access, or zero DataSize attributes\r
-    // specified causes it to be deleted.\r
-    //\r
-    if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
-      State = VariableHeader.State;\r
-      State &= VAR_DELETED;\r
-\r
-      Status = AccessVariableStore (\r
-                 TRUE,\r
-                 VariableGlobal,\r
-                 Variable->Volatile,\r
-                 Instance,\r
-                 (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
-                 sizeof (UINT8),\r
-                 &State\r
-                 );\r
-      if (!EFI_ERROR (Status)) {\r
-        UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, FALSE, TRUE, FALSE);\r
-        UpdateVariableCache (VariableName, VendorGuid, Attributes, DataSize, Data);\r
-      }\r
-      goto Done;\r
-    }\r
-    //\r
-    // Logic comes here to update variable.\r
-    // If the variable is marked valid and the same data has been passed in\r
-    // then return to the caller immediately.\r
-    //\r
-    if (DataSizeOfVariable (&VariableHeader) == DataSize) {\r
-      NextVariable = (AUTHENTICATED_VARIABLE_HEADER *)GetEndPointer (VariableGlobal->VolatileVariableBase, TRUE, VariableGlobal, Instance);\r
-      GetVariableDataPtr (Variable->CurrPtr, Variable->Volatile, VariableGlobal, Instance, (CHAR16 *) NextVariable);\r
-      if  (CompareMem (Data, (VOID *) NextVariable, DataSize) == 0) {\r
-        UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, TRUE, FALSE, FALSE);\r
-        Status = EFI_SUCCESS;\r
-        goto Done;\r
-      }\r
-    }\r
-    if ((VariableHeader.State == VAR_ADDED) ||\r
-        (VariableHeader.State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION))) {\r
-      //\r
-      // If new data is different from the old one, mark the old one as VAR_IN_DELETED_TRANSITION.\r
-      // It will be deleted if new variable is successfully written.\r
-      //\r
-      State = VariableHeader.State;\r
-      State &= VAR_IN_DELETED_TRANSITION;\r
-\r
-      Status = AccessVariableStore (\r
-                 TRUE,\r
-                 VariableGlobal,\r
-                 Variable->Volatile,\r
-                 Instance,\r
-                 (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
-                 sizeof (UINT8),\r
-                 &State\r
-                 );\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-    }\r
-  } else {\r
-    //\r
-    // Create a new variable\r
-    //\r
-\r
-    //\r
-    // Make sure we are trying to create a new variable.\r
-    // Setting a data variable with no access, or zero DataSize attributes means to delete it.\r
-    //\r
-    if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
-      Status = EFI_NOT_FOUND;\r
-      goto Done;\r
-    }\r
-\r
-    //\r
-    // Only variable have NV|RT attribute can be created in Runtime\r
-    //\r
-    if (EfiAtRuntime () &&\r
-        (((Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0) || ((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0))) {\r
-      Status = EFI_INVALID_PARAMETER;\r
-      goto Done;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Function part - create a new variable and copy the data.\r
-  // Both update a variable and create a variable will come here.\r
-  //\r
-  // Tricky part: Use scratch data area at the end of volatile variable store\r
-  // as a temporary storage.\r
-  //\r
-  NextVariable = (AUTHENTICATED_VARIABLE_HEADER *)GetEndPointer (VariableGlobal->VolatileVariableBase, TRUE, VariableGlobal, Instance);\r
-  ScratchSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize));\r
-  NextVariableHeader = (AUTHENTICATED_VARIABLE_HEADER *) NextVariable;\r
-\r
-  SetMem (NextVariableHeader, ScratchSize, 0xff);\r
-\r
-  NextVariableHeader->StartId         = VARIABLE_DATA;\r
-  NextVariableHeader->Attributes      = Attributes;\r
-  NextVariableHeader->PubKeyIndex     = KeyIndex;\r
-  NextVariableHeader->MonotonicCount  = MonotonicCount;\r
-  NextVariableHeader->Reserved        = 0;\r
-  VarNameOffset                       = sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
-  VarNameSize                         = StrSize (VariableName);\r
-  CopyMem (\r
-    (UINT8 *) ((UINTN)NextVariable + VarNameOffset),\r
-    VariableName,\r
-    VarNameSize\r
-    );\r
-  VarDataOffset = VarNameOffset + VarNameSize + GET_PAD_SIZE (VarNameSize);\r
-  CopyMem (\r
-    (UINT8 *) ((UINTN)NextVariable + VarDataOffset),\r
-    Data,\r
-    DataSize\r
-    );\r
-  CopyMem (&NextVariableHeader->VendorGuid, VendorGuid, sizeof (EFI_GUID));\r
-  //\r
-  // There will be pad bytes after Data, the NextVariable->NameSize and\r
-  // NextVariable->DataSize should not include pad size so that variable\r
-  // service can get actual size in GetVariable.\r
-  //\r
-  NextVariableHeader->NameSize  = (UINT32)VarNameSize;\r
-  NextVariableHeader->DataSize  = (UINT32)DataSize;\r
-\r
-  //\r
-  // The actual size of the variable that stores in storage should\r
-  // include pad size.\r
-  //\r
-  VarSize = VarDataOffset + DataSize + GET_PAD_SIZE (DataSize);\r
-  if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
-    //\r
-    // Create a nonvolatile variable\r
-    //\r
-    Volatile = FALSE;\r
-\r
-    GetVarStoreHeader (VariableGlobal->NonVolatileVariableBase, FALSE, VariableGlobal, Instance, &VariableStoreHeader);\r
-    if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0)\r
-             && ((HEADER_ALIGN (VarSize) + Global->HwErrVariableTotalSize) > PcdGet32(PcdHwErrStorageSize)))\r
-             || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0)\r
-             && ((HEADER_ALIGN (VarSize) + Global->CommonVariableTotalSize) > VariableStoreHeader.Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize)))) {\r
-      if (EfiAtRuntime ()) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        goto Done;\r
-      }\r
-      //\r
-      // Perform garbage collection & reclaim operation\r
-      //\r
-      Status = Reclaim (VariableGlobal->NonVolatileVariableBase, &(Global->NonVolatileLastVariableOffset), FALSE, VirtualMode, Global, Variable->CurrPtr);\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-\r
-      Reclaimed = TRUE;\r
-      //\r
-      // If still no enough space, return out of resources\r
-      //\r
-      if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0)\r
-               && ((HEADER_ALIGN (VarSize) + Global->HwErrVariableTotalSize) > PcdGet32(PcdHwErrStorageSize)))\r
-               || (((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == 0)\r
-               && ((HEADER_ALIGN (VarSize) + Global->CommonVariableTotalSize) > VariableStoreHeader.Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize)))) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        goto Done;\r
-      }\r
-    }\r
-    //\r
-    // Four steps\r
-    // 1. Write variable header\r
-    // 2. Set variable state to header valid\r
-    // 3. Write variable data\r
-    // 4. Set variable state to valid\r
-    //\r
-    //\r
-    // Step 1:\r
-    //\r
-    Status = AccessVariableStore (\r
-               TRUE,\r
-               VariableGlobal,\r
-               FALSE,\r
-               Instance,\r
-               VariableGlobal->NonVolatileVariableBase + Global->NonVolatileLastVariableOffset,\r
-               sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
-               (UINT8 *) NextVariable\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    //\r
-    // Step 2:\r
-    //\r
-    NextVariableHeader->State = VAR_HEADER_VALID_ONLY;\r
-    Status = AccessVariableStore (\r
-               TRUE,\r
-               VariableGlobal,\r
-               FALSE,\r
-               Instance,\r
-               VariableGlobal->NonVolatileVariableBase + Global->NonVolatileLastVariableOffset,\r
-               sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
-               (UINT8 *) NextVariable\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-    //\r
-    // Step 3:\r
-    //\r
-    Status = AccessVariableStore (\r
-               TRUE,\r
-               VariableGlobal,\r
-               FALSE,\r
-               Instance,\r
-               VariableGlobal->NonVolatileVariableBase + Global->NonVolatileLastVariableOffset + sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
-               (UINT32) VarSize - sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
-               (UINT8 *) NextVariable + sizeof (AUTHENTICATED_VARIABLE_HEADER)\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-    //\r
-    // Step 4:\r
-    //\r
-    NextVariableHeader->State = VAR_ADDED;\r
-    Status = AccessVariableStore (\r
-               TRUE,\r
-               VariableGlobal,\r
-               FALSE,\r
-               Instance,\r
-               VariableGlobal->NonVolatileVariableBase + Global->NonVolatileLastVariableOffset,\r
-               sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
-               (UINT8 *) NextVariable\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    Global->NonVolatileLastVariableOffset += HEADER_ALIGN (VarSize);\r
-\r
-    if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) {\r
-      Global->HwErrVariableTotalSize += HEADER_ALIGN (VarSize);\r
-    } else {\r
-      Global->CommonVariableTotalSize += HEADER_ALIGN (VarSize);\r
-    }\r
-  } else {\r
-    //\r
-    // Create a volatile variable\r
-    //\r
-    Volatile = TRUE;\r
-\r
-    if ((UINT32) (HEADER_ALIGN(VarSize) + Global->VolatileLastVariableOffset) >\r
-        ((VARIABLE_STORE_HEADER *) ((UINTN) (VariableGlobal->VolatileVariableBase)))->Size) {\r
-      //\r
-      // Perform garbage collection & reclaim operation\r
-      //\r
-      Status = Reclaim (VariableGlobal->VolatileVariableBase, &Global->VolatileLastVariableOffset, TRUE, VirtualMode, Global, Variable->CurrPtr);\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-      //\r
-      // If still no enough space, return out of resources\r
-      //\r
-      if ((UINT32) (HEADER_ALIGN (VarSize) + Global->VolatileLastVariableOffset) >\r
-            ((VARIABLE_STORE_HEADER *) ((UINTN) (VariableGlobal->VolatileVariableBase)))->Size\r
-            ) {\r
-        Status = EFI_OUT_OF_RESOURCES;\r
-        goto Done;\r
-      }\r
-      Reclaimed = TRUE;\r
-    }\r
-\r
-    NextVariableHeader->State = VAR_ADDED;\r
-    Status = AccessVariableStore (\r
-               TRUE,\r
-               VariableGlobal,\r
-               TRUE,\r
-               Instance,\r
-               VariableGlobal->VolatileVariableBase + Global->VolatileLastVariableOffset,\r
-               (UINT32) VarSize,\r
-               (UINT8 *) NextVariable\r
-               );\r
-\r
-    if (EFI_ERROR (Status)) {\r
-      goto Done;\r
-    }\r
-\r
-    Global->VolatileLastVariableOffset += HEADER_ALIGN (VarSize);\r
-  }\r
-  //\r
-  // Mark the old variable as deleted\r
-  // If storage has just been reclaimed, the old variable marked as VAR_IN_DELETED_TRANSITION\r
-  // has already been eliminated, so no need to delete it.\r
-  //\r
-  if (!Reclaimed && !EFI_ERROR (Status) && Variable->CurrPtr != 0) {\r
-    State = ((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State;\r
-    State &= VAR_DELETED;\r
-\r
-    Status = AccessVariableStore (\r
-               TRUE,\r
-               VariableGlobal,\r
-               Variable->Volatile,\r
-               Instance,\r
-               (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
-               sizeof (UINT8),\r
-               &State\r
-               );\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    UpdateVariableInfo (VariableName, VendorGuid, Volatile, FALSE, TRUE, FALSE, FALSE);\r
-    UpdateVariableCache (VariableName, VendorGuid, Attributes, DataSize, Data);\r
-  }\r
-\r
-Done:\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Implements EsalGetVariable function of Extended SAL Variable Services Class.\r
-\r
-  This function implements EsalGetVariable function of Extended SAL Variable Services Class.\r
-  It is equivalent in functionality to the EFI Runtime Service GetVariable().\r
-\r
-  @param[in]      VariableName    A Null-terminated Unicode string that is the name of\r
-                                  the vendor's variable.\r
-  @param[in]      VendorGuid      A unique identifier for the vendor.\r
-  @param[out]     Attributes      If not NULL, a pointer to the memory location to return the\r
-                                  attributes bitmask for the variable.\r
-  @param[in, out] DataSize        Size of Data found. If size is less than the\r
-                                  data, this value contains the required size.\r
-  @param[out]     Data            On input, the size in bytes of the return Data buffer.\r
-                                  On output, the size of data returned in Data.\r
-  @param[in]      VirtualMode     Current calling mode for this function.\r
-  @param[in]      Global          Context of this Extended SAL Variable Services Class call.\r
-\r
-  @retval EFI_SUCCESS            The function completed successfully.\r
-  @retval EFI_NOT_FOUND          The variable was not found.\r
-  @retval EFI_BUFFER_TOO_SMALL   DataSize is too small for the result.  DataSize has\r
-                                 been updated with the size needed to complete the request.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is NULL.\r
-  @retval EFI_INVALID_PARAMETER  VendorGuid is NULL.\r
-  @retval EFI_INVALID_PARAMETER  DataSize is NULL.\r
-  @retval EFI_INVALID_PARAMETER  DataSize is not too small and Data is NULL.\r
-  @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EsalGetVariable (\r
-  IN      CHAR16                *VariableName,\r
-  IN      EFI_GUID              *VendorGuid,\r
-  OUT     UINT32                *Attributes OPTIONAL,\r
-  IN OUT  UINTN                 *DataSize,\r
-  OUT     VOID                  *Data,\r
-  IN      BOOLEAN               VirtualMode,\r
-  IN      ESAL_VARIABLE_GLOBAL  *Global\r
-  )\r
-{\r
-  VARIABLE_POINTER_TRACK            Variable;\r
-  UINTN                             VarDataSize;\r
-  EFI_STATUS                        Status;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-  BOOLEAN                           Valid;\r
-  VARIABLE_GLOBAL                   *VariableGlobal;\r
-  UINT32                            Instance;\r
-\r
-  if (VariableName == NULL || VendorGuid == NULL || DataSize == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  VariableGlobal = &Global->VariableGlobal[VirtualMode];\r
-  Instance = Global->FvbInstance;\r
-\r
-  AcquireLockOnlyAtBootTime(&VariableGlobal->VariableServicesLock);\r
-\r
-  //\r
-  // Check if this variable exists in cache.\r
-  //\r
-  Status = FindVariableInCache (VariableName, VendorGuid, Attributes, DataSize, Data);\r
-  if ((Status == EFI_BUFFER_TOO_SMALL) || (Status == EFI_SUCCESS)){\r
-    //\r
-    // If variable exists in cache, just update statistical information for it and finish.\r
-    // Here UpdateVariableInfo() has already retrieved data & attributes for output.\r
-    //\r
-    UpdateVariableInfo (VariableName, VendorGuid, FALSE, TRUE, FALSE, FALSE, TRUE);\r
-    goto Done;\r
-  }\r
-  //\r
-  // If variable does not exist in cache, search for it in variable storage area.\r
-  //\r
-  Status = FindVariable (VariableName, VendorGuid, &Variable, VariableGlobal, Instance);\r
-  if (Variable.CurrPtr == 0x0 || EFI_ERROR (Status)) {\r
-    //\r
-    // If it cannot be found in variable storage area, goto Done.\r
-    //\r
-    goto Done;\r
-  }\r
-\r
-  Valid = IsValidVariableHeader (Variable.CurrPtr, Variable.Volatile, VariableGlobal, Instance, &VariableHeader);\r
-  if (!Valid) {\r
-    Status = EFI_NOT_FOUND;\r
-    goto Done;\r
-  }\r
-  //\r
-  // If variable exists, but not in cache, get its data and attributes, update\r
-  // statistical information, and update cache.\r
-  //\r
-  VarDataSize = DataSizeOfVariable (&VariableHeader);\r
-  ASSERT (VarDataSize != 0);\r
-\r
-  if (*DataSize >= VarDataSize) {\r
-    if (Data == NULL) {\r
-      Status = EFI_INVALID_PARAMETER;\r
-      goto Done;\r
-    }\r
-\r
-    GetVariableDataPtr (\r
-      Variable.CurrPtr,\r
-      Variable.Volatile,\r
-      VariableGlobal,\r
-      Instance,\r
-      Data\r
-      );\r
-    if (Attributes != NULL) {\r
-      *Attributes = VariableHeader.Attributes;\r
-    }\r
-\r
-    *DataSize = VarDataSize;\r
-    UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE, FALSE, FALSE, FALSE);\r
-    UpdateVariableCache (VariableName, VendorGuid, VariableHeader.Attributes, VarDataSize, Data);\r
-\r
-    Status = EFI_SUCCESS;\r
-    goto Done;\r
-  } else {\r
-    //\r
-    // If DataSize is too small for the result, return EFI_BUFFER_TOO_SMALL.\r
-    //\r
-    *DataSize = VarDataSize;\r
-    Status = EFI_BUFFER_TOO_SMALL;\r
-    goto Done;\r
-  }\r
-\r
-Done:\r
-  ReleaseLockOnlyAtBootTime (&VariableGlobal->VariableServicesLock);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Implements EsalGetNextVariableName function of Extended SAL Variable Services Class.\r
-\r
-  This function implements EsalGetNextVariableName function of Extended SAL Variable Services Class.\r
-  It is equivalent in functionality to the EFI Runtime Service GetNextVariableName().\r
-\r
-  @param[in, out] VariableNameSize Size of the variable\r
-  @param[in, out] VariableName     On input, supplies the last VariableName that was returned by GetNextVariableName().\r
-                                   On output, returns the Null-terminated Unicode string of the current variable.\r
-  @param[in, out] VendorGuid       On input, supplies the last VendorGuid that was returned by GetNextVariableName().\r
-                                   On output, returns the VendorGuid of the current variable.\r
-  @param[in]      VirtualMode      Current calling mode for this function.\r
-  @param[in]      Global           Context of this Extended SAL Variable Services Class call.\r
-\r
-  @retval EFI_SUCCESS             The function completed successfully.\r
-  @retval EFI_NOT_FOUND           The next variable was not found.\r
-  @retval EFI_BUFFER_TOO_SMALL    VariableNameSize is too small for the result.\r
-                                  VariableNameSize has been updated with the size needed to complete the request.\r
-  @retval EFI_INVALID_PARAMETER   VariableNameSize is NULL.\r
-  @retval EFI_INVALID_PARAMETER   VariableName is NULL.\r
-  @retval EFI_INVALID_PARAMETER   VendorGuid is NULL.\r
-  @retval EFI_DEVICE_ERROR        The variable name could not be retrieved due to a hardware error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EsalGetNextVariableName (\r
-  IN OUT  UINTN                 *VariableNameSize,\r
-  IN OUT  CHAR16                *VariableName,\r
-  IN OUT  EFI_GUID              *VendorGuid,\r
-  IN      BOOLEAN               VirtualMode,\r
-  IN      ESAL_VARIABLE_GLOBAL  *Global\r
-  )\r
-{\r
-  VARIABLE_POINTER_TRACK            Variable;\r
-  UINTN                             VarNameSize;\r
-  EFI_STATUS                        Status;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-  VARIABLE_GLOBAL                   *VariableGlobal;\r
-  UINT32                            Instance;\r
-\r
-  if (VariableNameSize == NULL || VariableName == NULL || VendorGuid == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  VariableGlobal = &Global->VariableGlobal[VirtualMode];\r
-  Instance = Global->FvbInstance;\r
-\r
-  AcquireLockOnlyAtBootTime(&VariableGlobal->VariableServicesLock);\r
-\r
-  Status = FindVariable (VariableName, VendorGuid, &Variable, VariableGlobal, Instance);\r
-  //\r
-  // If the variable does not exist, goto Done and return.\r
-  //\r
-  if (Variable.CurrPtr == 0x0 || EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  if (VariableName[0] != 0) {\r
-    //\r
-    // If variable name is not NULL, get next variable\r
-    //\r
-    Variable.CurrPtr = GetNextVariablePtr (\r
-                         Variable.CurrPtr,\r
-                         Variable.Volatile,\r
-                         VariableGlobal,\r
-                         Instance\r
-                         );\r
-  }\r
-\r
-  while (TRUE) {\r
-    if (Variable.CurrPtr >= Variable.EndPtr || Variable.CurrPtr == 0x0) {\r
-      //\r
-      // If fail to find a variable in current area, reverse the volatile attribute of area to search.\r
-      //\r
-      Variable.Volatile = (BOOLEAN) (Variable.Volatile ^ ((BOOLEAN) 0x1));\r
-      //\r
-      // Here we depend on the searching sequence of FindVariable().\r
-      // It first searches volatile area, then NV area.\r
-      // So if the volatile attribute after switching is non-volatile, it means that we have finished searching volatile area,\r
-      // and EFI_NOT_FOUND is returnd.\r
-      // Otherwise, it means that we have finished searchig non-volatile area, and we will continue to search volatile area.\r
-      //\r
-      if (!Variable.Volatile) {\r
-        Variable.StartPtr = GetStartPointer (VariableGlobal->NonVolatileVariableBase);\r
-        Variable.EndPtr   = GetEndPointer (VariableGlobal->NonVolatileVariableBase, FALSE, VariableGlobal, Instance);\r
-      } else {\r
-        Status = EFI_NOT_FOUND;\r
-        goto Done;\r
-      }\r
-\r
-      Variable.CurrPtr = Variable.StartPtr;\r
-      if (!IsValidVariableHeader (Variable.CurrPtr, Variable.Volatile, VariableGlobal, Instance, NULL)) {\r
-        continue;\r
-      }\r
-    }\r
-    //\r
-    // Variable is found\r
-    //\r
-    if (IsValidVariableHeader (Variable.CurrPtr, Variable.Volatile, VariableGlobal, Instance, &VariableHeader)) {\r
-      if ((VariableHeader.State == VAR_ADDED) &&\r
-          (!(EfiAtRuntime () && ((VariableHeader.Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0)))) {\r
-        VarNameSize = NameSizeOfVariable (&VariableHeader);\r
-        ASSERT (VarNameSize != 0);\r
-\r
-        if (VarNameSize <= *VariableNameSize) {\r
-          GetVariableNamePtr (\r
-            Variable.CurrPtr,\r
-            Variable.Volatile,\r
-            VariableGlobal,\r
-            Instance,\r
-            VariableName\r
-            );\r
-          CopyMem (\r
-            VendorGuid,\r
-            &VariableHeader.VendorGuid,\r
-            sizeof (EFI_GUID)\r
-            );\r
-          Status = EFI_SUCCESS;\r
-        } else {\r
-          Status = EFI_BUFFER_TOO_SMALL;\r
-        }\r
-\r
-        *VariableNameSize = VarNameSize;\r
-        goto Done;\r
-      }\r
-    }\r
-\r
-    Variable.CurrPtr = GetNextVariablePtr (\r
-                         Variable.CurrPtr,\r
-                         Variable.Volatile,\r
-                         VariableGlobal,\r
-                         Instance\r
-                         );\r
-  }\r
-\r
-Done:\r
-  ReleaseLockOnlyAtBootTime (&VariableGlobal->VariableServicesLock);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Implements EsalSetVariable function of Extended SAL Variable Services Class.\r
-\r
-  This function implements EsalSetVariable function of Extended SAL Variable Services Class.\r
-  It is equivalent in functionality to the EFI Runtime Service SetVariable().\r
-\r
-  @param[in]  VariableName       A Null-terminated Unicode string that is the name of the vendor's\r
-                                 variable.  Each VariableName is unique for each\r
-                                 VendorGuid.  VariableName must contain 1 or more\r
-                                 Unicode characters.  If VariableName is an empty Unicode\r
-                                 string, then EFI_INVALID_PARAMETER is returned.\r
-  @param[in]  VendorGuid         A unique identifier for the vendor.\r
-  @param[in]  Attributes         Attributes bitmask to set for the variable.\r
-  @param[in]  DataSize           The size in bytes of the Data buffer.  A size of zero causes the\r
-                                 variable to be deleted.\r
-  @param[in]  Data               The contents for the variable.\r
-  @param[in]  VirtualMode        Current calling mode for this function.\r
-  @param[in]  Global             Context of this Extended SAL Variable Services Class call.\r
-\r
-  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
-                                 defined by the Attributes.\r
-  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the\r
-                                 DataSize exceeds the maximum allowed.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is an empty Unicode string.\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
-  @retval EFI_DEVICE_ERROR       The variable could not be saved due to a hardware failure.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question is read-only.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.\r
-  @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EsalSetVariable (\r
-  IN CHAR16                  *VariableName,\r
-  IN EFI_GUID                *VendorGuid,\r
-  IN UINT32                  Attributes,\r
-  IN UINTN                   DataSize,\r
-  IN VOID                    *Data,\r
-  IN BOOLEAN                 VirtualMode,\r
-  IN ESAL_VARIABLE_GLOBAL    *Global\r
-  )\r
-{\r
-  VARIABLE_POINTER_TRACK  Variable;\r
-  EFI_STATUS              Status;\r
-  EFI_PHYSICAL_ADDRESS    NextVariable;\r
-  EFI_PHYSICAL_ADDRESS    Point;\r
-  VARIABLE_GLOBAL         *VariableGlobal;\r
-  UINT32                  Instance;\r
-  UINT32                  KeyIndex;\r
-  UINT64                  MonotonicCount;\r
-  UINTN                   PayloadSize;\r
-\r
-  //\r
-  // Check input parameters\r
-  //\r
-  if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if (DataSize != 0 && Data == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // EFI_VARIABLE_RUNTIME_ACCESS bit cannot be set without EFI_VARIABLE_BOOTSERVICE_ACCESS bit.\r
-  //\r
-  if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) == EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) {\r
-    if (DataSize < AUTHINFO_SIZE) {\r
-      //\r
-      // Try to write Authencated Variable without AuthInfo\r
-      //\r
-      return EFI_SECURITY_VIOLATION;\r
-    }\r
-    PayloadSize = DataSize - AUTHINFO_SIZE;\r
-  } else {\r
-    PayloadSize = DataSize;\r
-  }\r
-\r
-\r
-  if ((UINTN)(~0) - PayloadSize < StrSize(VariableName)){\r
-    //\r
-    // Prevent whole variable size overflow\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  VariableGlobal = &Global->VariableGlobal[VirtualMode];\r
-  Instance = Global->FvbInstance;\r
-\r
-  if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-    //\r
-    // For variable for hardware error record, the size of the VariableName, including the Unicode Null\r
-    // in bytes plus the DataSize is limited to maximum size of PcdGet32(PcdMaxHardwareErrorVariableSize) bytes.\r
-    //\r
-    if (StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-    //\r
-    // According to UEFI spec, HARDWARE_ERROR_RECORD variable name convention should be L"HwErrRecXXXX"\r
-    //\r
-    if (StrnCmp (VariableName, \\r
-                 Global->VariableName[VirtualMode][VAR_HW_ERR_REC], \\r
-                 StrLen(Global->VariableName[VirtualMode][VAR_HW_ERR_REC])) != 0) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  } else {\r
-    //\r
-    // For variable not for hardware error record, the size of the VariableName, including the\r
-    // Unicode Null in bytes plus the DataSize is limited to maximum size of PcdGet32(PcdMaxVariableSize) bytes.\r
-    //\r
-    if (StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER)) {\r
-      return EFI_INVALID_PARAMETER;\r
-    }\r
-  }\r
-\r
-  AcquireLockOnlyAtBootTime(&VariableGlobal->VariableServicesLock);\r
-\r
-  //\r
-  // Consider reentrant in MCA/INIT/NMI. It needs be reupdated;\r
-  //\r
-  if (InterlockedIncrement (&Global->ReentrantState) > 1) {\r
-    Point = VariableGlobal->NonVolatileVariableBase;;\r
-    //\r
-    // Parse non-volatile variable data and get last variable offset\r
-    //\r
-    NextVariable  = GetStartPointer (Point);\r
-    while (IsValidVariableHeader (NextVariable, FALSE, VariableGlobal, Instance, NULL)) {\r
-      NextVariable = GetNextVariablePtr (NextVariable, FALSE, VariableGlobal, Instance);\r
-    }\r
-    Global->NonVolatileLastVariableOffset = NextVariable - Point;\r
-  }\r
-\r
-  //\r
-  // Check whether the input variable exists\r
-  //\r
-\r
-  Status = FindVariable (VariableName, VendorGuid, &Variable, VariableGlobal, Instance);\r
-\r
-  //\r
-  // Hook the operation of setting PlatformLangCodes/PlatformLang and LangCodes/Lang\r
-  //\r
-  AutoUpdateLangVariable (VariableName, Data, PayloadSize, VirtualMode, Global);\r
-\r
-  //\r
-  // Process PK, KEK, Sigdb seperately\r
-  //\r
-  if (CompareGuid (VendorGuid, Global->GlobalVariableGuid[VirtualMode]) && (StrCmp (VariableName, Global->VariableName[VirtualMode][VAR_PLATFORM_KEY]) == 0)) {\r
-    Status = ProcessVarWithPk (VariableName, VendorGuid, Data, DataSize, VirtualMode, Global, &Variable, Attributes, TRUE);\r
-  } else if (CompareGuid (VendorGuid, Global->GlobalVariableGuid[VirtualMode]) && (StrCmp (VariableName, Global->VariableName[VirtualMode][VAR_KEY_EXCHANGE_KEY]) == 0)) {\r
-    Status = ProcessVarWithPk (VariableName, VendorGuid, Data, DataSize, VirtualMode, Global, &Variable, Attributes, FALSE);\r
-  } else if (CompareGuid (VendorGuid, Global->ImageSecurityDatabaseGuid[VirtualMode])) {\r
-    Status = ProcessVarWithKek (VariableName, VendorGuid, Data, DataSize, VirtualMode, Global, &Variable, Attributes);\r
-  } else {\r
-    Status = VerifyVariable (Data, DataSize, VirtualMode, Global, &Variable, Attributes, &KeyIndex, &MonotonicCount);\r
-    if (!EFI_ERROR(Status)) {\r
-      //\r
-      // Verification pass\r
-      //\r
-      if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
-        //\r
-        // Cut the certificate size before set\r
-        //\r
-        Status = UpdateVariable (\r
-                   VariableName,\r
-                   VendorGuid,\r
-                   (UINT8*)Data + AUTHINFO_SIZE,\r
-                   DataSize - AUTHINFO_SIZE,\r
-                   Attributes,\r
-                   KeyIndex,\r
-                   MonotonicCount,\r
-                   VirtualMode,\r
-                   Global,\r
-                   &Variable\r
-                   );\r
-      } else {\r
-        //\r
-        // Update variable as usual\r
-        //\r
-        Status = UpdateVariable (\r
-                   VariableName,\r
-                   VendorGuid,\r
-                   Data,\r
-                   DataSize,\r
-                   Attributes,\r
-                   0,\r
-                   0,\r
-                   VirtualMode,\r
-                   Global,\r
-                   &Variable\r
-                   );\r
-      }\r
-    }\r
-  }\r
-\r
-  InterlockedDecrement (&Global->ReentrantState);\r
-  ReleaseLockOnlyAtBootTime (&VariableGlobal->VariableServicesLock);\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Implements EsalQueryVariableInfo function of Extended SAL Variable Services Class.\r
-\r
-  This function implements EsalQueryVariableInfo function of Extended SAL Variable Services Class.\r
-  It is equivalent in functionality to the EFI Runtime Service QueryVariableInfo().\r
-\r
-  @param[in]  Attributes                   Attributes bitmask to specify the type of variables\r
-                                           on which to return information.\r
-  @param[out] MaximumVariableStorageSize   On output the maximum size of the storage space available for\r
-                                           the EFI variables associated with the attributes specified.\r
-  @param[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI\r
-                                           variables associated with the attributes specified.\r
-  @param[out] MaximumVariableSize          Returns the maximum size of an individual EFI variable\r
-                                           associated with the attributes specified.\r
-  @param[in]  VirtualMode                  Current calling mode for this function\r
-  @param[in]  Global                       Context of this Extended SAL Variable Services Class call\r
-\r
-  @retval EFI_SUCCESS                      Valid answer returned.\r
-  @retval EFI_INVALID_PARAMETER            An invalid combination of attribute bits was supplied.\r
-  @retval EFI_UNSUPPORTED                  The attribute is not supported on this platform, and the\r
-                                           MaximumVariableStorageSize, RemainingVariableStorageSize,\r
-                                           MaximumVariableSize are undefined.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EsalQueryVariableInfo (\r
-  IN  UINT32                 Attributes,\r
-  OUT UINT64                 *MaximumVariableStorageSize,\r
-  OUT UINT64                 *RemainingVariableStorageSize,\r
-  OUT UINT64                 *MaximumVariableSize,\r
-  IN  BOOLEAN                VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL   *Global\r
-  )\r
-{\r
-  EFI_PHYSICAL_ADDRESS              Variable;\r
-  EFI_PHYSICAL_ADDRESS              NextVariable;\r
-  UINT64                            VariableSize;\r
-  EFI_PHYSICAL_ADDRESS              VariableStoreHeaderAddress;\r
-  BOOLEAN                           Volatile;\r
-  VARIABLE_STORE_HEADER             VarStoreHeader;\r
-  AUTHENTICATED_VARIABLE_HEADER     VariableHeader;\r
-  UINT64                            CommonVariableTotalSize;\r
-  UINT64                            HwErrVariableTotalSize;\r
-  VARIABLE_GLOBAL                   *VariableGlobal;\r
-  UINT32                            Instance;\r
-\r
-  CommonVariableTotalSize = 0;\r
-  HwErrVariableTotalSize = 0;\r
-\r
-  if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL || Attributes == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  if((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == 0) {\r
-    //\r
-    // Make sure the Attributes combination is supported by the platform.\r
-    //\r
-    return EFI_UNSUPPORTED;\r
-  } else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\r
-    //\r
-    // Make sure if runtime bit is set, boot service bit is set also.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  } else if (EfiAtRuntime () && ((Attributes & EFI_VARIABLE_RUNTIME_ACCESS) == 0)) {\r
-    //\r
-    // Make sure RT Attribute is set if we are in Runtime phase.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  } else if ((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-    //\r
-    // Make sure Hw Attribute is set with NV.\r
-    //\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  VariableGlobal = &Global->VariableGlobal[VirtualMode];\r
-  Instance = Global->FvbInstance;\r
-\r
-  AcquireLockOnlyAtBootTime(&VariableGlobal->VariableServicesLock);\r
-\r
-  if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
-    //\r
-    // Query is Volatile related.\r
-    //\r
-    Volatile = TRUE;\r
-    VariableStoreHeaderAddress = VariableGlobal->VolatileVariableBase;\r
-  } else {\r
-    //\r
-    // Query is Non-Volatile related.\r
-    //\r
-    Volatile = FALSE;\r
-    VariableStoreHeaderAddress = VariableGlobal->NonVolatileVariableBase;\r
-  }\r
-\r
-  //\r
-  // Now let's fill *MaximumVariableStorageSize *RemainingVariableStorageSize\r
-  // with the storage size (excluding the storage header size).\r
-  //\r
-  GetVarStoreHeader (VariableStoreHeaderAddress, Volatile, VariableGlobal, Instance, &VarStoreHeader);\r
-\r
-  *MaximumVariableStorageSize   = VarStoreHeader.Size - sizeof (VARIABLE_STORE_HEADER);\r
-\r
-  // Harware error record variable needs larger size.\r
-  //\r
-  if ((Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-    *MaximumVariableStorageSize = PcdGet32(PcdHwErrStorageSize);\r
-    *MaximumVariableSize = PcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
-  } else {\r
-    if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
-      ASSERT (PcdGet32(PcdHwErrStorageSize) < VarStoreHeader.Size);\r
-      *MaximumVariableStorageSize = VarStoreHeader.Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize);\r
-    }\r
-\r
-    //\r
-    // Let *MaximumVariableSize be PcdGet32(PcdMaxVariableSize) with the exception of the variable header size.\r
-    //\r
-    *MaximumVariableSize = PcdGet32(PcdMaxVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
-  }\r
-\r
-  //\r
-  // Point to the starting address of the variables.\r
-  //\r
-  Variable = GetStartPointer (VariableStoreHeaderAddress);\r
-\r
-  //\r
-  // Now walk through the related variable store.\r
-  //\r
-  while (IsValidVariableHeader (Variable, Volatile, VariableGlobal, Instance, &VariableHeader) &&\r
-         (Variable < GetEndPointer (VariableStoreHeaderAddress, Volatile, VariableGlobal, Instance))) {\r
-    NextVariable = GetNextVariablePtr (Variable, Volatile, VariableGlobal, Instance);\r
-    VariableSize = NextVariable - Variable;\r
-\r
-    if (EfiAtRuntime ()) {\r
-      //\r
-      // we don't take the state of the variables in mind\r
-      // when calculating RemainingVariableStorageSize,\r
-      // since the space occupied by variables not marked with\r
-      // VAR_ADDED is not allowed to be reclaimed in Runtime.\r
-      //\r
-      if ((VariableHeader.Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-        HwErrVariableTotalSize += VariableSize;\r
-      } else {\r
-        CommonVariableTotalSize += VariableSize;\r
-      }\r
-    } else {\r
-      //\r
-      // Only care about Variables with State VAR_ADDED,because\r
-      // the space not marked as VAR_ADDED is reclaimable now.\r
-      //\r
-      if (VariableHeader.State == VAR_ADDED) {\r
-        if ((VariableHeader.Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
-          HwErrVariableTotalSize += VariableSize;\r
-        } else {\r
-          CommonVariableTotalSize += VariableSize;\r
-        }\r
-      }\r
-    }\r
-\r
-    //\r
-    // Go to the next one\r
-    //\r
-    Variable = NextVariable;\r
-  }\r
-\r
-  if ((Attributes  & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD){\r
-    *RemainingVariableStorageSize = *MaximumVariableStorageSize - HwErrVariableTotalSize;\r
-  }else {\r
-    *RemainingVariableStorageSize = *MaximumVariableStorageSize - CommonVariableTotalSize;\r
-  }\r
-\r
-  if (*RemainingVariableStorageSize < sizeof (AUTHENTICATED_VARIABLE_HEADER)) {\r
-    *MaximumVariableSize = 0;\r
-  } else if ((*RemainingVariableStorageSize - sizeof (AUTHENTICATED_VARIABLE_HEADER)) < *MaximumVariableSize) {\r
-    *MaximumVariableSize = *RemainingVariableStorageSize - sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
-  }\r
-\r
-  ReleaseLockOnlyAtBootTime (&VariableGlobal->VariableServicesLock);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Notification function of EVT_GROUP_READY_TO_BOOT event group.\r
-\r
-  This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group.\r
-  When the Boot Manager is about to load and execute a boot option, it reclaims variable\r
-  storage if free size is below the threshold.\r
-\r
-  @param[in]  Event        Event whose notification function is being invoked.\r
-  @param[in]  Context      Pointer to the notification function's context.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-ReclaimForOS(\r
-  IN EFI_EVENT  Event,\r
-  IN VOID       *Context\r
-  )\r
-{\r
-  UINT32                          VarSize;\r
-  EFI_STATUS                      Status;\r
-  UINTN                           CommonVariableSpace;\r
-  UINTN                           RemainingCommonVariableSpace;\r
-  UINTN                           RemainingHwErrVariableSpace;\r
-\r
-  VarSize = ((VARIABLE_STORE_HEADER *) ((UINTN) mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase))->Size;\r
-  Status  = EFI_SUCCESS;\r
-  //\r
-  //Allowable max size of common variable storage space\r
-  //\r
-  CommonVariableSpace = VarSize - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize);\r
-\r
-  RemainingCommonVariableSpace = CommonVariableSpace - mVariableModuleGlobal->CommonVariableTotalSize;\r
-\r
-  RemainingHwErrVariableSpace = PcdGet32 (PcdHwErrStorageSize) - mVariableModuleGlobal->HwErrVariableTotalSize;\r
-  //\r
-  // If the free area is below a threshold, then performs reclaim operation.\r
-  //\r
-  if ((RemainingCommonVariableSpace < PcdGet32 (PcdMaxVariableSize))\r
-    || ((PcdGet32 (PcdHwErrStorageSize) != 0) &&\r
-       (RemainingHwErrVariableSpace < PcdGet32 (PcdMaxHardwareErrorVariableSize)))){\r
-    Status = Reclaim (\r
-               mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase,\r
-               &mVariableModuleGlobal->NonVolatileLastVariableOffset,\r
-               FALSE,\r
-               Physical,\r
-               mVariableModuleGlobal,\r
-               0x0\r
-               );\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
-}\r
-\r
-/**\r
-  Flush the HOB variable to NV variable storage.\r
-**/\r
-VOID\r
-FlushHob2Nv (\r
-  VOID\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  VOID                            *GuidHob;\r
-  VARIABLE_STORE_HEADER           *VariableStoreHeader;\r
-  AUTHENTICATED_VARIABLE_HEADER   *VariableHeader;\r
-  //\r
-  // Get HOB variable store.\r
-  //\r
-  GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);\r
-  if (GuidHob != NULL) {\r
-    VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r
-    if (CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid) &&\r
-        (VariableStoreHeader->Format == VARIABLE_STORE_FORMATTED) &&\r
-        (VariableStoreHeader->State == VARIABLE_STORE_HEALTHY)\r
-       ) {\r
-      DEBUG ((EFI_D_INFO, "HOB Variable Store appears to be valid.\n"));\r
-      //\r
-      // Flush the HOB variable to NV Variable storage.\r
-      //\r
-      for ( VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *) HEADER_ALIGN (VariableStoreHeader + 1)\r
-          ; (VariableHeader < (AUTHENTICATED_VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) VariableStoreHeader + VariableStoreHeader->Size)\r
-            &&\r
-            (VariableHeader->StartId == VARIABLE_DATA))\r
-          ; VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) (VariableHeader + 1)\r
-                           + VariableHeader->NameSize + GET_PAD_SIZE (VariableHeader->NameSize)\r
-                           + VariableHeader->DataSize + GET_PAD_SIZE (VariableHeader->DataSize)\r
-                           )\r
-          ) {\r
-        ASSERT (VariableHeader->State == VAR_ADDED);\r
-        ASSERT ((VariableHeader->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0);\r
-        Status = EsalSetVariable (\r
-                   (CHAR16 *) (VariableHeader + 1),\r
-                   &VariableHeader->VendorGuid,\r
-                   VariableHeader->Attributes,\r
-                   VariableHeader->DataSize,\r
-                   (UINT8 *) (VariableHeader + 1) + VariableHeader->NameSize + GET_PAD_SIZE (VariableHeader->NameSize),\r
-                   Physical,\r
-                   mVariableModuleGlobal\r
-                   );\r
-        ASSERT_EFI_ERROR (Status);\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/**\r
-  Initializes variable store area for non-volatile and volatile variable.\r
-\r
-  This function allocates and initializes memory space for global context of ESAL\r
-  variable service and variable store area for non-volatile and volatile variable.\r
-\r
-  @param[in]  ImageHandle       The Image handle of this driver.\r
-  @param[in]  SystemTable       The pointer of EFI_SYSTEM_TABLE.\r
-\r
-  @retval EFI_SUCCESS           Function successfully executed.\r
-  @retval EFI_OUT_OF_RESOURCES  Fail to allocate enough memory resource.\r
-\r
-**/\r
-EFI_STATUS\r
-VariableCommonInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  )\r
-{\r
-  EFI_STATUS                      Status;\r
-  EFI_FIRMWARE_VOLUME_HEADER      *FwVolHeader;\r
-  EFI_PHYSICAL_ADDRESS            CurrPtr;\r
-  VARIABLE_STORE_HEADER           *VolatileVariableStore;\r
-  VARIABLE_STORE_HEADER           *VariableStoreHeader;\r
-  EFI_PHYSICAL_ADDRESS            Variable;\r
-  EFI_PHYSICAL_ADDRESS            NextVariable;\r
-  UINTN                           VariableSize;\r
-  UINT32                          Instance;\r
-  EFI_PHYSICAL_ADDRESS            FvVolHdr;\r
-  EFI_PHYSICAL_ADDRESS            TempVariableStoreHeader;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;\r
-  UINT64                          BaseAddress;\r
-  UINT64                          Length;\r
-  UINTN                           Index;\r
-  UINT8                           Data;\r
-  EFI_PHYSICAL_ADDRESS            VariableStoreBase;\r
-  UINT64                          VariableStoreLength;\r
-  EFI_EVENT                       ReadyToBootEvent;\r
-  UINTN                           ScratchSize;\r
-\r
-  //\r
-  // Allocate memory for mVariableModuleGlobal\r
-  //\r
-  mVariableModuleGlobal = AllocateRuntimeZeroPool (sizeof (ESAL_VARIABLE_GLOBAL));\r
-  if (mVariableModuleGlobal == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  mVariableModuleGlobal->GlobalVariableGuid[Physical] = &gEfiGlobalVariableGuid;\r
-  CopyMem (\r
-    mVariableModuleGlobal->VariableName[Physical],\r
-    mVariableName,\r
-    sizeof (mVariableName)\r
-    );\r
-\r
-  EfiInitializeLock(&mVariableModuleGlobal->VariableGlobal[Physical].VariableServicesLock, TPL_NOTIFY);\r
-\r
-  //\r
-  // Note that in EdkII variable driver implementation, Hardware Error Record type variable\r
-  // is stored with common variable in the same NV region. So the platform integrator should\r
-  // ensure that the value of PcdHwErrStorageSize is less than or equal to the value of\r
-  // PcdFlashNvStorageVariableSize.\r
-  //\r
-  ASSERT (PcdGet32(PcdHwErrStorageSize) <= PcdGet32 (PcdFlashNvStorageVariableSize));\r
-\r
-  //\r
-  // Allocate memory for volatile variable store\r
-  //\r
-  ScratchSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize));\r
-  VolatileVariableStore = AllocateRuntimePool (PcdGet32 (PcdVariableStoreSize) + ScratchSize);\r
-  if (VolatileVariableStore == NULL) {\r
-    FreePool (mVariableModuleGlobal);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  SetMem (VolatileVariableStore, PcdGet32 (PcdVariableStoreSize) + ScratchSize, 0xff);\r
-\r
-  //\r
-  // Variable Specific Data\r
-  //\r
-  mVariableModuleGlobal->VariableGlobal[Physical].VolatileVariableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) VolatileVariableStore;\r
-  mVariableModuleGlobal->VolatileLastVariableOffset = (UINTN) GetStartPointer ((EFI_PHYSICAL_ADDRESS) VolatileVariableStore) - (UINTN) VolatileVariableStore;\r
-\r
-  CopyGuid (&VolatileVariableStore->Signature, &gEfiAuthenticatedVariableGuid);\r
-  VolatileVariableStore->Size                       = PcdGet32 (PcdVariableStoreSize);\r
-  VolatileVariableStore->Format                     = VARIABLE_STORE_FORMATTED;\r
-  VolatileVariableStore->State                      = VARIABLE_STORE_HEALTHY;\r
-  VolatileVariableStore->Reserved                   = 0;\r
-  VolatileVariableStore->Reserved1                  = 0;\r
-\r
-  //\r
-  // Get non volatile varaible store\r
-  //\r
-  TempVariableStoreHeader = (UINT64) PcdGet32 (PcdFlashNvStorageVariableBase);\r
-  VariableStoreBase = TempVariableStoreHeader + \\r
-                              (((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength);\r
-  VariableStoreLength = (UINT64) PcdGet32 (PcdFlashNvStorageVariableSize) - \\r
-                                (((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) (TempVariableStoreHeader)) -> HeaderLength);\r
-  //\r
-  // Mark the variable storage region of the FLASH as RUNTIME\r
-  //\r
-  BaseAddress = VariableStoreBase & (~EFI_PAGE_MASK);\r
-  Length      = VariableStoreLength + (VariableStoreBase - BaseAddress);\r
-  Length      = (Length + EFI_PAGE_SIZE - 1) & (~EFI_PAGE_MASK);\r
-\r
-  Status      = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-\r
-  Status = gDS->SetMemorySpaceAttributes (\r
-                  BaseAddress,\r
-                  Length,\r
-                  GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    goto Done;\r
-  }\r
-  //\r
-  // Get address of non volatile variable store base.\r
-  //\r
-  mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase = VariableStoreBase;\r
-\r
-  //\r
-  // Check Integrity\r
-  //\r
-  //\r
-  // Find the Correct Instance of the FV Block Service.\r
-  //\r
-  Instance  = 0;\r
-  CurrPtr   = mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase;\r
-\r
-  do {\r
-    FvVolHdr = 0;\r
-    Status    = (EFI_STATUS) EsalCall (\r
-                               EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_LO,\r
-                               EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID_HI,\r
-                               GetPhysicalAddressFunctionId,\r
-                               Instance,\r
-                               (UINT64) &FvVolHdr,\r
-                               0,\r
-                               0,\r
-                               0,\r
-                               0,\r
-                               0\r
-                               ).Status;\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-    FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvVolHdr);\r
-    ASSERT (FwVolHeader != NULL);\r
-    if (CurrPtr >= (EFI_PHYSICAL_ADDRESS) FwVolHeader &&\r
-        CurrPtr <  ((EFI_PHYSICAL_ADDRESS) FwVolHeader + FwVolHeader->FvLength)) {\r
-      mVariableModuleGlobal->FvbInstance = Instance;\r
-      break;\r
-    }\r
-\r
-    Instance++;\r
-  } while (Status == EFI_SUCCESS);\r
-\r
-  VariableStoreHeader = (VARIABLE_STORE_HEADER *) CurrPtr;\r
-  if (GetVariableStoreStatus (VariableStoreHeader) == EfiValid) {\r
-    if (~VariableStoreHeader->Size == 0) {\r
-      Status = AccessVariableStore (\r
-                 TRUE,\r
-                 &mVariableModuleGlobal->VariableGlobal[Physical],\r
-                 FALSE,\r
-                 mVariableModuleGlobal->FvbInstance,\r
-                 (UINTN) &VariableStoreHeader->Size,\r
-                 sizeof (UINT32),\r
-                 (UINT8 *) &VariableStoreLength\r
-                 );\r
-      //\r
-      // As Variables are stored in NV storage, which are slow devices,such as flash.\r
-      // Variable operation may skip checking variable program result to improve performance,\r
-      // We can assume Variable program is OK through some check point.\r
-      // Variable Store Size Setting should be the first Variable write operation,\r
-      // We can assume all Read/Write is OK if we can set Variable store size successfully.\r
-      // If write fail, we will assert here.\r
-      //\r
-      ASSERT(VariableStoreHeader->Size == VariableStoreLength);\r
-\r
-      if (EFI_ERROR (Status)) {\r
-        goto Done;\r
-      }\r
-    }\r
-\r
-    mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase = (EFI_PHYSICAL_ADDRESS) ((UINTN) CurrPtr);\r
-    //\r
-    // Parse non-volatile variable data and get last variable offset.\r
-    //\r
-    Variable = GetStartPointer (CurrPtr);\r
-    Status   = EFI_SUCCESS;\r
-\r
-    while (IsValidVariableHeader (Variable, FALSE, &(mVariableModuleGlobal->VariableGlobal[Physical]), Instance, NULL)) {\r
-      NextVariable = GetNextVariablePtr (\r
-                       Variable,\r
-                       FALSE,\r
-                       &(mVariableModuleGlobal->VariableGlobal[Physical]),\r
-                       Instance\r
-                       );\r
-      VariableSize = NextVariable - Variable;\r
-      if ((((AUTHENTICATED_VARIABLE_HEADER *)Variable)->Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\r
-        mVariableModuleGlobal->HwErrVariableTotalSize += VariableSize;\r
-      } else {\r
-        mVariableModuleGlobal->CommonVariableTotalSize += VariableSize;\r
-      }\r
-\r
-      Variable = NextVariable;\r
-    }\r
-\r
-    mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) Variable - (UINTN) CurrPtr;\r
-\r
-    //\r
-    // Check if the free area is really free.\r
-    //\r
-    for (Index = mVariableModuleGlobal->NonVolatileLastVariableOffset; Index < VariableStoreHeader->Size; Index++) {\r
-      Data = ((UINT8 *) (UINTN) mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase)[Index];\r
-      if (Data != 0xff) {\r
-        //\r
-        // There must be something wrong in variable store, do reclaim operation.\r
-        //\r
-        Status = Reclaim (\r
-                   mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase,\r
-                   &mVariableModuleGlobal->NonVolatileLastVariableOffset,\r
-                   FALSE,\r
-                   Physical,\r
-                   mVariableModuleGlobal,\r
-                   0x0\r
-                   );\r
-        if (EFI_ERROR (Status)) {\r
-          goto Done;\r
-        }\r
-        break;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Register the event handling function to reclaim variable for OS usage.\r
-    //\r
-    Status = EfiCreateEventReadyToBootEx (\r
-               TPL_NOTIFY,\r
-               ReclaimForOS,\r
-               NULL,\r
-               &ReadyToBootEvent\r
-               );\r
-  } else {\r
-    Status = EFI_VOLUME_CORRUPTED;\r
-    DEBUG((EFI_D_ERROR, "Variable Store header is corrupted\n"));\r
-  }\r
-\r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    FreePool (mVariableModuleGlobal);\r
-    FreePool (VolatileVariableStore);\r
-  }\r
-\r
-  return Status;\r
-}\r
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h
deleted file mode 100644 (file)
index 76d4ac5..0000000
+++ /dev/null
@@ -1,505 +0,0 @@
-/** @file\r
-  Internal header file for Extended SAL variable service module.\r
-\r
-Copyright (c) 2009 - 2018, 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
-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
-#ifndef _VARIABLE_H_\r
-#define _VARIABLE_H_\r
-\r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/VariableWrite.h>\r
-#include <Protocol/FaultTolerantWrite.h>\r
-#include <Protocol/FirmwareVolumeBlock.h>\r
-#include <Protocol/Variable.h>\r
-#include <Protocol/ExtendedSalBootService.h>\r
-#include <Protocol/ExtendedSalServiceClasses.h>\r
-\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/AuthenticatedVariableFormat.h>\r
-#include <Guid/ImageAuthentication.h>\r
-#include <Guid/EventGroup.h>\r
-\r
-#include <Library/PcdLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/UefiDriverEntryPoint.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/SynchronizationLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/ExtendedSalLib.h>\r
-#include <Library/BaseCryptLib.h>\r
-\r
-#define MAX_NAME_SIZE            0x100\r
-#define NUM_VAR_NAME             9  // Number of pre-defined variable name to be referenced\r
-#define VAR_PLATFORM_LANG_CODES  0  // Index of "PlatformLangCodes" variable\r
-#define VAR_LANG_CODES           1  // Index of "LangCodes" variable\r
-#define VAR_PLATFORM_LANG        2  // Index of "PlatformLang" variable\r
-#define VAR_LANG                 3  // Index of "Lang" variable\r
-#define VAR_HW_ERR_REC           4  // Index of "HwErrRecXXXX" variable\r
-#define VAR_AUTH_KEY_DB          5  // Index of "AuthVarKeyDatabase" variable\r
-#define VAR_SETUP_MODE           6  // Index of "SetupMode" variable\r
-#define VAR_PLATFORM_KEY         7  // Index of "PK" variable\r
-#define VAR_KEY_EXCHANGE_KEY     8  // Index of "KEK" variable\r
-\r
-///\r
-/// "AuthVarKeyDatabase" variable for the Public Key store.\r
-///\r
-#define AUTHVAR_KEYDB_NAME      L"AuthVarKeyDatabase"\r
-#define AUTHVAR_KEYDB_NAME_SIZE 38\r
-\r
-///\r
-/// The maximum size of the public key database, restricted by maximum individal EFI\r
-/// varible size, and excluding the variable header and name size.\r
-///\r
-#define MAX_KEYDB_SIZE  (FixedPcdGet32 (PcdMaxVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER) - AUTHVAR_KEYDB_NAME_SIZE)\r
-#define MAX_KEY_NUM     (MAX_KEYDB_SIZE / EFI_CERT_TYPE_RSA2048_SIZE)\r
-\r
-///\r
-/// The size of a 3 character ISO639 language code.\r
-///\r
-#define ISO_639_2_ENTRY_SIZE    3\r
-\r
-typedef enum {\r
-  Physical,\r
-  Virtual\r
-} VARIABLE_POINTER_TYPE;\r
-\r
-typedef struct {\r
-  EFI_PHYSICAL_ADDRESS CurrPtr;\r
-  EFI_PHYSICAL_ADDRESS EndPtr;\r
-  EFI_PHYSICAL_ADDRESS StartPtr;\r
-  BOOLEAN              Volatile;\r
-} VARIABLE_POINTER_TRACK;\r
-\r
-typedef struct {\r
-  EFI_PHYSICAL_ADDRESS  VolatileVariableBase;\r
-  EFI_PHYSICAL_ADDRESS  NonVolatileVariableBase;\r
-  EFI_LOCK              VariableServicesLock;\r
-} VARIABLE_GLOBAL;\r
-\r
-typedef struct {\r
-  VARIABLE_GLOBAL VariableGlobal[2];\r
-  CHAR16          *VariableName[2][NUM_VAR_NAME];\r
-  EFI_GUID        *GlobalVariableGuid[2];\r
-  UINTN           VolatileLastVariableOffset;\r
-  UINTN           NonVolatileLastVariableOffset;\r
-  UINTN           CommonVariableTotalSize;\r
-  UINTN           HwErrVariableTotalSize;\r
-  CHAR8           *PlatformLangCodes[2];\r
-  CHAR8           *LangCodes[2];\r
-  CHAR8           *PlatformLang[2];\r
-  CHAR8           Lang[ISO_639_2_ENTRY_SIZE + 1];\r
-  UINT32          FvbInstance;\r
-  UINT32          ReentrantState;\r
-  EFI_GUID        *AuthenticatedVariableGuid[2];\r
-  EFI_GUID        *CertRsa2048Sha256Guid[2];\r
-  EFI_GUID        *ImageSecurityDatabaseGuid[2];\r
-  VOID            *HashContext[2];             // Hash context pointer\r
-  UINT8           KeyList[MAX_KEYDB_SIZE];     // Cached Platform Key list\r
-  UINT8           PubKeyStore[MAX_KEYDB_SIZE]; // Cached Public Key list\r
-} ESAL_VARIABLE_GLOBAL;\r
-\r
-typedef struct {\r
-  EFI_GUID    *Guid;\r
-  CHAR16      *Name;\r
-  UINT32      Attributes;\r
-  UINTN       DataSize;\r
-  VOID        *Data;\r
-} VARIABLE_CACHE_ENTRY;\r
-\r
-\r
-extern ESAL_VARIABLE_GLOBAL  *mVariableModuleGlobal;\r
-\r
-//\r
-// Functions\r
-//\r
-\r
-/**\r
-  Initializes variable store area for non-volatile and volatile variable.\r
-\r
-  This function allocates and initializes memory space for global context of ESAL\r
-  variable service and variable store area for non-volatile and volatile variable.\r
-\r
-  @param[in]  ImageHandle       The Image handle of this driver.\r
-  @param[in]  SystemTable       The pointer of EFI_SYSTEM_TABLE.\r
-\r
-  @retval EFI_SUCCESS           Function successfully executed.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed to allocate enough memory resource.\r
-\r
-**/\r
-EFI_STATUS\r
-VariableCommonInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  );\r
-\r
-/**\r
-  Entry point of Extended SAL Variable service module.\r
-\r
-  This function is the entry point of Extended SAL Variable service module.\r
-  It registers all functions of Extended SAL Variable class, initializes\r
-  variable store for non-volatile and volatile variables, and registers\r
-  notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
-\r
-  @param[in]  ImageHandle   The Image handle of this driver.\r
-  @param[in]  SystemTable   The pointer of EFI_SYSTEM_TABLE.\r
-\r
-  @retval     EFI_SUCCESS   Extended SAL Variable Services Class successfully registered.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VariableServiceInitialize (\r
-  IN EFI_HANDLE         ImageHandle,\r
-  IN EFI_SYSTEM_TABLE   *SystemTable\r
-  );\r
-\r
-/**\r
-  Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r
-\r
-  This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r
-  It convers pointer to new virtual address.\r
-\r
-  @param[in]  Event        The event whose notification function is being invoked.\r
-  @param[in]  Context      The pointer to the notification function's context.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VariableClassAddressChangeEvent (\r
-  IN EFI_EVENT        Event,\r
-  IN VOID             *Context\r
-  );\r
-\r
-/**\r
-  Implements EsalGetVariable function of Extended SAL Variable Services Class.\r
-\r
-  This function implements EsalGetVariable function of Extended SAL Variable Services Class.\r
-  It is equivalent in functionality to the EFI Runtime Service GetVariable().\r
-\r
-  @param[in]      VariableName    A Null-terminated Unicode string that is the name of\r
-                                  the vendor's variable.\r
-  @param[in]      VendorGuid      A unique identifier for the vendor.\r
-  @param[out]     Attributes      If not NULL, a pointer to the memory location to return the\r
-                                  attributes bitmask for the variable.\r
-  @param[in, out] DataSize        Size of Data found. If size is less than the\r
-                                  data, this value contains the required size.\r
-  @param[out]     Data            On input, the size in bytes of the return Data buffer.\r
-                                  On output, the size of data returned in Data.\r
-  @param[in]      VirtualMode     Current calling mode for this function.\r
-  @param[in]      Global          Context of this Extended SAL Variable Services Class call.\r
-\r
-  @retval EFI_SUCCESS            The function completed successfully.\r
-  @retval EFI_NOT_FOUND          The variable was not found.\r
-  @retval EFI_BUFFER_TOO_SMALL   DataSize is too small for the result.  DataSize has\r
-                                 been updated with the size needed to complete the request.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is NULL.\r
-  @retval EFI_INVALID_PARAMETER  VendorGuid is NULL.\r
-  @retval EFI_INVALID_PARAMETER  DataSize is NULL.\r
-  @retval EFI_INVALID_PARAMETER  DataSize is not too small and Data is NULL.\r
-  @retval EFI_DEVICE_ERROR       The variable could not be retrieved due to a hardware error.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EsalGetVariable (\r
-  IN      CHAR16                *VariableName,\r
-  IN      EFI_GUID              *VendorGuid,\r
-  OUT     UINT32                *Attributes OPTIONAL,\r
-  IN OUT  UINTN                 *DataSize,\r
-  OUT     VOID                  *Data,\r
-  IN      BOOLEAN               VirtualMode,\r
-  IN      ESAL_VARIABLE_GLOBAL  *Global\r
-  );\r
-\r
-/**\r
-  Implements EsalGetNextVariableName function of Extended SAL Variable Services Class.\r
-\r
-  This function implements EsalGetNextVariableName function of Extended SAL Variable Services Class.\r
-  It is equivalent in functionality to the EFI Runtime Service GetNextVariableName().\r
-\r
-  @param[in, out] VariableNameSize Size of the variable\r
-  @param[in, out] VariableName     On input, supplies the last VariableName that was returned by GetNextVariableName().\r
-                                   On output, returns the Null-terminated Unicode string of the current variable.\r
-  @param[in, out] VendorGuid       On input, supplies the last VendorGuid that was returned by GetNextVariableName().\r
-                                   On output, returns the VendorGuid of the current variable.\r
-  @param[in]      VirtualMode      Current calling mode for this function.\r
-  @param[in]      Global           Context of this Extended SAL Variable Services Class call.\r
-\r
-  @retval EFI_SUCCESS             The function completed successfully.\r
-  @retval EFI_NOT_FOUND           The next variable was not found.\r
-  @retval EFI_BUFFER_TOO_SMALL    VariableNameSize is too small for the result.\r
-                                  VariableNameSize has been updated with the size needed to complete the request.\r
-  @retval EFI_INVALID_PARAMETER   VariableNameSize is NULL.\r
-  @retval EFI_INVALID_PARAMETER   VariableName is NULL.\r
-  @retval EFI_INVALID_PARAMETER   VendorGuid is NULL.\r
-  @retval EFI_DEVICE_ERROR        The variable name could not be retrieved due to a hardware error.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EsalGetNextVariableName (\r
-  IN OUT  UINTN                 *VariableNameSize,\r
-  IN OUT  CHAR16                *VariableName,\r
-  IN OUT  EFI_GUID              *VendorGuid,\r
-  IN      BOOLEAN               VirtualMode,\r
-  IN      ESAL_VARIABLE_GLOBAL  *Global\r
-  );\r
-\r
-/**\r
-  Implements EsalSetVariable function of Extended SAL Variable Services Class.\r
-\r
-  This function implements EsalSetVariable function of Extended SAL Variable Services Class.\r
-  It is equivalent in functionality to the EFI Runtime Service SetVariable().\r
-\r
-  @param[in]  VariableName       A Null-terminated Unicode string that is the name of the vendor's\r
-                                 variable.  Each VariableName is unique for each\r
-                                 VendorGuid.  VariableName must contain 1 or more\r
-                                 Unicode characters.  If VariableName is an empty Unicode\r
-                                 string, then EFI_INVALID_PARAMETER is returned.\r
-  @param[in]  VendorGuid         A unique identifier for the vendor.\r
-  @param[in]  Attributes         Attributes bitmask to set for the variable.\r
-  @param[in]  DataSize           The size in bytes of the Data buffer.  A size of zero causes the\r
-                                 variable to be deleted.\r
-  @param[in]  Data               The contents for the variable.\r
-  @param[in]  VirtualMode        Current calling mode for this function.\r
-  @param[in]  Global             Context of this Extended SAL Variable Services Class call.\r
-\r
-  @retval EFI_SUCCESS            The firmware has successfully stored the variable and its data as\r
-                                 defined by the Attributes.\r
-  @retval EFI_INVALID_PARAMETER  An invalid combination of attribute bits was supplied, or the\r
-                                 DataSize exceeds the maximum allowed.\r
-  @retval EFI_INVALID_PARAMETER  VariableName is an empty Unicode string.\r
-  @retval EFI_OUT_OF_RESOURCES   Not enough storage is available to hold the variable and its data.\r
-  @retval EFI_DEVICE_ERROR       The variable could not be saved due to a hardware failure.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question is read-only.\r
-  @retval EFI_WRITE_PROTECTED    The variable in question cannot be deleted.\r
-  @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.\r
-  @retval EFI_NOT_FOUND          The variable trying to be updated or deleted was not found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EsalSetVariable (\r
-  IN CHAR16                  *VariableName,\r
-  IN EFI_GUID                *VendorGuid,\r
-  IN UINT32                  Attributes,\r
-  IN UINTN                   DataSize,\r
-  IN VOID                    *Data,\r
-  IN BOOLEAN                 VirtualMode,\r
-  IN ESAL_VARIABLE_GLOBAL    *Global\r
-  );\r
-\r
-/**\r
-  Implements EsalQueryVariableInfo function of Extended SAL Variable Services Class.\r
-\r
-  This function implements EsalQueryVariableInfo function of Extended SAL Variable Services Class.\r
-  It is equivalent in functionality to the EFI Runtime Service QueryVariableInfo().\r
-\r
-  @param[in]  Attributes                   Attributes bitmask to specify the type of variables\r
-                                           on which to return information.\r
-  @param[out] MaximumVariableStorageSize   On output the maximum size of the storage space available for\r
-                                           the EFI variables associated with the attributes specified.\r
-  @param[out] RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI\r
-                                           variables associated with the attributes specified.\r
-  @param[out] MaximumVariableSize          Returns the maximum size of an individual EFI variable\r
-                                           associated with the attributes specified.\r
-  @param[in]  VirtualMode                  Current calling mode for this function\r
-  @param[in]  Global                       Context of this Extended SAL Variable Services Class call\r
-\r
-  @retval EFI_SUCCESS                      Valid answer returned.\r
-  @retval EFI_INVALID_PARAMETER            An invalid combination of attribute bits was supplied.\r
-  @retval EFI_UNSUPPORTED                  The attribute is not supported on this platform, and the\r
-                                           MaximumVariableStorageSize, RemainingVariableStorageSize,\r
-                                           MaximumVariableSize are undefined.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EsalQueryVariableInfo (\r
-  IN  UINT32                 Attributes,\r
-  OUT UINT64                 *MaximumVariableStorageSize,\r
-  OUT UINT64                 *RemainingVariableStorageSize,\r
-  OUT UINT64                 *MaximumVariableSize,\r
-  IN  BOOLEAN                VirtualMode,\r
-  IN  ESAL_VARIABLE_GLOBAL   *Global\r
-  );\r
-\r
-/**\r
-  Writes a buffer to variable storage space.\r
-\r
-  This function writes a buffer to variable storage space into firmware\r
-  volume block device. The destination is specified by parameter\r
-  VariableBase. Fault Tolerant Write protocol is used for writing.\r
-\r
-  @param[in] VariableBase The base address of the variable to write.\r
-  @param[in] Buffer       Points to the data buffer.\r
-  @param[in] BufferSize   The number of bytes of the data Buffer.\r
-\r
-  @retval EFI_SUCCESS     The function completed successfully.\r
-  @retval EFI_NOT_FOUND   Fail to locate Fault Tolerant Write protocol.\r
-  @retval Other           The function could not complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-FtwVariableSpace (\r
-  IN EFI_PHYSICAL_ADDRESS   VariableBase,\r
-  IN UINT8                  *Buffer,\r
-  IN UINTN                  BufferSize\r
-  );\r
-\r
-/**\r
-  Finds variable in volatile and non-volatile storage areas.\r
-\r
-  This code finds variable in volatile and non-volatile storage areas.\r
-  If VariableName is an empty string, then we just return the first\r
-  qualified variable without comparing VariableName and VendorGuid.\r
-  Otherwise, VariableName and VendorGuid are compared.\r
-\r
-  @param[in]  VariableName            Name of the variable to be found.\r
-  @param[in]  VendorGuid              Vendor GUID to be found.\r
-  @param[out] PtrTrack                VARIABLE_POINTER_TRACK structure for output,\r
-                                      including the range searched and the target position.\r
-  @param[in]  Global                  Pointer to VARIABLE_GLOBAL structure, including\r
-                                      base of volatile variable storage area, base of\r
-                                      NV variable storage area, and a lock.\r
-  @param[in]  Instance                Instance of FV Block services.\r
-\r
-  @retval EFI_INVALID_PARAMETER       If VariableName is not an empty string, while\r
-                                      VendorGuid is NULL.\r
-  @retval EFI_SUCCESS                 Variable successfully found.\r
-  @retval EFI_INVALID_PARAMETER       Variable not found.\r
-\r
-**/\r
-EFI_STATUS\r
-FindVariable (\r
-  IN  CHAR16                  *VariableName,\r
-  IN  EFI_GUID                *VendorGuid,\r
-  OUT VARIABLE_POINTER_TRACK  *PtrTrack,\r
-  IN  VARIABLE_GLOBAL         *Global,\r
-  IN  UINTN                   Instance\r
-  );\r
-\r
-/**\r
-  Gets the pointer to variable data area.\r
-\r
-  This function gets the pointer to variable data area.\r
-  The variable is specified by its variable header.\r
-\r
-  @param[in]  VariableAddress    Start address of variable header.\r
-  @param[in]  Volatile           TRUE  - Variable is volatile.\r
-                                 FALSE - Variable is non-volatile.\r
-  @param[in]  Global             Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]  Instance           Instance of FV Block services.\r
-  @param[out] VariableData       Buffer to hold variable data for output.\r
-\r
-**/\r
-VOID\r
-GetVariableDataPtr (\r
-  IN  EFI_PHYSICAL_ADDRESS   VariableAddress,\r
-  IN  BOOLEAN                Volatile,\r
-  IN  VARIABLE_GLOBAL        *Global,\r
-  IN  UINTN                  Instance,\r
-  OUT CHAR16                 *VariableData\r
-  );\r
-\r
-/**\r
-  Gets the size of variable data area.\r
-\r
-  This function gets the size of variable data area.\r
-  The variable is specified by its variable header.\r
-  If variable header contains raw data, just return 0.\r
-\r
-  @param[in]  Variable  Pointer to the variable header.\r
-\r
-  @return               Size of variable data area in bytes.\r
-\r
-**/\r
-UINTN\r
-DataSizeOfVariable (\r
-  IN  AUTHENTICATED_VARIABLE_HEADER     *Variable\r
-  );\r
-\r
-/**\r
-  Update the variable region with Variable information. These are the same\r
-  arguments as the EFI Variable services.\r
-\r
-  @param[in] VariableName       Name of variable.\r
-  @param[in] VendorGuid         Guid of variable.\r
-  @param[in] Data               Variable data.\r
-  @param[in] DataSize           Size of data. 0 means delete.\r
-  @param[in] Attributes         Attributes of the variable.\r
-  @param[in] KeyIndex           Index of associated public key.\r
-  @param[in] MonotonicCount     Value of associated monotonic count.\r
-  @param[in] VirtualMode        Current calling mode for this function.\r
-  @param[in] Global             Context of this Extended SAL Variable Services Class call.\r
-  @param[in] Variable           The variable information which is used to keep track of variable usage.\r
-\r
-  @retval EFI_SUCCESS           The update operation is success.\r
-  @retval EFI_OUT_OF_RESOURCES  Variable region is full, can not write other data into this region.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UpdateVariable (\r
-  IN      CHAR16                  *VariableName,\r
-  IN      EFI_GUID                *VendorGuid,\r
-  IN      VOID                    *Data,\r
-  IN      UINTN                   DataSize,\r
-  IN      UINT32                  Attributes OPTIONAL,\r
-  IN      UINT32                  KeyIndex  OPTIONAL,\r
-  IN      UINT64                  MonotonicCount  OPTIONAL,\r
-  IN      BOOLEAN                 VirtualMode,\r
-  IN      ESAL_VARIABLE_GLOBAL    *Global,\r
-  IN      VARIABLE_POINTER_TRACK  *Variable\r
-  );\r
-\r
-/**\r
-  Checks variable header.\r
-\r
-  This function checks if variable header is valid or not.\r
-\r
-  @param[in]  VariableAddress    Start address of variable header.\r
-  @param[in]  Volatile           TRUE  - Variable is volatile.\r
-                                 FALSE - Variable is non-volatile.\r
-  @param[in]  Global             Pointer to VARAIBLE_GLOBAL structure.\r
-  @param[in]  Instance           Instance of FV Block services.\r
-  @param[out] VariableHeader     Pointer to AUTHENTICATED_VARIABLE_HEADER for output.\r
-\r
-  @retval TRUE                   Variable header is valid.\r
-  @retval FALSE                  Variable header is not valid.\r
-\r
-**/\r
-BOOLEAN\r
-IsValidVariableHeader (\r
-  IN  EFI_PHYSICAL_ADDRESS              VariableAddress,\r
-  IN  BOOLEAN                           Volatile,\r
-  IN  VARIABLE_GLOBAL                   *Global,\r
-  IN  UINTN                             Instance,\r
-  OUT AUTHENTICATED_VARIABLE_HEADER     *VariableHeader  OPTIONAL\r
-  );\r
-\r
-/**\r
-  Flush the HOB variable to NV variable storage.\r
-**/\r
-VOID\r
-FlushHob2Nv (\r
-  VOID\r
-  );\r
-\r
-#endif\r
index fa7c39d6e58b9c86a10f7bec1d6ecc5cce243861..487fc8cda917678e1892c8eab41d17238cf897c9 100644 (file)
@@ -2,7 +2,7 @@
 #  Provides the capbility to configure secure boot in a setup browser\r
 #  By this module, user may change the content of DB, DBX, PK and KEK.\r
 #\r
-# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, 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
@@ -23,7 +23,7 @@
   UNLOAD_IMAGE                   = SecureBootConfigDriverUnload\r
 \r
 #\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
 #\r
 \r
 [Sources]\r