/** @file\r
The implementation of Extended SAL variable services.\r
\r
-Copyright (c) 2009 - 2011, 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
+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
+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
if ((StartAddress + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + VolatileBase->Size))) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- \r
+\r
//\r
// For volatile variable, a simple memory copy is enough.\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
+ GetPhysicalAddressFunctionId,\r
+ Instance,\r
+ (UINT64) &FvVolHdr,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
0\r
).Status;\r
ASSERT_EFI_ERROR (Status);\r
if ((StartAddress + DataSize) > ((EFI_PHYSICAL_ADDRESS) (UINTN) ((CHAR8 *)VariableStoreHeader + VariableStoreHeader->Size))) {\r
return EFI_INVALID_PARAMETER;\r
}\r
- \r
+\r
LinearOffset = (UINTN) FwVolHeader;\r
CurrWritePtr = StartAddress;\r
CurrWriteSize = DataSize;\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
+ 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
+ ReadFunctionId,\r
+ Instance,\r
+ LbaNumber,\r
+ (CurrWritePtr - LinearOffset),\r
+ (UINT64) &CurrWriteSize,\r
+ (UINT64) CurrBuffer,\r
+ 0,\r
0\r
).Status;\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
- WriteFunctionId, \r
- Instance, \r
- LbaNumber, \r
- (CurrWritePtr - LinearOffset), \r
- (UINT64) &Size, \r
- (UINT64) CurrBuffer, \r
- 0, \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
+ ReadFunctionId,\r
+ Instance,\r
+ LbaNumber,\r
+ (CurrWritePtr - LinearOffset),\r
+ (UINT64) &Size,\r
+ (UINT64) CurrBuffer,\r
+ 0,\r
0\r
).Status;\r
}\r
Instance,\r
VarStoreAddress,\r
sizeof (VARIABLE_STORE_HEADER),\r
- VarStoreHeader \r
+ VarStoreHeader\r
);\r
ASSERT_EFI_ERROR (Status);\r
}\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 VARIABLE_HEADER for output.\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
BOOLEAN\r
IsValidVariableHeader (\r
- IN EFI_PHYSICAL_ADDRESS VariableAddress,\r
- IN BOOLEAN Volatile,\r
- IN VARIABLE_GLOBAL *Global,\r
- IN UINTN Instance,\r
- OUT VARIABLE_HEADER *VariableHeader OPTIONAL\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
- VARIABLE_HEADER LocalVariableHeader;\r
+ EFI_STATUS Status;\r
+ AUTHENTICATED_VARIABLE_HEADER LocalVariableHeader;\r
\r
Status = AccessVariableStore (\r
FALSE,\r
Volatile,\r
Instance,\r
VariableAddress,\r
- sizeof (VARIABLE_HEADER),\r
- &LocalVariableHeader \r
+ sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
+ &LocalVariableHeader\r
);\r
\r
if (EFI_ERROR (Status) || LocalVariableHeader.StartId != VARIABLE_DATA) {\r
}\r
\r
if (VariableHeader != NULL) {\r
- CopyMem (VariableHeader, &LocalVariableHeader, sizeof (VARIABLE_HEADER));\r
+ CopyMem (VariableHeader, &LocalVariableHeader, sizeof (AUTHENTICATED_VARIABLE_HEADER));\r
}\r
\r
return TRUE;\r
**/\r
UINTN\r
NameSizeOfVariable (\r
- IN VARIABLE_HEADER *Variable\r
+ IN AUTHENTICATED_VARIABLE_HEADER *Variable\r
)\r
{\r
if (Variable->State == (UINT8) (-1) ||\r
**/\r
UINTN\r
DataSizeOfVariable (\r
- IN VARIABLE_HEADER *Variable\r
+ IN AUTHENTICATED_VARIABLE_HEADER *Variable\r
)\r
{\r
if (Variable->State == (UINT8) -1 ||\r
OUT CHAR16 *VariableName\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_PHYSICAL_ADDRESS Address;\r
- VARIABLE_HEADER VariableHeader;\r
- BOOLEAN IsValid;\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
// Name area follows variable header.\r
//\r
- Address = VariableAddress + sizeof (VARIABLE_HEADER);\r
+ Address = VariableAddress + sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
\r
Status = AccessVariableStore (\r
FALSE,\r
Instance,\r
Address,\r
VariableHeader.NameSize,\r
- VariableName \r
+ VariableName\r
);\r
ASSERT_EFI_ERROR (Status);\r
}\r
OUT CHAR16 *VariableData\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_PHYSICAL_ADDRESS Address;\r
- VARIABLE_HEADER VariableHeader;\r
- BOOLEAN IsValid;\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
// Data area follows variable name.\r
// Be careful about pad size for alignment\r
//\r
- Address = VariableAddress + sizeof (VARIABLE_HEADER);\r
+ Address = VariableAddress + sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
Address += NameSizeOfVariable (&VariableHeader);\r
Address += GET_PAD_SIZE (NameSizeOfVariable (&VariableHeader));\r
\r
Instance,\r
Address,\r
VariableHeader.DataSize,\r
- VariableData \r
+ VariableData\r
);\r
ASSERT_EFI_ERROR (Status);\r
}\r
IN UINTN Instance\r
)\r
{\r
- EFI_PHYSICAL_ADDRESS Address;\r
- VARIABLE_HEADER VariableHeader;\r
+ EFI_PHYSICAL_ADDRESS Address;\r
+ AUTHENTICATED_VARIABLE_HEADER VariableHeader;\r
\r
if (!IsValidVariableHeader (VariableAddress, Volatile, Global, Instance, &VariableHeader)) {\r
return 0x0;\r
//\r
// Header of next variable follows data area of this variable\r
//\r
- Address = VariableAddress + sizeof (VARIABLE_HEADER);\r
+ Address = VariableAddress + sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
Address += NameSizeOfVariable (&VariableHeader);\r
Address += GET_PAD_SIZE (NameSizeOfVariable (&VariableHeader));\r
Address += DataSizeOfVariable (&VariableHeader);\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
+ 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
Instance,\r
VarStoreHeaderAddress,\r
sizeof (VARIABLE_STORE_HEADER),\r
- &VariableStoreHeader \r
+ &VariableStoreHeader\r
);\r
\r
ASSERT_EFI_ERROR (Status);\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
+ 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
+ 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
+ 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
CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);\r
gVariableInfo->Name = AllocatePool (StrSize (VariableName));\r
ASSERT (gVariableInfo->Name != NULL);\r
- StrCpy (gVariableInfo->Name, VariableName);\r
+ StrCpyS (gVariableInfo->Name, StrSize (VariableName) / sizeof (CHAR16), VariableName);\r
gVariableInfo->Volatile = Volatile;\r
\r
gBS->InstallConfigurationTable (&gEfiAuthenticatedVariableGuid, gVariableInfo);\r
}\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
CopyGuid (&Entry->Next->VendorGuid, VendorGuid);\r
Entry->Next->Name = AllocatePool (StrSize (VariableName));\r
ASSERT (Entry->Next->Name != NULL);\r
- StrCpy (Entry->Next->Name, VariableName);\r
+ StrCpyS (Entry->Next->Name, StrSize (VariableName) / sizeof (CHAR16), VariableName);\r
Entry->Next->Volatile = Volatile;\r
}\r
\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 (StrCmp (VariableName, Entry->Name) == 0) {\r
Entry->Attributes = Attributes;\r
if (DataSize == 0) {\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
return EFI_NOT_FOUND;\r
}\r
\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
- VARIABLE_HEADER VariableHeader;\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
Volatile = FALSE;\r
}\r
while (IsValidVariableHeader (Variable[Index], Volatile, Global, Instance, &VariableHeader)) {\r
- if (VariableHeader.State == VAR_ADDED || \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
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
- VARIABLE_HEADER VariableHeader;\r
- 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
+ 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
// Collect VAR_ADDED variables, and variables in delete transition status.\r
//\r
- if (VariableHeader.State == VAR_ADDED || \r
+ if (VariableHeader.State == VAR_ADDED ||\r
VariableHeader.State == (VAR_IN_DELETED_TRANSITION & VAR_ADDED)\r
) {\r
VariableSize = NextVariable - Variable;\r
}\r
\r
//\r
- // Reserve the 1 Bytes with Oxff to identify the \r
- // end of the variable buffer. \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
\r
//\r
// Reinstall all ADDED variables\r
- // \r
+ //\r
Variable = GetStartPointer (VariableBase);\r
while (IsValidVariableHeader (Variable, IsVolatile, VariableGlobal, Instance, &VariableHeader)) {\r
NextVariable = GetNextVariablePtr (Variable, IsVolatile, VariableGlobal, Instance);\r
VariableSize = NextVariable - Variable;\r
CopyMem (CurrPtr, (UINT8 *) Variable, VariableSize);\r
CurrPtr += VariableSize;\r
- if ((!IsVolatile) && ((((VARIABLE_HEADER*)Variable)->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\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) && ((((VARIABLE_HEADER*)Variable)->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\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
//\r
// Reinstall in delete transition variables\r
- // \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
+ // 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
+ // 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
// 1. No valid instance of this variable exists.\r
// 2. It is not the variable that is going to be updated.\r
//\r
- ((VARIABLE_HEADER *) CurrPtr)->State = VAR_ADDED;\r
+ ((AUTHENTICATED_VARIABLE_HEADER *) CurrPtr)->State = VAR_ADDED;\r
}\r
CurrPtr += VariableSize;\r
- if ((!IsVolatile) && ((((VARIABLE_HEADER*)Variable)->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) == EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\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) && ((((VARIABLE_HEADER*)Variable)->Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\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
IN CHAR8 *SupportedLang,\r
IN CHAR8 *Lang,\r
IN BOOLEAN Iso639Language\r
- ) \r
+ )\r
{\r
UINTN Index;\r
UINTN CompareLength;\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
+\r
+ if ((CompareLength == LanguageLength) &&\r
(AsciiStrnCmp (Lang, SupportedLang, CompareLength) == 0)) {\r
//\r
// Successfully find the index of Lang string in SupportedLang string.\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
+ 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
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
+ 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
+ @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
+ 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
+ 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
+ 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
+ @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
+ @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 CONST CHAR8 *SupportedLanguages,\r
IN BOOLEAN Iso639Language,\r
IN BOOLEAN VirtualMode,\r
...\r
LanguageLength = 0;\r
} else {\r
//\r
- // If RFC 4646 mode, then trim Language from the right to the next '-' character \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
VA_END (Args);\r
\r
//\r
- // No matches were found \r
+ // No matches were found\r
//\r
return NULL;\r
}\r
FreePool (Global->PlatformLangCodes[VirtualMode]);\r
}\r
Global->PlatformLangCodes[VirtualMode] = AllocateRuntimeCopyPool (DataSize, Data);\r
- ASSERT (mVariableModuleGlobal->PlatformLangCodes[VirtualMode] != NULL);\r
+ ASSERT (Global->PlatformLangCodes[VirtualMode] != NULL);\r
\r
//\r
- // PlatformLang holds a single language from PlatformLangCodes, \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
ASSERT (Global->LangCodes[VirtualMode] != NULL);\r
}\r
\r
- if (SetLanguageCodes \r
+ if (SetLanguageCodes\r
&& (Global->PlatformLangCodes[VirtualMode] != NULL)\r
&& (Global->LangCodes[VirtualMode] != NULL)) {\r
//\r
VariableGlobal,\r
Variable.Volatile,\r
Instance,\r
- (UINTN) &(((VARIABLE_HEADER *)Variable.CurrPtr)->DataSize),\r
+ (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable.CurrPtr)->DataSize),\r
sizeof (DataSize),\r
&DataSize\r
- ); \r
+ );\r
ASSERT_EFI_ERROR (Status);\r
}\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
+ PredefinedVariableName[VAR_PLATFORM_LANG],\r
+ Global->GlobalVariableGuid[VirtualMode],\r
+ BestPlatformLang,\r
+ AsciiStrSize (BestPlatformLang),\r
+ Attributes,\r
0,\r
0,\r
- VirtualMode, \r
- Global, \r
+ VirtualMode,\r
+ Global,\r
&Variable\r
);\r
\r
}\r
\r
/**\r
- Update the variable region with Variable information. These are the same \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] 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] 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
IN EFI_GUID *VendorGuid,\r
IN VOID *Data,\r
IN UINTN DataSize,\r
- IN UINT32 Attributes OPTIONAL, \r
+ IN UINT32 Attributes OPTIONAL,\r
IN UINT32 KeyIndex OPTIONAL,\r
IN UINT64 MonotonicCount OPTIONAL,\r
IN BOOLEAN VirtualMode,\r
)\r
{\r
EFI_STATUS Status;\r
- VARIABLE_HEADER *NextVariable;\r
+ AUTHENTICATED_VARIABLE_HEADER *NextVariable;\r
UINTN VarNameOffset;\r
UINTN VarDataOffset;\r
UINTN VarNameSize;\r
UINTN VarSize;\r
BOOLEAN Volatile;\r
UINT8 State;\r
- VARIABLE_HEADER VariableHeader;\r
- VARIABLE_HEADER *NextVariableHeader;\r
+ AUTHENTICATED_VARIABLE_HEADER VariableHeader;\r
+ AUTHENTICATED_VARIABLE_HEADER *NextVariableHeader;\r
BOOLEAN Valid;\r
BOOLEAN Reclaimed;\r
VARIABLE_STORE_HEADER VariableStoreHeader;\r
// Update/Delete existing variable\r
//\r
Volatile = Variable->Volatile;\r
- \r
- if (EfiAtRuntime ()) { \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
+ // 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
//\r
if ((VariableHeader.Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {\r
Status = EFI_INVALID_PARAMETER;\r
- goto Done; \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
+ if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {\r
State = VariableHeader.State;\r
State &= VAR_DELETED;\r
\r
VariableGlobal,\r
Variable->Volatile,\r
Instance,\r
- (UINTN) &(((VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
+ (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
sizeof (UINT8),\r
&State\r
- ); \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
+ goto Done;\r
}\r
//\r
// Logic comes here to update variable.\r
// then return to the caller immediately.\r
//\r
if (DataSizeOfVariable (&VariableHeader) == DataSize) {\r
- NextVariable = (VARIABLE_HEADER *)GetEndPointer (VariableGlobal->VolatileVariableBase, TRUE, VariableGlobal, Instance);\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
VariableGlobal,\r
Variable->Volatile,\r
Instance,\r
- (UINTN) &(((VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
+ (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
sizeof (UINT8),\r
&State\r
- ); \r
+ );\r
if (EFI_ERROR (Status)) {\r
- goto Done; \r
+ goto Done;\r
}\r
- } \r
+ }\r
} else {\r
//\r
// Create a new variable\r
- // \r
- \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
+ // 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
//\r
// Only variable have NV|RT attribute can be created in Runtime\r
//\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
//\r
// Tricky part: Use scratch data area at the end of volatile variable store\r
// as a temporary storage.\r
//\r
- NextVariable = (VARIABLE_HEADER *)GetEndPointer (VariableGlobal->VolatileVariableBase, TRUE, VariableGlobal, Instance);\r
+ NextVariable = (AUTHENTICATED_VARIABLE_HEADER *)GetEndPointer (VariableGlobal->VolatileVariableBase, TRUE, VariableGlobal, Instance);\r
ScratchSize = MAX (PcdGet32 (PcdMaxVariableSize), PcdGet32 (PcdMaxHardwareErrorVariableSize));\r
- NextVariableHeader = (VARIABLE_HEADER *) NextVariable;\r
+ NextVariableHeader = (AUTHENTICATED_VARIABLE_HEADER *) NextVariable;\r
\r
SetMem (NextVariableHeader, ScratchSize, 0xff);\r
\r
NextVariableHeader->PubKeyIndex = KeyIndex;\r
NextVariableHeader->MonotonicCount = MonotonicCount;\r
NextVariableHeader->Reserved = 0;\r
- VarNameOffset = sizeof (VARIABLE_HEADER);\r
+ VarNameOffset = sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
VarNameSize = StrSize (VariableName);\r
CopyMem (\r
(UINT8 *) ((UINTN)NextVariable + VarNameOffset),\r
// Create a nonvolatile variable\r
//\r
Volatile = FALSE;\r
- \r
+\r
GetVarStoreHeader (VariableGlobal->NonVolatileVariableBase, FALSE, VariableGlobal, Instance, &VariableStoreHeader);\r
- if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) \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
+ || (((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
//\r
// If still no enough space, return out of resources\r
//\r
- if ((((Attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) != 0) \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
+ || (((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
// Four steps\r
// 1. Write variable header\r
- // 2. Set variable state to header valid \r
+ // 2. Set variable state to header valid\r
// 3. Write variable data\r
// 4. Set variable state to valid\r
//\r
FALSE,\r
Instance,\r
VariableGlobal->NonVolatileVariableBase + Global->NonVolatileLastVariableOffset,\r
- sizeof (VARIABLE_HEADER),\r
+ sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
(UINT8 *) NextVariable\r
);\r
\r
FALSE,\r
Instance,\r
VariableGlobal->NonVolatileVariableBase + Global->NonVolatileLastVariableOffset,\r
- sizeof (VARIABLE_HEADER),\r
+ sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
(UINT8 *) NextVariable\r
);\r
\r
VariableGlobal,\r
FALSE,\r
Instance,\r
- VariableGlobal->NonVolatileVariableBase + Global->NonVolatileLastVariableOffset + sizeof (VARIABLE_HEADER),\r
- (UINT32) VarSize - sizeof (VARIABLE_HEADER),\r
- (UINT8 *) NextVariable + sizeof (VARIABLE_HEADER)\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
FALSE,\r
Instance,\r
VariableGlobal->NonVolatileVariableBase + Global->NonVolatileLastVariableOffset,\r
- sizeof (VARIABLE_HEADER),\r
+ sizeof (AUTHENTICATED_VARIABLE_HEADER),\r
(UINT8 *) NextVariable\r
);\r
\r
} else {\r
//\r
// Create a volatile variable\r
- // \r
+ //\r
Volatile = TRUE;\r
\r
if ((UINT32) (HEADER_ALIGN(VarSize) + Global->VolatileLastVariableOffset) >\r
// has already been eliminated, so no need to delete it.\r
//\r
if (!Reclaimed && !EFI_ERROR (Status) && Variable->CurrPtr != 0) {\r
- State = ((VARIABLE_HEADER *)Variable->CurrPtr)->State;\r
+ State = ((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State;\r
State &= VAR_DELETED;\r
\r
Status = AccessVariableStore (\r
VariableGlobal,\r
Variable->Volatile,\r
Instance,\r
- (UINTN) &(((VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
+ (UINTN) &(((AUTHENTICATED_VARIABLE_HEADER *)Variable->CurrPtr)->State),\r
sizeof (UINT8),\r
&State\r
);\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
+\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
+ @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
+ @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_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
+ @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
IN ESAL_VARIABLE_GLOBAL *Global\r
)\r
{\r
- VARIABLE_POINTER_TRACK Variable;\r
- UINTN VarDataSize;\r
- EFI_STATUS Status;\r
- VARIABLE_HEADER VariableHeader;\r
- BOOLEAN Valid;\r
- VARIABLE_GLOBAL *VariableGlobal;\r
- UINT32 Instance;\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
*DataSize = VarDataSize;\r
UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE, FALSE, FALSE, FALSE);\r
UpdateVariableCache (VariableName, VendorGuid, VariableHeader.Attributes, VarDataSize, Data);\r
- \r
+\r
Status = EFI_SUCCESS;\r
goto Done;\r
} else {\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
+\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
+ 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_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
+ @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
IN ESAL_VARIABLE_GLOBAL *Global\r
)\r
{\r
- VARIABLE_POINTER_TRACK Variable;\r
- UINTN VarNameSize;\r
- EFI_STATUS Status;\r
- VARIABLE_HEADER VariableHeader;\r
- VARIABLE_GLOBAL *VariableGlobal;\r
- UINT32 Instance;\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
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
+\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
+ 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] 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
+ @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
+ @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
//\r
if (VariableName == NULL || VariableName[0] == 0 || VendorGuid == NULL) {\r
return EFI_INVALID_PARAMETER;\r
- } \r
+ }\r
\r
if (DataSize != 0 && Data == NULL) {\r
return EFI_INVALID_PARAMETER;\r
// Try to write Authencated Variable without AuthInfo\r
//\r
return EFI_SECURITY_VIOLATION;\r
- } \r
- PayloadSize = DataSize - AUTHINFO_SIZE; \r
+ }\r
+ PayloadSize = DataSize - AUTHINFO_SIZE;\r
} else {\r
- PayloadSize = DataSize; \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
// 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 ((PayloadSize > PcdGet32(PcdMaxHardwareErrorVariableSize)) || \r
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxHardwareErrorVariableSize))) {\r
+ if (StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxHardwareErrorVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER)) {\r
return EFI_INVALID_PARAMETER;\r
}\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 ((PayloadSize > PcdGet32(PcdMaxVariableSize)) ||\r
- (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxVariableSize))) {\r
+ if (StrSize (VariableName) + PayloadSize > PcdGet32(PcdMaxVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER)) {\r
return EFI_INVALID_PARAMETER;\r
- } \r
- } \r
+ }\r
+ }\r
\r
AcquireLockOnlyAtBootTime(&VariableGlobal->VariableServicesLock);\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
+ 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
+ // 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
+ VariableName,\r
+ VendorGuid,\r
+ Data,\r
+ DataSize,\r
+ Attributes,\r
+ 0,\r
+ 0,\r
+ VirtualMode,\r
+ Global,\r
&Variable\r
);\r
}\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
+ @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
+ @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
+ @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
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
- VARIABLE_HEADER VariableHeader;\r
- UINT64 CommonVariableTotalSize;\r
- UINT64 HwErrVariableTotalSize;\r
- VARIABLE_GLOBAL *VariableGlobal;\r
- UINT32 Instance;\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
if(MaximumVariableStorageSize == NULL || RemainingVariableStorageSize == NULL || MaximumVariableSize == NULL || Attributes == 0) {\r
return EFI_INVALID_PARAMETER;\r
}\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
+ 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
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 (VARIABLE_HEADER);\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
//\r
// Let *MaximumVariableSize be PcdGet32(PcdMaxVariableSize) with the exception of the variable header size.\r
//\r
- *MaximumVariableSize = PcdGet32(PcdMaxVariableSize) - sizeof (VARIABLE_HEADER);\r
+ *MaximumVariableSize = PcdGet32(PcdMaxVariableSize) - sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
}\r
\r
//\r
*RemainingVariableStorageSize = *MaximumVariableStorageSize - CommonVariableTotalSize;\r
}\r
\r
- if (*RemainingVariableStorageSize < sizeof (VARIABLE_HEADER)) {\r
+ if (*RemainingVariableStorageSize < sizeof (AUTHENTICATED_VARIABLE_HEADER)) {\r
*MaximumVariableSize = 0;\r
- } else if ((*RemainingVariableStorageSize - sizeof (VARIABLE_HEADER)) < *MaximumVariableSize) {\r
- *MaximumVariableSize = *RemainingVariableStorageSize - sizeof (VARIABLE_HEADER);\r
+ } else if ((*RemainingVariableStorageSize - sizeof (AUTHENTICATED_VARIABLE_HEADER)) < *MaximumVariableSize) {\r
+ *MaximumVariableSize = *RemainingVariableStorageSize - sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
}\r
\r
ReleaseLockOnlyAtBootTime (&VariableGlobal->VariableServicesLock);\r
UINTN RemainingHwErrVariableSpace;\r
\r
VarSize = ((VARIABLE_STORE_HEADER *) ((UINTN) mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase))->Size;\r
- Status = EFI_SUCCESS; \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
+\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
+ || ((PcdGet32 (PcdHwErrStorageSize) != 0) &&\r
(RemainingHwErrVariableSpace < PcdGet32 (PcdMaxHardwareErrorVariableSize)))){\r
Status = Reclaim (\r
mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase,\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
//\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
+ // 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
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
+ GetPhysicalAddressFunctionId,\r
+ Instance,\r
+ (UINT64) &FvVolHdr,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
0\r
).Status;\r
if (EFI_ERROR (Status)) {\r
Instance\r
);\r
VariableSize = NextVariable - Variable;\r
- if ((((VARIABLE_HEADER *)Variable)->Attributes & (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) == (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_HARDWARE_ERROR_RECORD)) {\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
// Register the event handling function to reclaim variable for OS usage.\r
//\r
Status = EfiCreateEventReadyToBootEx (\r
- TPL_NOTIFY, \r
- ReclaimForOS, \r
- NULL, \r
+ TPL_NOTIFY,\r
+ ReclaimForOS,\r
+ NULL,\r
&ReadyToBootEvent\r
);\r
} else {\r
Status = EFI_VOLUME_CORRUPTED;\r
- DEBUG((EFI_D_INFO, "Variable Store header is corrupted\n"));\r
+ DEBUG((EFI_D_ERROR, "Variable Store header is corrupted\n"));\r
}\r
\r
Done:\r