This commit defines VARIABLE_RUNTIME_CACHE_INFO HOB.
The HOB is used to store the address and size of the
buffer that will be used for variable runtime service
when the PcdEnableVariableRuntimeCache is TRUE.

In following patches, when PcdEnableVariableRuntimeCache
is TRUE, VariablePei module will install a callback of
gEfiPeiMemoryDiscoveredPpiGuid to allocate needed buffer
for different type cache, unblock the buffer and build HOB.
Then VariableSmmRuntimeDxe driver will consume the
gEdkiiVariableRuntimeCacheInfoHobGuid to initialize the
variable runtime cache related content.

Signed-off-by: Dun Tan <dun....@intel.com>
Cc: Ray Ni <ray...@intel.com>
Cc: Liming Gao <gaolim...@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin...@intel.com>
---
 MdeModulePkg/Include/Guid/VariableRuntimeCacheInfo.h | 65 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 MdeModulePkg/MdeModulePkg.dec                        |  3 +++
 2 files changed, 68 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/VariableRuntimeCacheInfo.h 
b/MdeModulePkg/Include/Guid/VariableRuntimeCacheInfo.h
new file mode 100644
index 0000000000..c2a8b77945
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/VariableRuntimeCacheInfo.h
@@ -0,0 +1,65 @@
+/** @file
+  This Variable Runtime Cache Info HOB is used to store the address
+  and the size of the buffer that will be used for variable runtime
+  service when the PcdEnableVariableRuntimeCache is TRUE.
+
+  Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef VARIABLE_RUNTIME_CACHE_INFO_H_
+#define VARIABLE_RUNTIME_CACHE_INFO_H_
+
+#include <PiPei.h>
+
+#define VARIABLE_RUNTIME_CACHE_INFO_HOB_REVISION  1
+
+#define VARIABLE_RUNTIME_CACHE_INFO_GUID \
+  { \
+    0x0f472f7d, 0x6713, 0x4915, {0x96, 0x14, 0x5d, 0xda, 0x28, 0x40, 0x10, 
0x56}  \
+  }
+
+#pragma pack(1)
+typedef struct {
+  ///
+  /// TRUE indicates GetVariable () or GetNextVariable () is being called.
+  /// When the value is FALSE, the given update (and any other pending updates)
+  /// can be flushed to the runtime cache.
+  ///
+  BOOLEAN    ReadLock;
+  ///
+  /// TRUE indicates there is pending update for the given variable store 
needed
+  /// to be flushed to the runtime cache.
+  ///
+  BOOLEAN    PendingUpdate;
+  ///
+  /// TRUE indicates all HOB variables have been flushed in flash.
+  ///
+  BOOLEAN    HobFlushComplete;
+} CACHE_INFO_FLAG;
+
+typedef struct {
+  CACHE_INFO_FLAG    *CacheInfoFlag;
+  ///
+  /// Buffer reserved for runtime Hob cache
+  ///
+  UINT64             RuntimeHobCacheBuffer;
+  UINTN              RuntimeHobCachePages;
+  ///
+  /// Buffer reserved for Non-Volatile runtime cache
+  ///
+  UINT64             RuntimeNvCacheBuffer;
+  UINTN              RuntimeNvCachePages;
+  ///
+  /// Buffer reserved for Volatile runtime cache
+  ///
+  UINT64             RuntimeVolatileCacheBuffer;
+  UINTN              RuntimeVolatileCachePages;
+} VARIABLE_RUNTIME_CACHE_INFO;
+#pragma pack()
+
+extern EFI_GUID  gEdkiiVariableRuntimeCacheInfoHobGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index f7339f0aec..1bf5e31b7c 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -465,6 +465,9 @@
   gEdk2JedecSfdpSpiDxeDriverGuid  = { 0xBE71701E, 0xB63C, 0x4574, { 0x9C, 
0x5C, 0x36, 0x29, 0xE8, 0xEA, 0xC4, 0x14 }}
   gEdk2JedecSfdpSpiSmmDriverGuid  = { 0x95A1E915, 0x195C, 0x477C, { 0x92, 
0x6F, 0x7E, 0x24, 0x67, 0xC1, 0xB3, 0x1F }}
 
+  ## Include/Guid/VariableRuntimeCacheInfo.h
+  gEdkiiVariableRuntimeCacheInfoHobGuid = { 0x0f472f7d, 0x6713, 0x4915, { 
0x96, 0x14, 0x5d, 0xda, 0x28, 0x40, 0x10, 0x56 }}
+
 [Ppis]
   ## Include/Ppi/FirmwareVolumeShadowPpi.h
   gEdkiiPeiFirmwareVolumeShadowPpiGuid = { 0x7dfe756c, 0xed8d, 0x4d77, {0x9e, 
0xc4, 0x39, 0x9a, 0x8a, 0x81, 0x51, 0x16 } }
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119018): https://edk2.groups.io/g/devel/message/119018
Mute This Topic: https://groups.io/mt/106150797/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to