# @Prompt Maximum authenticated variable size.\r
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x00|UINT32|0x30000009\r
\r
+ ## The maximum size of a single non-authenticated volatile variable.\r
+ # The default value is 0 for compatibility: in that case, the maximum\r
+ # non-authenticated volatile variable size remains specified by\r
+ # PcdMaxVariableSize. Only the MdeModulePkg/Universal/Variable/RuntimeDxe\r
+ # driver supports this PCD.\r
+ # @Prompt Maximum non-authenticated volatile variable size.\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize|0x00|UINT32|0x3000000a\r
+\r
## The maximum size of single hardware error record variable.<BR><BR>\r
# In IA32/X64 platforms, this value should be larger than 1KB.<BR>\r
# In IA64 platforms, this value should be larger than 128KB.<BR>\r
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxAuthVariableSize_HELP #language en-US "The maximum size of a single authenticated variable."\r
"The value is 0 as default for compatibility that maximum authenticated variable size is specified by PcdMaxVariableSize."\r
\r
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxVolatileVariableSize_PROMPT #language en-US "The maximum size of a single non-authenticated volatile variable."\r
+\r
+#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxVolatileVariableSize_HELP #language en-US "The maximum size of a single non-authenticated volatile variable.<BR><BR>\n"\r
+ "The default value is 0 for compatibility: in that case, the maximum "\r
+ "non-authenticated volatile variable size remains specified by "\r
+ "PcdMaxVariableSize.<BR>\n"\r
+ "Only the MdeModulePkg/Universal/Variable/RuntimeDxe driver supports this PCD.<BR>"\r
+\r
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxHardwareErrorVariableSize_PROMPT #language en-US "Maximum HwErr variable size"\r
\r
#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdMaxHardwareErrorVariableSize_HELP #language en-US "The maximum size of single hardware error record variable.<BR><BR>\n"\r
CopyMem (BufferForMerge, (UINT8 *) ((UINTN) CacheVariable->CurrPtr + DataOffset), DataSizeOfVariable (CacheVariable->CurrPtr));\r
\r
//\r
- // Set Max Common/Auth Variable Data Size as default MaxDataSize.\r
+ // Set Max Auth/Non-Volatile/Volatile Variable Data Size as default MaxDataSize.\r
//\r
if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) {\r
MaxDataSize = mVariableModuleGlobal->MaxAuthVariableSize - DataOffset;\r
- } else {\r
+ } else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
MaxDataSize = mVariableModuleGlobal->MaxVariableSize - DataOffset;\r
+ } else {\r
+ MaxDataSize = mVariableModuleGlobal->MaxVolatileVariableSize - DataOffset;\r
}\r
\r
//\r
} else {\r
//\r
// The size of the VariableName, including the Unicode Null in bytes plus\r
- // the DataSize is limited to maximum size of Max(Auth)VariableSize bytes.\r
+ // the DataSize is limited to maximum size of Max(Auth|Volatile)VariableSize bytes.\r
//\r
if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) {\r
if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->MaxAuthVariableSize - GetVariableHeaderSize ()) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- } else {\r
+ } else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->MaxVariableSize - GetVariableHeaderSize ()) {\r
return EFI_INVALID_PARAMETER;\r
}\r
+ } else {\r
+ if (StrSize (VariableName) + PayloadSize > mVariableModuleGlobal->MaxVolatileVariableSize - GetVariableHeaderSize ()) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
}\r
}\r
\r
}\r
\r
//\r
- // Let *MaximumVariableSize be Max(Auth)VariableSize with the exception of the variable header size.\r
+ // Let *MaximumVariableSize be Max(Auth|Volatile)VariableSize with the exception of the variable header size.\r
//\r
if ((Attributes & VARIABLE_ATTRIBUTE_AT_AW) != 0) {\r
*MaximumVariableSize = mVariableModuleGlobal->MaxAuthVariableSize - GetVariableHeaderSize ();\r
- } else {\r
+ } else if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
*MaximumVariableSize = mVariableModuleGlobal->MaxVariableSize - GetVariableHeaderSize ();\r
+ } else {\r
+ *MaximumVariableSize = mVariableModuleGlobal->MaxVolatileVariableSize - GetVariableHeaderSize ();\r
}\r
}\r
\r
}\r
}\r
\r
+/**\r
+ Get maximum variable size, covering both non-volatile and volatile variables.\r
+\r
+ @return Maximum variable size.\r
+\r
+**/\r
+UINTN\r
+GetMaxVariableSize (\r
+ VOID\r
+ )\r
+{\r
+ UINTN MaxVariableSize;\r
+\r
+ MaxVariableSize = GetNonVolatileMaxVariableSize();\r
+ //\r
+ // The condition below fails implicitly if PcdMaxVolatileVariableSize equals\r
+ // the default zero value.\r
+ //\r
+ if (MaxVariableSize < PcdGet32 (PcdMaxVolatileVariableSize)) {\r
+ MaxVariableSize = PcdGet32 (PcdMaxVolatileVariableSize);\r
+ }\r
+ return MaxVariableSize;\r
+}\r
+\r
/**\r
Init non-volatile variable store.\r
\r
}\r
}\r
\r
+ mVariableModuleGlobal->MaxVolatileVariableSize = ((PcdGet32 (PcdMaxVolatileVariableSize) != 0) ?\r
+ PcdGet32 (PcdMaxVolatileVariableSize) :\r
+ mVariableModuleGlobal->MaxVariableSize\r
+ );\r
//\r
// Allocate memory for volatile variable store, note that there is a scratch space to store scratch data.\r
//\r
- ScratchSize = GetNonVolatileMaxVariableSize ();\r
+ ScratchSize = GetMaxVariableSize ();\r
mVariableModuleGlobal->ScratchBufferSize = ScratchSize;\r
VolatileVariableStore = AllocateRuntimePool (PcdGet32 (PcdVariableStoreSize) + ScratchSize);\r
if (VolatileVariableStore == NULL) {\r