/*++\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2010, 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
@param[in] DataSize Size of data. 0 means delete\r
\r
- @param[in] Attributes Attribues of the variable\r
+ @param[in] Attributes Attribues of the variable\r
\r
@param[in] Variable The variable information which is used to keep track of variable usage.\r
\r
// Therefore, in variable driver, only store the original value for other use.\r
//\r
AsciiStrnCpy (mGlobal->LangCodes, Data, DataSize);\r
- } else if (StrCmp (VariableName, L"PlatformLang") == 0) {\r
+ } else if ((StrCmp (VariableName, L"PlatformLang") == 0) && (DataSize != 0)) {\r
ASSERT (AsciiStrLen (mGlobal->PlatformLangCodes) != 0);\r
\r
//\r
\r
ASSERT_EFI_ERROR(Status);\r
\r
- } else if (StrCmp (VariableName, L"Lang") == 0) {\r
+ } else if ((StrCmp (VariableName, L"Lang") == 0) && (DataSize != 0)) {\r
ASSERT (AsciiStrLen (mGlobal->LangCodes) != 0);\r
\r
//\r
FindVariable(L"PlatformLang", &gEfiGlobalVariableGuid, &Variable);\r
\r
Status = UpdateVariable(L"PlatformLang", &gEfiGlobalVariableGuid, \r
- BestPlatformLang, AsciiStrLen (BestPlatformLang), Attributes, &Variable);\r
+ BestPlatformLang, AsciiStrSize (BestPlatformLang), Attributes, &Variable);\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
@param[in] DataSize Size of data. 0 means delete\r
\r
- @param[in] Attributes Attribues of the variable\r
+ @param[in] Attributes Attribues of the variable\r
\r
@param[in] Variable The variable information which is used to keep track of variable usage.\r
\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
+ if (DataSize != 0 && Data == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Not support authenticated variable write yet.\r
+ //\r
+ if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
//\r
// Make sure if runtime bit is set, boot service bit is set also\r
//\r
\r
//\r
// The size of the VariableName, including the Unicode Null in bytes plus\r
- // the DataSize is limited to maximum size of FixedPcdGet32(PcdMaxHardwareErrorVariableSize)\r
- // bytes for HwErrRec, and FixedPcdGet32(PcdMaxVariableSize) bytes for the others.\r
+ // the DataSize is limited to maximum size of PcdGet32 (PcdMaxHardwareErrorVariableSize)\r
+ // bytes for HwErrRec, and PcdGet32 (PcdMaxVariableSize) bytes for the others.\r
//\r
if ((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD) {\r
- if ((DataSize > FixedPcdGet32(PcdMaxHardwareErrorVariableSize)) || \r
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > FixedPcdGet32(PcdMaxHardwareErrorVariableSize))) {\r
+ if ((DataSize > PcdGet32(PcdMaxHardwareErrorVariableSize)) || \r
+ (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32(PcdMaxHardwareErrorVariableSize))) {\r
return EFI_INVALID_PARAMETER;\r
}\r
//\r
return EFI_INVALID_PARAMETER;\r
}\r
} else {\r
- if ((DataSize > FixedPcdGet32(PcdMaxVariableSize)) ||\r
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > FixedPcdGet32(PcdMaxVariableSize))) {\r
+ if ((DataSize > PcdGet32(PcdMaxVariableSize)) ||\r
+ (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32(PcdMaxVariableSize))) {\r
return EFI_INVALID_PARAMETER;\r
} \r
} \r
// Make sure the Attributes combination is supported by the platform.\r
//\r
return EFI_UNSUPPORTED; \r
- } \r
- else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS) {\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
// Make sure Hw Attribute is set with NV.\r
//\r
return EFI_INVALID_PARAMETER;\r
+ } else if ((Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {\r
+ //\r
+ // Not support authentiated variable write yet.\r
+ //\r
+ return EFI_UNSUPPORTED;\r
}\r
\r
VariableStoreHeader = (VARIABLE_STORE_HEADER *) mGlobal->VariableBase[\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 = FixedPcdGet32(PcdHwErrStorageSize);\r
- *MaximumVariableSize = FixedPcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER);\r
+ *MaximumVariableStorageSize = PcdGet32(PcdHwErrStorageSize);\r
+ *MaximumVariableSize = PcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (VARIABLE_HEADER);\r
} else {\r
if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {\r
- ASSERT (FixedPcdGet32(PcdHwErrStorageSize) < VariableStoreHeader->Size);\r
- *MaximumVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER) - FixedPcdGet32(PcdHwErrStorageSize);\r
+ ASSERT (PcdGet32(PcdHwErrStorageSize) < VariableStoreHeader->Size);\r
+ *MaximumVariableStorageSize = VariableStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER) - PcdGet32(PcdHwErrStorageSize);\r
}\r
\r
//\r
- // Let *MaximumVariableSize be FixedPcdGet32(PcdMaxVariableSize) with the exception of the variable header size.\r
+ // Let *MaximumVariableSize be PcdGet32(PcdMaxVariableSize) with the exception of the variable header size.\r
//\r
- *MaximumVariableSize = FixedPcdGet32(PcdMaxVariableSize) - sizeof (VARIABLE_HEADER);\r
+ *MaximumVariableSize = PcdGet32(PcdMaxVariableSize) - sizeof (VARIABLE_HEADER);\r
}\r
\r
//\r